KASAN: use-after-free Read in fuse_copy_do

Status: upstream: reported C repro on 2022/11/15 07:48
First crash: 469d, last: 469d
Fix bisection: failed (error log, bisect log)
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in fuse_copy_do C 1 365d 469d 0/1 upstream: reported C repro on 2022/11/15 20:38

Sample crash report:
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
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

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

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/11/15 07:47 linux-4.19.y 3f8a27f9e27b 97de9cfc .config console log report syz C [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in fuse_copy_do
* Struck through repros no longer work on HEAD.