bcachefs (loop0): check_inodes... done bcachefs (loop0): check_dirents... bcachefs (loop0): directory with missing backpointer u64s 7 type dirent 4096:917846673077883043:U32_MAX len 0 ver 0: file0 -> 4098 type dir inum: 4098:4294967295 mode=40600 flags=(4300000) journal_seq=24 hash_seed=e561e402f9d4e5ab hash_type=siphash bi_size=0 bi_sectors=0 bi_version=0 bi_atime=30644730119931988 bi_ctime=30644730119931988 bi_mtime=30644730119931988 bi_otime=30644730119931988 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=0 bi_subvol=0 bi_parent_subvol=0 bi_nocow=0 bi_depth=0 bi_inodes_32bit=0, fixing bcachefs (loop0): key in missing snapshot dirents u64s 8 type dirent 4096:1859603997870691834:4290052095 len 0 ver 0: lost+found -> 4097 type dir, deleting bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:4049365536653451559:U32_MAX len 0 ver 0: file2 -> 1073741825 type reg, fixing bcachefs (loop0): dirent points to missing inode: u64s 8 type dirent 4096:6961650737852714117:U32_MAX len 0 ver 0: file.cold -> 1073741826 type reg, fixing bcachefs (loop0): directory 4096:4294967295 with wrong i_nlink: got 0, should be 1, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4098:2017255989106902683:U32_MAX len 0 ver 0: file0 -> 4099 type reg, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4098:2017255989106902683:U32_MAX len 0 ver 0: file0 -> 4099 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2247 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x2aac/0x3b90 fs/bcachefs/fsck.c:2272 Read of size 1 at addr ffff8880563e0170 by task syz.0.0/5327 CPU: 0 UID: 0 PID: 5327 Comm: syz.0.0 Not tainted 6.15.0-rc3-syzkaller-00008-ga33b5a08cbbd #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 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:408 [inline] print_report+0x16e/0x5b0 mm/kasan/report.c:521 kasan_report+0x143/0x180 mm/kasan/report.c:634 check_dirent fs/bcachefs/fsck.c:2247 [inline] bch2_check_dirents+0x2aac/0x3b90 fs/bcachefs/fsck.c:2272 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:285 bch2_fs_recovery+0x2c65/0x3e20 fs/bcachefs/recovery.c:973 bch2_fs_start+0x310/0x620 fs/bcachefs/super.c:1065 bch2_fs_get_tree+0x113e/0x18f0 fs/bcachefs/fs.c:2253 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 do_new_mount+0x2cf/0xb70 fs/namespace.c:3881 do_mount fs/namespace.c:4221 [inline] __do_sys_mount fs/namespace.c:4432 [inline] __se_sys_mount+0x38c/0x400 fs/namespace.c:4409 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf3/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7ff39298f90a 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:00007ff3937f3e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007ff3937f3ef0 RCX: 00007ff39298f90a RDX: 000020000000f640 RSI: 0000200000000080 RDI: 00007ff3937f3eb0 RBP: 000020000000f640 R08: 00007ff3937f3ef0 R09: 0000000000010000 R10: 0000000000010000 R11: 0000000000000246 R12: 0000200000000080 R13: 00007ff3937f3eb0 R14: 000000000000f63d R15: 00002000000004c0 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x563e0 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 04fff00000000000 ffffea0001597808 ffff88805ffd6f08 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 5327, tgid 5326 (syz.0.0), ts 71273723398, free_ts 71644653234 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1718 prep_new_page mm/page_alloc.c:1726 [inline] get_page_from_freelist+0x360a/0x37a0 mm/page_alloc.c:3688 __alloc_frozen_pages_noprof+0x211/0x5b0 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+0x92/0x210 mm/slub.c:4285 __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4313 __do_kmalloc_node mm/slub.c:4329 [inline] __kvmalloc_node_noprof+0x7c/0x5a0 mm/slub.c:5026 btree_bounce_alloc fs/bcachefs/btree_io.c:124 [inline] btree_node_sort+0x67c/0x1870 fs/bcachefs/btree_io.c:323 bch2_btree_post_write_cleanup+0x11a/0xaa0 fs/bcachefs/btree_io.c:2508 bch2_btree_node_write_trans+0x18a/0x7a0 fs/bcachefs/btree_io.c:2577 btree_node_write_if_need fs/bcachefs/btree_io.h:157 [inline] __btree_node_flush+0x3a1/0x470 fs/bcachefs/btree_trans_commit.c:253 bch2_btree_node_flush1+0x2a/0x40 fs/bcachefs/btree_trans_commit.c:267 journal_flush_pins+0x89b/0xe40 fs/bcachefs/journal_reclaim.c:589 journal_flush_pins_or_still_flushing fs/bcachefs/journal_reclaim.c:859 [inline] journal_flush_done+0x107/0x820 fs/bcachefs/journal_reclaim.c:877 bch2_journal_flush_pins+0x23a/0x3c0 fs/bcachefs/journal_reclaim.c:909 bch2_journal_flush_all_pins fs/bcachefs/journal_reclaim.h:76 [inline] bch2_fs_recovery+0x2af1/0x3e20 fs/bcachefs/recovery.c:957 page last free pid 5327 tgid 5326 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1262 [inline] __free_pages_ok+0xb1d/0xda0 mm/page_alloc.c:1438 __folio_put+0x2b5/0x360 mm/swap.c:112 folio_put include/linux/mm.h:1580 [inline] free_large_kmalloc+0x143/0x1e0 mm/slub.c:4781 kfree+0x216/0x430 mm/slub.c:4849 btree_bounce_free fs/bcachefs/btree_io.c:112 [inline] btree_node_sort+0x1124/0x1870 fs/bcachefs/btree_io.c:380 bch2_btree_post_write_cleanup+0x11a/0xaa0 fs/bcachefs/btree_io.c:2508 bch2_btree_node_prep_for_write+0x35a/0x670 fs/bcachefs/btree_trans_commit.c:93 bch2_trans_lock_write+0x66f/0xb60 fs/bcachefs/btree_trans_commit.c:129 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:840 [inline] __bch2_trans_commit+0x3252/0x9da0 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+0x2801/0x3b90 fs/bcachefs/fsck.c:2272 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:285 bch2_fs_recovery+0x2c65/0x3e20 fs/bcachefs/recovery.c:973 bch2_fs_start+0x310/0x620 fs/bcachefs/super.c:1065 bch2_fs_get_tree+0x113e/0x18f0 fs/bcachefs/fs.c:2253 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 Memory state around the buggy address: ffff8880563e0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880563e0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880563e0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880563e0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880563e0200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================