done bcachefs (loop7): check_extents... done bcachefs (loop7): check_dirents... dirent points to missing inode: u64s 8 type dirent 4096:6728544935518790663:U32_MAX len 0 ver 0: lost+found -> 4097 type dir, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2351 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x107b/0x1190 fs/bcachefs/fsck.c:2375 Read of size 1 at addr ffff888157cc3070 by task syz.7.20/5375 CPU: 0 UID: 0 PID: 5375 Comm: syz.7.20 Not tainted 6.13.0-rc3-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x5a/0x90 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xc3/0x620 mm/kasan/report.c:489 kasan_report+0xd9/0x110 mm/kasan/report.c:602 check_dirent fs/bcachefs/fsck.c:2351 [inline] bch2_check_dirents+0x107b/0x1190 fs/bcachefs/fsck.c:2375 bch2_run_recovery_pass+0x7a/0x160 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ce/0x6f0 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2fd4/0x37c0 fs/bcachefs/recovery.c:974 bch2_fs_start+0x2ae/0x530 fs/bcachefs/super.c:1032 bch2_fs_get_tree+0xd03/0x1700 fs/bcachefs/fs.c:2200 vfs_get_tree+0x88/0x240 fs/super.c:1814 do_new_mount fs/namespace.c:3507 [inline] path_mount+0x8ea/0x1a70 fs/namespace.c:3834 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4057 [inline] __se_sys_mount fs/namespace.c:4034 [inline] __x64_sys_mount+0x209/0x280 fs/namespace.c:4034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x6d/0x1a0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fbcb978e84a 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:00007fbcba6c2e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fbcba6c2ef0 RCX: 00007fbcb978e84a RDX: 0000400000000000 RSI: 0000400000000040 RDI: 00007fbcba6c2eb0 RBP: 0000400000000000 R08: 00007fbcba6c2ef0 R09: 0000000001000001 R10: 0000000001000001 R11: 0000000000000246 R12: 0000400000000040 R13: 00007fbcba6c2eb0 R14: 000000000000595c R15: 0000400000000140 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x157cc3 flags: 0x100000000000000(node=0|zone=2) raw: 0100000000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as freed page last allocated via order 5, migratetype Unmovable, gfp_mask 0x52800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP), pid 5375, tgid 5374 (syz.7.20), ts 102860807557, free_ts 105808568690 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x283/0x300 mm/page_alloc.c:1556 prep_new_page mm/page_alloc.c:1564 [inline] get_page_from_freelist+0x17fd/0x49d0 mm/page_alloc.c:3474 __alloc_pages_noprof+0x1cf/0x4a0 mm/page_alloc.c:4751 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] ___kmalloc_large_node+0xad/0x160 mm/slub.c:4243 __kmalloc_large_node_noprof+0x1a/0xd0 mm/slub.c:4270 __do_kmalloc_node mm/slub.c:4286 [inline] __kmalloc_node_noprof+0x42b/0x560 mm/slub.c:4304 __kvmalloc_node_noprof+0x42/0xd0 mm/util.c:650 btree_bounce_alloc+0x109/0x1f0 fs/bcachefs/btree_io.c:123 bch2_btree_node_read_done+0xbae/0x41d0 fs/bcachefs/btree_io.c:1222 btree_node_read_work+0x513/0xdf0 fs/bcachefs/btree_io.c:1358 bch2_btree_node_read+0x6f6/0xca0 fs/bcachefs/btree_io.c:1748 __bch2_btree_root_read fs/bcachefs/btree_io.c:1789 [inline] bch2_btree_root_read+0x220/0x3d0 fs/bcachefs/btree_io.c:1811 read_btree_roots fs/bcachefs/recovery.c:582 [inline] bch2_fs_recovery+0x2067/0x37c0 fs/bcachefs/recovery.c:929 bch2_fs_start+0x2ae/0x530 fs/bcachefs/super.c:1032 bch2_fs_get_tree+0xd03/0x1700 fs/bcachefs/fs.c:2200 vfs_get_tree+0x88/0x240 fs/super.c:1814 page last free pid 5375 tgid 5374 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] __free_pages_ok+0x675/0xe60 mm/page_alloc.c:1269 __folio_put+0x258/0x350 mm/swap.c:112 btree_bounce_free fs/bcachefs/btree_io.c:111 [inline] btree_node_sort+0xe73/0x14e0 fs/bcachefs/btree_io.c:379 bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2293 [inline] bch2_btree_post_write_cleanup+0x10a/0x600 fs/bcachefs/btree_io.c:2267 bch2_btree_node_prep_for_write fs/bcachefs/btree_trans_commit.c:93 [inline] bch2_trans_lock_write+0x685/0x920 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:862 [inline] __bch2_trans_commit+0x1b51/0x7640 fs/bcachefs/btree_trans_commit.c:1066 bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline] check_dirent fs/bcachefs/fsck.c:2347 [inline] bch2_check_dirents+0xc9e/0x1190 fs/bcachefs/fsck.c:2375 bch2_run_recovery_pass+0x7a/0x160 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ce/0x6f0 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2fd4/0x37c0 fs/bcachefs/recovery.c:974 bch2_fs_start+0x2ae/0x530 fs/bcachefs/super.c:1032 bch2_fs_get_tree+0xd03/0x1700 fs/bcachefs/fs.c:2200 vfs_get_tree+0x88/0x240 fs/super.c:1814 do_new_mount fs/namespace.c:3507 [inline] path_mount+0x8ea/0x1a70 fs/namespace.c:3834 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4057 [inline] __se_sys_mount fs/namespace.c:4034 [inline] __x64_sys_mount+0x209/0x280 fs/namespace.c:4034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x6d/0x1a0 arch/x86/entry/common.c:83 Memory state around the buggy address: ffff888157cc2f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888157cc2f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888157cc3000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888157cc3080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888157cc3100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== done bcachefs (loop7): resume_logged_ops... done bcachefs (loop7): delete_dead_inodes... done bcachefs (loop7): Second fsck run was not clean bcachefs (loop7): going read-only bcachefs (loop7): finished waiting for writes to stop bcachefs (loop7): flushing journal and stopping allocators, journal seq 33 bcachefs (loop7): flushing journal and stopping allocators complete, journal seq 33 bcachefs (loop7): clean shutdown complete, journal seq 34 bcachefs (loop7): marking filesystem clean bcachefs (loop7): done starting filesystem syz.7.20 (5375) used greatest stack depth: 16408 bytes left