syzbot


KASAN: use-after-free Read in btrfs_search_slot

Status: upstream: reported C repro on 2022/12/29 23:26
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+61a1b0ba1254fab2100e@syzkaller.appspotmail.com
First crash: 704d, last: 639d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in btrfs_search_slot btrfs C done 9 1d09h 40d 0/28 upstream: reported C repro on 2024/10/24 03:50

Sample crash report:
BTRFS info (device loop0): enabling ssd optimizations
BTRFS info (device loop0): using spread ssd allocation scheme
BTRFS info (device loop0): using free space tree
BTRFS info (device loop0): has skinny extents
==================================================================
BUG: KASAN: use-after-free in btrfs_search_slot+0x1cca/0x1ee0 fs/btrfs/ctree.c:2793
Read of size 8 at addr ffff88809ae702b0 by task btrfs-ino-cache/28967

CPU: 0 PID: 28967 Comm: btrfs-ino-cache Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
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 mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 btrfs_search_slot+0x1cca/0x1ee0 fs/btrfs/ctree.c:2793
 caching_kthread+0x275/0x970 fs/btrfs/inode-map.c:61
 kthread+0x33f/0x460 kernel/kthread.c:259
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Allocated by task 28938:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 btrfs_alloc_root fs/btrfs/disk-io.c:1220 [inline]
 btrfs_read_tree_root+0x94/0x560 fs/btrfs/disk-io.c:1421
 btrfs_read_fs_root fs/btrfs/disk-io.c:1467 [inline]
 btrfs_get_fs_root+0x239/0x890 fs/btrfs/disk-io.c:1601
 btrfs_read_fs_root_no_name fs/btrfs/disk-io.h:80 [inline]
 open_ctree+0x469c/0x61e0 fs/btrfs/disk-io.c:3181
 btrfs_fill_super fs/btrfs/super.c:1209 [inline]
 btrfs_mount_root+0x12e5/0x1830 fs/btrfs/super.c:1613
 mount_fs+0xa3/0x310 fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:951
 btrfs_mount+0x23a/0xaa0 fs/btrfs/super.c:1681
 mount_fs+0xa3/0x310 fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2492 [inline]
 do_mount+0x115c/0x2f50 fs/namespace.c:2822
 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 8095:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 btrfs_put_fs_root fs/btrfs/disk-io.h:111 [inline]
 btrfs_free_fs_root+0x1e6/0x260 fs/btrfs/disk-io.c:3861
 btrfs_free_fs_roots+0x2ef/0x4d0 fs/btrfs/disk-io.c:2092
 close_ctree+0x306/0x850 fs/btrfs/disk-io.c:4017
 generic_shutdown_super+0x144/0x370 fs/super.c:456
 kill_anon_super+0x36/0x60 fs/super.c:1032
 btrfs_kill_super+0x49/0x550 fs/btrfs/super.c:2221
 deactivate_locked_super+0x94/0x160 fs/super.c:329
 deactivate_super+0x174/0x1a0 fs/super.c:360
 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

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

Memory state around the buggy address:
 ffff88809ae70180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809ae70200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809ae70280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff88809ae70300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809ae70380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/26 22:53 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report syz C [disk image] [vmlinux] [mounted in repro] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2022/12/29 23:25 linux-4.19.y 3f8a27f9e27b 44712fbc .config console log report syz C [disk image] [vmlinux] [mounted in repro] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2023/03/04 13:39 linux-4.19.y 3f8a27f9e27b f8902b57 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2023/02/26 14:45 linux-4.19.y 3f8a27f9e27b ee50e71c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2023/01/29 13:46 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2023/01/27 07:19 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
2023/01/21 20:25 linux-4.19.y 3f8a27f9e27b cc0f9968 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in btrfs_search_slot
* Struck through repros no longer work on HEAD.