KASAN: use-after-free Read in fuse_copy_do

11 views
Skip to first unread message

syzbot

unread,
Nov 15, 2022, 2:48:44 AM11/15/22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15619785880000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=4dc2faf87ca4ca604587
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=162cf0e9880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16167785880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/98c0bdb4abb3/disk-3f8a27f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea228ff02669/vmlinux-3f8a27f9.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+4dc2fa...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:377 [inline]
BUG: KASAN: use-after-free in fuse_copy_do+0x34a/0x430 fs/fuse/dev.c:817
Read of size 256 at addr ffff88809d072590 by task syz-executor416/8196

CPU: 0 PID: 8196 Comm: syz-executor416 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report+0x8f/0xa0 mm/kasan/report.c:412
memcpy+0x20/0x50 mm/kasan/kasan.c:302
memcpy include/linux/string.h:377 [inline]
fuse_copy_do+0x34a/0x430 fs/fuse/dev.c:817
fuse_copy_one fs/fuse/dev.c:1053 [inline]
fuse_copy_args+0x1fa/0x530 fs/fuse/dev.c:1071
fuse_dev_do_read+0x15ac/0x20e0 fs/fuse/dev.c:1327
fuse_dev_read+0x156/0x1f0 fs/fuse/dev.c:1393
call_read_iter include/linux/fs.h:1815 [inline]
new_sync_read fs/read_write.c:406 [inline]
__vfs_read+0x518/0x750 fs/read_write.c:418
vfs_read+0x194/0x3c0 fs/read_write.c:452
ksys_read+0x12b/0x2a0 fs/read_write.c:579
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f9b0a3b61d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9b0a3032f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f9b0a4474f0 RCX: 00007f9b0a3b61d9
RDX: 0000000000002020 RSI: 0000000020002140 RDI: 0000000000000003
RBP: 00007f9b0a41428c R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f9b0a40e168
R13: 00007f9b0a410280 R14: 00007f9b0a412288 R15: 00007f9b0a4474f8

Allocated by task 8160:
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15a/0x3c0 mm/slab.c:3736
kmalloc include/linux/slab.h:520 [inline]
__d_alloc+0x636/0xa10 fs/dcache.c:1629
d_alloc+0x4a/0x230 fs/dcache.c:1696
d_alloc_parallel+0xeb/0x19e0 fs/dcache.c:2443
__lookup_slow+0x18d/0x4a0 fs/namei.c:1655
lookup_slow fs/namei.c:1689 [inline]
walk_component+0x7ac/0xda0 fs/namei.c:1811
lookup_last fs/namei.c:2274 [inline]
path_lookupat+0x1ff/0x8d0 fs/namei.c:2319
filename_lookup+0x1ac/0x5a0 fs/namei.c:2349
user_path include/linux/namei.h:62 [inline]
do_mount+0x147/0x2f50 fs/namespace.c:2762
ksys_mount+0xcf/0x130 fs/namespace.c:3038
__do_sys_mount fs/namespace.c:3052 [inline]
__se_sys_mount fs/namespace.c:3049 [inline]
__x64_sys_mount+0xba/0x150 fs/namespace.c:3049
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 0:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff88809d072580
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 16 bytes inside of
512-byte region [ffff88809d072580, ffff88809d072780)
The buggy address belongs to the page:
page:ffffea0002741c80 count:1 mapcount:0 mapping:ffff88813bff0940 index:0xffff88809d072a80
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea000275b7c8 ffffea000275b748 ffff88813bff0940
raw: ffff88809d072a80 ffff88809d072080 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809d072480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809d072500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809d072580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809d072600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809d072680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Nov 15, 2022, 3:38:41 PM11/15/22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e911713e40ca Linux 4.14.299
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=149e038e880000
kernel config: https://syzkaller.appspot.com/x/.config?x=1d7ed9728cc57838
dashboard link: https://syzkaller.appspot.com/bug?extid=838dae48269e71d6f5c6
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13675bf5880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13c5ac01880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c8588259d654/disk-e911713e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/700d08072e5e/vmlinux-e911713e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/844ad5da2ed5/bzImage-e911713e.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+838dae...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:376 [inline]
BUG: KASAN: use-after-free in fuse_copy_do+0x32f/0x430 fs/fuse/dev.c:810
Read of size 256 at addr ffff8880a91d62d0 by task syz-executor280/8941

CPU: 0 PID: 8941 Comm: syz-executor280 Not tainted 4.14.299-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report+0x6f/0x80 mm/kasan/report.c:409
memcpy+0x20/0x50 mm/kasan/kasan.c:302
memcpy include/linux/string.h:376 [inline]
fuse_copy_do+0x32f/0x430 fs/fuse/dev.c:810
fuse_copy_one fs/fuse/dev.c:1061 [inline]
fuse_copy_args+0x183/0x420 fs/fuse/dev.c:1079
fuse_dev_do_read+0x161e/0x2150 fs/fuse/dev.c:1337
fuse_dev_read+0x12a/0x1a0 fs/fuse/dev.c:1403
call_read_iter include/linux/fs.h:1774 [inline]
new_sync_read fs/read_write.c:401 [inline]
__vfs_read+0x449/0x620 fs/read_write.c:413
vfs_read+0x139/0x340 fs/read_write.c:447
SYSC_read fs/read_write.c:574 [inline]
SyS_read+0xf2/0x210 fs/read_write.c:567
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Allocated by task 8936:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15a/0x400 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
__d_alloc+0x61f/0xa20 fs/dcache.c:1639
d_alloc+0x46/0x240 fs/dcache.c:1710
d_alloc_parallel+0xd6/0x16b0 fs/dcache.c:2492
lookup_slow+0x175/0x400 fs/namei.c:1679
walk_component+0x6a1/0xbc0 fs/namei.c:1825
lookup_last fs/namei.c:2293 [inline]
path_lookupat+0x1bb/0x780 fs/namei.c:2343
filename_lookup+0x18a/0x510 fs/namei.c:2377
user_path include/linux/namei.h:62 [inline]
do_mount+0x118/0x2a30 fs/namespace.c:2845
SYSC_mount fs/namespace.c:3121 [inline]
SyS_mount+0xa8/0x120 fs/namespace.c:3098
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Freed by task 0:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2699 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
rcu_process_callbacks+0x780/0x1180 kernel/rcu/tree.c:2946
__do_softirq+0x24d/0x9ff kernel/softirq.c:288

The buggy address belongs to the object at ffff8880a91d62c0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 16 bytes inside of
512-byte region [ffff8880a91d62c0, ffff8880a91d64c0)
The buggy address belongs to the page:
page:ffffea0002a47580 count:1 mapcount:0 mapping:ffff8880a91d6040 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880a91d6040 0000000000000000 0000000100000006
raw: ffffea0002aaf3e0 ffffea0002a49a60 ffff88813fe74940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a91d6180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a91d6200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a91d6280: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8880a91d6300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a91d6380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
Reply all
Reply to author
Forward
0 new messages