bcachefs (loop1): dirent points to missing inode: u64s 7 type dirent 4096:2695648408715017799:U32_MAX len 0 ver 0: file2 -> 536870913 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent+0x3520/0x3630 fs/bcachefs/fsck.c:2396 Read of size 1 at addr ffff88804ba00110 by task syz.1.2387/12562 CPU: 0 UID: 0 PID: 12562 Comm: syz.1.2387 Not tainted 6.16.0-syzkaller-06699-ge8d780dcd957 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 check_dirent+0x3520/0x3630 fs/bcachefs/fsck.c:2396 bch2_check_dirents+0x429/0x950 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x520/0x10c0 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x2d1/0x480 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2f55/0x48a0 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xdd0/0x1450 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xd9b/0x1b70 fs/bcachefs/fs.c:2488 vfs_get_tree+0x8e/0x340 fs/super.c:1815 do_new_mount fs/namespace.c:3805 [inline] path_mount+0x1482/0x1fd0 fs/namespace.c:4120 do_mount fs/namespace.c:4133 [inline] __do_sys_mount fs/namespace.c:4344 [inline] __se_sys_mount fs/namespace.c:4321 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4321 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f470359014a 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:00007f4704324e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f4704324ef0 RCX: 00007f470359014a RDX: 0000200000000080 RSI: 00002000000000c0 RDI: 00007f4704324eb0 RBP: 0000200000000080 R08: 00007f4704324ef0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00002000000000c0 R13: 00007f4704324eb0 R14: 000000000000596f R15: 00002000000001c0 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ba00 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 00fff00000000000 ffff88813fffbf08 ffff88813fffbf08 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 0x42800(GFP_NOWAIT|__GFP_COMP), pid 12562, tgid 12561 (syz.1.2387), ts 562586147841, free_ts 564304765067 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1704 prep_new_page mm/page_alloc.c:1712 [inline] get_page_from_freelist+0x1321/0x3890 mm/page_alloc.c:3669 __alloc_frozen_pages_noprof+0x261/0x23f0 mm/page_alloc.c:4959 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2419 ___kmalloc_large_node+0xed/0x160 mm/slub.c:4305 __kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:4336 __do_kmalloc_node mm/slub.c:4352 [inline] __kvmalloc_node_noprof.cold+0xb/0x65 mm/slub.c:5051 btree_bounce_alloc+0x115/0x200 fs/bcachefs/btree_io.c:127 bch2_btree_node_read_done+0x10d6/0x4e50 fs/bcachefs/btree_io.c:1278 btree_node_read_work+0x2c9/0xe00 fs/bcachefs/btree_io.c:1440 bch2_btree_node_read+0x891/0xe20 fs/bcachefs/btree_io.c:1865 __bch2_btree_root_read fs/bcachefs/btree_io.c:1906 [inline] bch2_btree_root_read+0x2d1/0x480 fs/bcachefs/btree_io.c:1928 read_btree_roots fs/bcachefs/recovery.c:615 [inline] bch2_fs_recovery+0x2271/0x48a0 fs/bcachefs/recovery.c:1006 bch2_fs_start+0xdd0/0x1450 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xd9b/0x1b70 fs/bcachefs/fs.c:2488 vfs_get_tree+0x8e/0x340 fs/super.c:1815 page last free pid 12562 tgid 12561 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1248 [inline] __free_pages_ok+0x765/0x10e0 mm/page_alloc.c:1424 btree_bounce_free fs/bcachefs/btree_io.c:115 [inline] btree_node_sort+0x101c/0x1560 fs/bcachefs/btree_io.c:383 bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2607 [inline] bch2_btree_post_write_cleanup+0x14b/0x860 fs/bcachefs/btree_io.c:2581 bch2_btree_node_prep_for_write+0x354/0x550 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x695/0x8c0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:850 [inline] __bch2_trans_commit+0x280d/0x8570 fs/bcachefs/btree_trans_commit.c:1085 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] check_dirent+0x16cf/0x3630 fs/bcachefs/fsck.c:2391 bch2_check_dirents+0x429/0x950 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x520/0x10c0 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x2d1/0x480 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2f55/0x48a0 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xdd0/0x1450 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xd9b/0x1b70 fs/bcachefs/fs.c:2488 vfs_get_tree+0x8e/0x340 fs/super.c:1815 do_new_mount fs/namespace.c:3805 [inline] path_mount+0x1482/0x1fd0 fs/namespace.c:4120 do_mount fs/namespace.c:4133 [inline] __do_sys_mount fs/namespace.c:4344 [inline] __se_sys_mount fs/namespace.c:4321 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4321 Memory state around the buggy address: ffff88804ba00000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804ba00080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff88804ba00100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff88804ba00180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804ba00200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== bcachefs (loop1): hash table key at wrong offset: should be at 5178636093158006573 u64s 8 type dirent 4096:8130059955150870709:U32_MAX len 0 ver 0: lost+foun -> 4097 type dir, fixing bcachefs (loop1): dirent points to missing inode: u64s 8 type dirent 4096:9097378837824744618:U32_MAX len 0 ver 0: file.cold -> 172335562754 type reg, fixing bcachefs (loop1): fsck counted subdirectories wrong for inum 4096:4294967295: got 1 should be 2 bcachefs (loop1): check_dirents requires second pass done bcachefs (loop1): resume_logged_ops... done bcachefs (loop1): delete_dead_inodes... done bcachefs (loop1): Fixed errors, running fsck a second time to verify fs is clean bcachefs (loop1): check_extents_to_backpointers... done bcachefs (loop1): check_subvols... done bcachefs (loop1): check_inodes... done bcachefs (loop1): check_dirents... done bcachefs (loop1): resume_logged_ops... done bcachefs (loop1): delete_dead_inodes... done bcachefs (loop1): done starting filesystem syz.1.2387 (12562) used greatest stack depth: 16088 bytes left