inode 4100:4294967295 has wrong backpointer: got 0:7520985256299251607 should be 4098:7520985256299251607, fixing incorrect d_type: got lnk, should be reg: u64s 7 type dirent 4098:7520985256299251607:U32_MAX len 0 ver 0: file1 -> 4100 type lnk, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent+0x1ec6/0x21c0 fs/bcachefs/fsck.c:2422 Read of size 1 at addr ffff8880420a3120 by task syz.6.3450/18349 CPU: 0 UID: 0 PID: 18349 Comm: syz.6.3450 Not tainted 6.14.0-syzkaller-01103-g2df0c02dab82 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/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:408 [inline] print_report+0xc3/0x670 mm/kasan/report.c:521 kasan_report+0xe0/0x110 mm/kasan/report.c:634 check_dirent+0x1ec6/0x21c0 fs/bcachefs/fsck.c:2422 bch2_check_dirents+0x408/0x780 fs/bcachefs/fsck.c:2447 bch2_run_recovery_pass+0x91/0x1a0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x40b/0x900 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2961/0x43f0 fs/bcachefs/recovery.c:936 bch2_fs_start+0x343/0x660 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0x1176/0x17c0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x8e/0x340 fs/super.c:1759 do_new_mount fs/namespace.c:3878 [inline] path_mount+0x14d4/0x1f30 fs/namespace.c:4205 do_mount fs/namespace.c:4218 [inline] __do_sys_mount fs/namespace.c:4429 [inline] __se_sys_mount fs/namespace.c:4406 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4406 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f92e418e90a 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:00007f92e5068e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f92e5068ef0 RCX: 00007f92e418e90a RDX: 0000200000000000 RSI: 0000200000000040 RDI: 00007f92e5068eb0 RBP: 0000200000000000 R08: 00007f92e5068ef0 R09: 0000000001000001 R10: 0000000001000001 R11: 0000000000000246 R12: 0000200000000040 R13: 00007f92e5068eb0 R14: 000000000000595c R15: 0000200000000140 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x4c88 pfn:0x420a3 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000004c88 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 18349, tgid 18348 (syz.6.3450), ts 1270721190034, free_ts 1279565753664 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551 prep_new_page mm/page_alloc.c:1559 [inline] get_page_from_freelist+0x10c4/0x34c0 mm/page_alloc.c:3477 __alloc_frozen_pages_noprof+0x223/0x24d0 mm/page_alloc.c:4740 __alloc_pages_noprof+0xb/0x1b0 mm/page_alloc.c:4774 __alloc_pages_node_noprof include/linux/gfp.h:265 [inline] alloc_pages_node_noprof include/linux/gfp.h:292 [inline] ___kmalloc_large_node+0x82/0x1e0 mm/slub.c:4262 __kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:4290 __do_kmalloc_node mm/slub.c:4306 [inline] __kvmalloc_node_noprof.cold+0xb/0x65 mm/slub.c:5003 btree_bounce_alloc+0x11e/0x210 fs/bcachefs/btree_io.c:123 bch2_btree_node_read_done+0xebc/0x4c90 fs/bcachefs/btree_io.c:1222 btree_node_read_work+0x568/0x1060 fs/bcachefs/btree_io.c:1358 bch2_btree_node_read+0x8bc/0xe90 fs/bcachefs/btree_io.c:1748 __bch2_btree_root_read fs/bcachefs/btree_io.c:1789 [inline] bch2_btree_root_read+0x2d1/0x470 fs/bcachefs/btree_io.c:1811 read_btree_roots fs/bcachefs/recovery.c:581 [inline] bch2_fs_recovery+0x2026/0x43f0 fs/bcachefs/recovery.c:928 bch2_fs_start+0x343/0x660 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0x1176/0x17c0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x8e/0x340 fs/super.c:1759 page last free pid 18349 tgid 18348 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] __free_pages_ok+0x622/0xe40 mm/page_alloc.c:1271 __folio_put+0x329/0x450 mm/swap.c:112 btree_bounce_free fs/bcachefs/btree_io.c:111 [inline] btree_node_sort+0xfe7/0x1580 fs/bcachefs/btree_io.c:379 bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2293 [inline] bch2_btree_post_write_cleanup+0x145/0x600 fs/bcachefs/btree_io.c:2267 bch2_btree_node_prep_for_write+0x356/0x550 fs/bcachefs/btree_trans_commit.c:93 bch2_trans_lock_write+0x6ec/0x900 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:862 [inline] __bch2_trans_commit+0x22c1/0x7f40 fs/bcachefs/btree_trans_commit.c:1070 bch2_trans_commit fs/bcachefs/btree_update.h:191 [inline] check_dirent+0xc4c/0x21c0 fs/bcachefs/fsck.c:2417 bch2_check_dirents+0x408/0x780 fs/bcachefs/fsck.c:2447 bch2_run_recovery_pass+0x91/0x1a0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x40b/0x900 fs/bcachefs/recovery_passes.c:291 bch2_fs_recovery+0x2961/0x43f0 fs/bcachefs/recovery.c:936 bch2_fs_start+0x343/0x660 fs/bcachefs/super.c:1041 bch2_fs_get_tree+0x1176/0x17c0 fs/bcachefs/fs.c:2203 vfs_get_tree+0x8e/0x340 fs/super.c:1759 do_new_mount fs/namespace.c:3878 [inline] path_mount+0x14d4/0x1f30 fs/namespace.c:4205 Memory state around the buggy address: ffff8880420a3000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880420a3080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880420a3100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880420a3180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880420a3200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== hash table key at wrong offset: btree dirents inode 4098 offset 8977922886548783724, hashed to 8975598395359443469 u64s 7 type dirent 4098:8977922886548783724:U32_MAX len 0 ver 0: file0 -> 4099 type reg, fixing done bcachefs (loop6): resume_logged_ops... done bcachefs (loop6): delete_dead_inodes... done bcachefs (loop6): Fixed errors, running fsck a second time to verify fs is clean bcachefs (loop6): check_lrus... done bcachefs (loop6): check_backpointers_to_extents... done bcachefs (loop6): check_inodes... inode points to missing dirent inum: 4099:4294967295 mode=100600 flags=(15300000) journal_seq=22 hash_seed=81a170e3cc725f32 hash_type=siphash bi_size=4096 bi_sectors=8 bi_version=0 bi_atime=28292721113413204 bi_ctime=28292721113413204 bi_mtime=28292721113413204 bi_otime=28292721113413204 bi_uid=0 bi_gid=0 bi_nlink=0 bi_generation=0 bi_dev=0 bi_data_checksum=0 bi_compression=0 bi_project=0 bi_background_compression=0 bi_data_replicas=0 bi_promote_target=0 bi_foreground_target=0 bi_background_target=0 bi_erasure_code=0 bi_fields_set=0 bi_dir=0 bi_dir_offset=8975598395359443469 bi_subvol=0 bi_parent_subvol=0 bi_nocow=0 bi_depth=0 bi_inodes_32bit=0, fixing inode points to missing dirent inum: 536870912:4294967295 mode=100600 flags=(15300000) journal_seq=18 hash_seed=ac331f7e1c9dfdce hash_type=siphash bi_size=4096 bi_sectors=8 bi_version=0 bi_atime=28292721303413207 bi_ctime=28292721303413207 bi_mtime=28292721303413207 bi_otime=28292721303413207 bi_uid=0 bi_gid=0 bi_nlink=0 bi_generation=0 bi_dev=0 bi_data_checksum=0 bi_compression=0 bi_project=0 bi_background_compression=0 bi_data_replicas=0 bi_promote_target=0 bi_foreground_target=0 bi_background_target=0 bi_erasure_code=0 bi_fields_set=0 bi_dir=0 bi_dir_offset=2857738807885371339 bi_subvol=0 bi_parent_subvol=0 bi_nocow=0 bi_depth=0 bi_inodes_32bit=0, fixing inode points to missing dirent inum: 536870914:4294967295 mode=100600 flags=(15300000) journal_seq=20 hash_seed=71c8947da525f5ca hash_type=siphash bi_size=4096 bi_sectors=8 bi_version=0 bi_atime=28292721993413217 bi_ctime=28292721993413217 bi_mtime=28292721993413217 bi_otime=28292721993413217 bi_uid=0 bi_gid=0 bi_nlink=0 bi_generation=0 bi_dev=0 bi_data_checksum=0 bi_compression=0 bi_project=0 bi_background_compression=0 bi_data_replicas=0 bi_promote_target=0 bi_foreground_target=0 bi_background_target=0 bi_erasure_code=0 bi_fields_set=0 bi_dir=0 bi_dir_offset=1052761085488801531 bi_subvol=0 bi_parent_subvol=0 bi_nocow=0 bi_depth=0 bi_inodes_32bit=0, fixing done bcachefs (loop6): check_extents... done bcachefs (loop6): check_dirents... dirent points to missing inode: u64s 8 type dirent 4096:3664472208356215072:U32_MAX len 0 ver 0: lost+found -> 4097 type dir, fixing done bcachefs (loop6): resume_logged_ops... done bcachefs (loop6): delete_dead_inodes... done bcachefs (loop6): Second fsck run was not clean bcachefs (loop6): going read-only bcachefs (loop6): finished waiting for writes to stop bcachefs (loop6): flushing journal and stopping allocators, journal seq 26 bcachefs (loop6): flushing journal and stopping allocators complete, journal seq 27 bcachefs (loop6): clean shutdown complete, journal seq 28 bcachefs (loop6): marking filesystem clean bcachefs (loop6): done starting filesystem bcachefs (loop6): shutting down bcachefs (loop6): shutdown complete syz.6.3450 (18349) used greatest stack depth: 13720 bytes left