bcachefs (loop5): dirent points to missing inode: u64s 7 type dirent 4098:4600437421902197670:U32_MAX len 0 ver 0: file1 -> 4100 type lnk, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2247 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x1bac/0x2460 fs/bcachefs/fsck.c:2272 Read of size 1 at addr ffff8880925201b8 by task syz.5.531/11038 CPU: 1 UID: 0 PID: 11038 Comm: syz.5.531 Not tainted 6.15.0-rc3-syzkaller-00283-gf1a3944c860b #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/19/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xb4/0x290 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 check_dirent fs/bcachefs/fsck.c:2247 [inline] bch2_check_dirents+0x1bac/0x2460 fs/bcachefs/fsck.c:2272 bch2_run_recovery_pass+0xdf/0x1d0 fs/bcachefs/recovery_passes.c:227 bch2_run_recovery_passes+0x2a0/0xdb0 fs/bcachefs/recovery_passes.c:280 bch2_fs_recovery+0x2399/0x37b0 fs/bcachefs/recovery.c:937 bch2_fs_start+0x70b/0xae0 fs/bcachefs/super.c:1083 bch2_fs_get_tree+0xd99/0x1340 fs/bcachefs/fs.c:2570 vfs_get_tree+0x8f/0x2b0 fs/super.c:1759 do_new_mount+0x24a/0xa40 fs/namespace.c:3884 do_mount fs/namespace.c:4224 [inline] __do_sys_mount fs/namespace.c:4435 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4412 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fc5d899010a 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:00007fc5d9819e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fc5d9819ef0 RCX: 00007fc5d899010a RDX: 000020000000f640 RSI: 0000200000000140 RDI: 00007fc5d9819eb0 RBP: 000020000000f640 R08: 00007fc5d9819ef0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000200000000140 R13: 00007fc5d9819eb0 R14: 000000000000f600 R15: 0000200000000180 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x92520 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 00fff00000000000 ffffea00024d5808 ffffea00022e2808 0000000000000000 raw: 0000000000000000 0000000000000005 00000000f0000000 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 11038, tgid 11037 (syz.5.531), ts 396063951815, free_ts 396129192960 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1d8/0x230 mm/page_alloc.c:1718 prep_new_page mm/page_alloc.c:1726 [inline] get_page_from_freelist+0x21c7/0x22a0 mm/page_alloc.c:3688 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4970 __alloc_pages_noprof+0xa/0x30 mm/page_alloc.c:5004 __alloc_pages_node_noprof include/linux/gfp.h:284 [inline] alloc_pages_node_noprof include/linux/gfp.h:311 [inline] ___kmalloc_large_node+0x85/0x200 mm/slub.c:4285 __kmalloc_large_node_noprof+0x18/0x90 mm/slub.c:4313 __do_kmalloc_node mm/slub.c:4329 [inline] __kvmalloc_node_noprof+0x74/0x5e0 mm/slub.c:5026 btree_bounce_alloc fs/bcachefs/btree_io.c:124 [inline] btree_node_sort+0x65d/0x1790 fs/bcachefs/btree_io.c:323 bch2_btree_post_write_cleanup+0x11f/0xab0 fs/bcachefs/btree_io.c:2508 bch2_btree_node_prep_for_write+0x341/0x660 fs/bcachefs/btree_trans_commit.c:93 bch2_trans_lock_write+0x669/0xbb0 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:840 [inline] __bch2_trans_commit+0x2cb3/0x8ae0 fs/bcachefs/btree_trans_commit.c:1050 bch2_trans_commit fs/bcachefs/btree_update.h:195 [inline] __bch2_str_hash_check_key+0x246b/0x2d80 fs/bcachefs/str_hash.c:-1 bch2_str_hash_check_key fs/bcachefs/str_hash.h:414 [inline] check_dirent fs/bcachefs/fsck.c:2177 [inline] bch2_check_dirents+0x1d31/0x2460 fs/bcachefs/fsck.c:2272 bch2_run_recovery_pass+0xdf/0x1d0 fs/bcachefs/recovery_passes.c:227 bch2_run_recovery_passes+0x2a0/0xdb0 fs/bcachefs/recovery_passes.c:280 page last free pid 11038 tgid 11037 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1262 [inline] __free_pages_ok+0x910/0xac0 mm/page_alloc.c:1438 __folio_put+0x21b/0x2c0 mm/swap.c:112 folio_put include/linux/mm.h:1580 [inline] free_large_kmalloc+0x145/0x200 mm/slub.c:4781 btree_bounce_free fs/bcachefs/btree_io.c:112 [inline] btree_node_sort+0x1149/0x1790 fs/bcachefs/btree_io.c:380 bch2_btree_post_write_cleanup+0x11f/0xab0 fs/bcachefs/btree_io.c:2508 bch2_btree_node_prep_for_write+0x341/0x660 fs/bcachefs/btree_trans_commit.c:93 bch2_trans_lock_write+0x669/0xbb0 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:840 [inline] __bch2_trans_commit+0x2cb3/0x8ae0 fs/bcachefs/btree_trans_commit.c:1050 bch2_trans_commit fs/bcachefs/btree_update.h:195 [inline] check_dirent fs/bcachefs/fsck.c:2242 [inline] bch2_check_dirents+0x19ae/0x2460 fs/bcachefs/fsck.c:2272 bch2_run_recovery_pass+0xdf/0x1d0 fs/bcachefs/recovery_passes.c:227 bch2_run_recovery_passes+0x2a0/0xdb0 fs/bcachefs/recovery_passes.c:280 bch2_fs_recovery+0x2399/0x37b0 fs/bcachefs/recovery.c:937 bch2_fs_start+0x70b/0xae0 fs/bcachefs/super.c:1083 bch2_fs_get_tree+0xd99/0x1340 fs/bcachefs/fs.c:2570 vfs_get_tree+0x8f/0x2b0 fs/super.c:1759 do_new_mount+0x24a/0xa40 fs/namespace.c:3884 Memory state around the buggy address: ffff888092520080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888092520100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888092520180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888092520200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888092520280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================