syzbot


KASAN: use-after-free Read in caching_kthread

Status: upstream: reported on 2023/01/11 15:16
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+7eccd99585531cd39044@syzkaller.appspotmail.com
First crash: 710d, last: 686d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in caching_kthread btrfs C 33 669d 734d 0/1 upstream: reported C repro on 2022/12/18 11:20

Sample crash report:
BTRFS info (device loop4): has skinny extents
audit: type=1800 audit(1675527676.401:5): pid=10299 uid=0 auid=4294967295 ses=4294967295 op="collect_data" cause="failed(directio)" comm="syz-executor.4" name="bus" dev="loop4" ino=263 res=0
==================================================================
BUG: KASAN: use-after-free in caching_kthread+0x7b9/0x8e0 fs/btrfs/inode-map.c:45
Read of size 8 at addr ffff888064700570 by task btrfs-ino-cache/10328

CPU: 0 PID: 10328 Comm: btrfs-ino-cache Not tainted 4.14.304-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
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 mm/kasan/report.c:409 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
 caching_kthread+0x7b9/0x8e0 fs/btrfs/inode-map.c:45
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:406

Allocated by task 10299:
 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
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 btrfs_alloc_root fs/btrfs/disk-io.c:1226 [inline]
 btrfs_read_tree_root+0x94/0x4a0 fs/btrfs/disk-io.c:1432
 btrfs_read_fs_root fs/btrfs/disk-io.c:1477 [inline]
 btrfs_get_fs_root+0x1b6/0x790 fs/btrfs/disk-io.c:1611
 btrfs_read_fs_root_no_name fs/btrfs/disk-io.h:89 [inline]
 open_ctree+0x4b7d/0x7530 fs/btrfs/disk-io.c:2970
 btrfs_fill_super fs/btrfs/super.c:1147 [inline]
 btrfs_mount+0x1915/0x1fe0 fs/btrfs/super.c:1631
 mount_fs+0x92/0x2a0 fs/super.c:1237
 vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1036
 mount_subvol fs/btrfs/super.c:1398 [inline]
 btrfs_mount+0x42a/0x1fe0 fs/btrfs/super.c:1569
 mount_fs+0x92/0x2a0 fs/super.c:1237
 vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046
 vfs_kern_mount fs/namespace.c:1036 [inline]
 do_new_mount fs/namespace.c:2572 [inline]
 do_mount+0xe65/0x2a30 fs/namespace.c:2905
 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 8007:
 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
 btrfs_put_fs_root fs/btrfs/disk-io.h:120 [inline]
 free_fs_root+0x270/0x320 fs/btrfs/disk-io.c:3638
 btrfs_free_fs_roots+0x294/0x440 fs/btrfs/disk-io.c:2103
 close_ctree+0x2c9/0x840 fs/btrfs/disk-io.c:3800
 generic_shutdown_super+0x144/0x370 fs/super.c:446
 kill_anon_super+0x36/0x90 fs/super.c:1006
 btrfs_kill_super+0x49/0x540 fs/btrfs/super.c:2163
 deactivate_locked_super+0x6c/0xd0 fs/super.c:319
 deactivate_super+0x7f/0xa0 fs/super.c:350
 cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3

The buggy address belongs to the object at ffff888064700380
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 496 bytes inside of
 4096-byte region [ffff888064700380, ffff888064701380)
The buggy address belongs to the page:
page:ffffea000191c000 count:1 mapcount:0 mapping:ffff888064700380 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff888064700380 0000000000000000 0000000100000001
raw: ffffea000191c220 ffffea000191ba20 ffff88813fe74dc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888064700400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888064700480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888064700500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff888064700580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888064700600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/04 16:21 linux-4.14.y 3949d1610004 be607b78 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 KASAN: use-after-free Read in caching_kthread
2023/01/21 09:05 linux-4.14.y 97205fccccdc cc0f9968 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 KASAN: use-after-free Read in caching_kthread
2023/01/13 11:21 linux-4.14.y c4215ee4771b 96166539 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 KASAN: use-after-free Read in caching_kthread
2023/01/11 15:16 linux-4.14.y c4215ee4771b 96166539 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 KASAN: use-after-free Read in caching_kthread
* Struck through repros no longer work on HEAD.