================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2396 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x1fac/0x33f0 fs/bcachefs/fsck.c:2422 Read of size 1 at addr ffff888061e00190 by task syz.0.2613/18461 CPU: 0 UID: 0 PID: 18461 Comm: syz.0.2613 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xca/0x240 mm/kasan/report.c:482 kasan_report+0x118/0x150 mm/kasan/report.c:595 check_dirent fs/bcachefs/fsck.c:2396 [inline] bch2_check_dirents+0x1fac/0x33f0 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x3bd/0x1060 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2690/0x3a50 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xaaf/0xda0 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xb39/0x1520 fs/bcachefs/fs.c:2488 vfs_get_tree+0x92/0x2b0 fs/super.c:1752 do_new_mount+0x2a2/0xa30 fs/namespace.c:3819 do_mount fs/namespace.c:4147 [inline] __do_sys_mount fs/namespace.c:4358 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4335 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f5878b9038a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f58799c6e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f58799c6ef0 RCX: 00007f5878b9038a RDX: 0000200000000080 RSI: 00002000000000c0 RDI: 00007f58799c6eb0 RBP: 0000200000000080 R08: 00007f58799c6ef0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00002000000000c0 R13: 00007f58799c6eb0 R14: 000000000000596f R15: 00002000000001c0 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x61e00 head: order:5 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f8(unknown) raw: 00fff00000000040 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000000f8000000 0000000000000000 head: 00fff00000000040 0000000000000000 dead000000000122 0000000000000000 head: 0000000000000000 0000000000000000 00000000f8000000 0000000000000000 head: 00fff00000000005 ffffea0001878001 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000020 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 5, migratetype Unmovable, gfp_mask 0x42800(GFP_NOWAIT|__GFP_COMP), pid 18502, tgid 18501 (syz.7.2619), ts 1610605703480, free_ts 1610569637894 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1850 prep_new_page mm/page_alloc.c:1858 [inline] get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3857 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5147 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2416 ___kmalloc_large_node+0x5f/0x1b0 mm/slub.c:5307 __kmalloc_large_node_noprof+0x18/0x90 mm/slub.c:5338 __do_kmalloc_node mm/slub.c:5354 [inline] __kvmalloc_node_noprof+0x6e/0x910 mm/slub.c:6527 btree_bounce_alloc fs/bcachefs/btree_io.c:127 [inline] bch2_btree_node_read_done+0x32fb/0x5560 fs/bcachefs/btree_io.c:1278 btree_node_read_work+0x40e/0xe60 fs/bcachefs/btree_io.c:1440 bch2_btree_node_read+0x887/0x2a00 fs/bcachefs/btree_io.c:-1 __bch2_btree_root_read fs/bcachefs/btree_io.c:1906 [inline] bch2_btree_root_read+0x5f0/0x760 fs/bcachefs/btree_io.c:1928 read_btree_roots+0x2c6/0x840 fs/bcachefs/recovery.c:615 bch2_fs_recovery+0x261f/0x3a50 fs/bcachefs/recovery.c:1006 bch2_fs_start+0xaaf/0xda0 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xb39/0x1520 fs/bcachefs/fs.c:2488 vfs_get_tree+0x92/0x2b0 fs/super.c:1752 page last free pid 18461 tgid 18458 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1394 [inline] __free_pages_ok+0xa83/0xbe0 mm/page_alloc.c:1570 free_large_kmalloc+0x13a/0x1f0 mm/slub.c:6255 btree_bounce_free fs/bcachefs/btree_io.c:115 [inline] btree_node_sort+0x1184/0x1760 fs/bcachefs/btree_io.c:383 bch2_btree_post_write_cleanup+0x11f/0xad0 fs/bcachefs/btree_io.c:2607 bch2_btree_node_prep_for_write+0x337/0x650 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x669/0xba0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:850 [inline] __bch2_trans_commit+0x2773/0x8880 fs/bcachefs/btree_trans_commit.c:1085 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] check_dirent fs/bcachefs/fsck.c:2391 [inline] bch2_check_dirents+0x1c5c/0x33f0 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x3bd/0x1060 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2690/0x3a50 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xaaf/0xda0 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xb39/0x1520 fs/bcachefs/fs.c:2488 vfs_get_tree+0x92/0x2b0 fs/super.c:1752 do_new_mount+0x2a2/0xa30 fs/namespace.c:3819 do_mount fs/namespace.c:4147 [inline] __do_sys_mount fs/namespace.c:4358 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4335 Memory state around the buggy address: ffff888061e00080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888061e00100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888061e00180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ ffff888061e00200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888061e00280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================