bcachefs (loop0): scanning for missing backpointers in 1/128 buckets done bcachefs (loop0): check_snapshots... done bcachefs (loop0): check_subvols... done bcachefs (loop0): check_inodes... done bcachefs (loop0): check_dirents... bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:508771216775134759:U32_MAX len 0 ver 0: file3 -> 1073741825 type reg, fixing bcachefs (loop0): directory with missing backpointer u64s 7 type dirent 4096:1316329587870451630:U32_MAX len 0 ver 0: file0 -> 4098 type dir inum: 4098:4294967295 mode=40600 flags=(4300000) journal_seq=23 hash_seed=d5d2eed0ca556c61 hash_type=siphash bi_size=0 bi_sectors=0 bi_version=0 bi_atime=29334185553495702 bi_ctime=29334185553495702 bi_mtime=29334185553495702 bi_otime=29334185553495702 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): dirent points to missing inode: u64s 7 type dirent 4096:3733564823327202707:U32_MAX len 0 ver 0: file1— -> 1073741824 type reg, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:5937062504331745319:U32_MAX len 0 ver 0: file2 -> 1073741825 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2205 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x2aac/0x3b90 fs/bcachefs/fsck.c:2230 Read of size 1 at addr ffff8880569c0138 by task syz.0.0/5324 CPU: 0 UID: 0 PID: 5324 Comm: syz.0.0 Not tainted 6.15.0-rc1-syzkaller #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:2205 [inline] bch2_check_dirents+0x2aac/0x3b90 fs/bcachefs/fsck.c:2230 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:1069 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:3879 do_mount fs/namespace.c:4219 [inline] __do_sys_mount fs/namespace.c:4430 [inline] __se_sys_mount+0x38c/0x400 fs/namespace.c:4407 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fe548d8e90a 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:00007fe5451ece68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fe5451ecef0 RCX: 00007fe548d8e90a RDX: 000020000000f640 RSI: 0000200000000140 RDI: 00007fe5451eceb0 RBP: 000020000000f640 R08: 00007fe5451ecef0 R09: 0000000000000008 R10: 0000000000000008 R11: 0000000000000246 R12: 0000200000000140 R13: 00007fe5451eceb0 R14: 000000000000f613 R15: 0000200000000180 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x569c0 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 04fff00000000000 ffffea000159b008 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 5324, tgid 5323 (syz.0.0), ts 83451948678, free_ts 83912118963 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1717 prep_new_page mm/page_alloc.c:1725 [inline] get_page_from_freelist+0x352b/0x36c0 mm/page_alloc.c:3652 __alloc_frozen_pages_noprof+0x211/0x5b0 mm/page_alloc.c:4934 __alloc_pages_noprof+0xa/0x30 mm/page_alloc.c:4968 __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:4275 __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4303 __do_kmalloc_node mm/slub.c:4319 [inline] __kvmalloc_node_noprof+0x7c/0x5a0 mm/slub.c:5016 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 5324 tgid 5323 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:1437 __folio_put+0x2b5/0x360 mm/swap.c:112 folio_put include/linux/mm.h:1563 [inline] free_large_kmalloc+0x143/0x1e0 mm/slub.c:4771 kfree+0x216/0x430 mm/slub.c:4839 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:2200 [inline] bch2_check_dirents+0x2801/0x3b90 fs/bcachefs/fsck.c:2230 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:1069 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: ffff8880569c0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880569c0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880569c0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880569c0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880569c0200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================