bcachefs (loop3): 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:2443 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x2bdc/0x3ef0 fs/bcachefs/fsck.c:2468 Read of size 1 at addr ffff888045163070 by task syz-executor112/9064 CPU: 0 UID: 0 PID: 9064 Comm: syz-executor112 Not tainted 6.14.0-rc2-next-20250214-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+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:410 [inline] print_report+0x16b/0x5a0 mm/kasan/report.c:510 kasan_report+0x143/0x180 mm/kasan/report.c:623 check_dirent fs/bcachefs/fsck.c:2443 [inline] bch2_check_dirents+0x2bdc/0x3ef0 fs/bcachefs/fsck.c:2468 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2c5c/0x3e00 fs/bcachefs/recovery.c:973 bch2_fs_start+0x37c/0x610 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0xdb7/0x17a0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 do_new_mount+0x2be/0xb40 fs/namespace.c:3659 do_mount fs/namespace.c:3999 [inline] __do_sys_mount fs/namespace.c:4210 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4187 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa63d0b0c8a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 ee 08 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffdb81a9238 EFLAGS: 00000282 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007ffdb81a9250 RCX: 00007fa63d0b0c8a RDX: 0000400000000000 RSI: 0000400000000040 RDI: 00007ffdb81a9250 RBP: 0000400000000000 R08: 00007ffdb81a9290 R09: 0000000000005956 R10: 0000000001000001 R11: 0000000000000282 R12: 0000400000000040 R13: 0000000000000004 R14: 0000000000000003 R15: 00007ffdb81a9290 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x45163 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 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 9064, tgid 9064 (syz-executor112), ts 495068659526, free_ts 499373934615 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1629 prep_new_page mm/page_alloc.c:1637 [inline] get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3555 __alloc_frozen_pages_noprof+0x292/0x710 mm/page_alloc.c:4817 __alloc_pages_noprof+0xa/0x30 mm/page_alloc.c:4851 __alloc_pages_node_noprof include/linux/gfp.h:265 [inline] alloc_pages_node_noprof include/linux/gfp.h:292 [inline] ___kmalloc_large_node+0x8b/0x1d0 mm/slub.c:4253 __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4280 __do_kmalloc_node mm/slub.c:4296 [inline] __kvmalloc_node_noprof+0x71/0x580 mm/slub.c:4987 btree_bounce_alloc fs/bcachefs/btree_io.c:124 [inline] bch2_btree_node_read_done+0x380b/0x6180 fs/bcachefs/btree_io.c:1223 btree_node_read_work+0x6e2/0x1380 fs/bcachefs/btree_io.c:1359 bch2_btree_node_read+0x243c/0x2a00 __bch2_btree_root_read fs/bcachefs/btree_io.c:1790 [inline] bch2_btree_root_read+0x626/0x7b0 fs/bcachefs/btree_io.c:1812 read_btree_roots+0x3d3/0xa70 fs/bcachefs/recovery.c:581 bch2_fs_recovery+0x2623/0x3e00 fs/bcachefs/recovery.c:928 bch2_fs_start+0x37c/0x610 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0xdb7/0x17a0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 page last free pid 9064 tgid 9064 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1205 [inline] __free_pages_ok+0xbbf/0xe40 mm/page_alloc.c:1349 __folio_put+0x2b3/0x360 mm/swap.c:112 folio_put include/linux/mm.h:1457 [inline] free_large_kmalloc+0xfe/0x180 mm/slub.c:4742 kfree+0x212/0x430 mm/slub.c:4810 btree_bounce_free fs/bcachefs/btree_io.c:112 [inline] btree_node_sort+0x1100/0x1830 fs/bcachefs/btree_io.c:380 bch2_btree_post_write_cleanup+0x11a/0xa70 fs/bcachefs/btree_io.c:2484 bch2_btree_node_prep_for_write+0x345/0x660 fs/bcachefs/btree_trans_commit.c:93 bch2_trans_lock_write+0x627/0xb10 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:839 [inline] __bch2_trans_commit+0x31ec/0x9c80 fs/bcachefs/btree_trans_commit.c:1047 bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline] check_dirent fs/bcachefs/fsck.c:2438 [inline] bch2_check_dirents+0x292f/0x3ef0 fs/bcachefs/fsck.c:2468 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2c5c/0x3e00 fs/bcachefs/recovery.c:973 bch2_fs_start+0x37c/0x610 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0xdb7/0x17a0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 Memory state around the buggy address: ffff888045162f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888045162f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888045163000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888045163080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888045163100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================