bcachefs (loop0): bucket 0:5 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing bcachefs (loop0): bucket 0:6 gen 0 has wrong data_type: got free, should be sb, fixing bcachefs (loop0): bucket 0:6 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing bcachefs (loop0): bucket 0:7 gen 0 has wrong data_type: got free, should be sb, fixing bcachefs (loop0): bucket 0:7 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing bcachefs (loop0): bucket 0:8 gen 0 has wrong data_type: got free, should be sb, fixing bcachefs (loop0): bucket 0:8 gen 0 data type sb has wrong dirty_sectors: got 0, should be 8, fixing bcachefs (loop0): bucket 0:16 gen 0 has wrong data_type: got free, should be sb, fixing bcachefs (loop0): bucket 0:16 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing bcachefs (loop0): bucket 0:17 gen 0 has wrong data_type: got free, should be sb, fixing Ratelimiting new instances of previous error bcachefs (loop0): bucket 0:17 gen 0 data type sb has wrong dirty_sectors: got 0, should be 256, fixing Ratelimiting new instances of previous error done bcachefs (loop0): going read-write bcachefs (loop0): journal_replay... done bcachefs (loop0): check_lrus... done bcachefs (loop0): check_backpointers_to_extents... done bcachefs (loop0): check_extents_to_backpointers... bcachefs (loop0): scanning for missing backpointers in 3/128 buckets done bcachefs (loop0): check_subvols... done bcachefs (loop0): check_inodes... done bcachefs (loop0): check_dirents... bcachefs (loop0): hash table key at wrong offset: should be at 5541010888983075472 u64s 7 type dirent 4096:189491840996961599:U32_MAX len 0 ver 0: file0 -> 4098 type dir, fixing bcachefs (loop0): hash table key at wrong offset: should be at 381495342740118712 u64s 7 type dirent 4096:1896155912177158345:U32_MAX len 0 ver 0: file3 -> 536870913 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 6163224976069816328 u64s 7 type dirent 4096:2695648408715017799:U32_MAX len 0 ver 0: file2 -> 536870913 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 7015942963738932794 u64s 7 type dirent 4096:4330382808765833931:U32_MAX len 0 ver 0: file1 -> 536870912 type reg, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:5541010888983075472:U32_MAX len 0 ver 0: file0 -> 4098 type dir, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:6163224976069816328:U32_MAX len 0 ver 0: file2 -> 536870913 type reg, fixing bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:7015942963738932794:U32_MAX len 0 ver 0: file1 -> 536870912 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 2324683688882438234 u64s 8 type dirent 4096:8130059955150870709:U32_MAX len 0 ver 0: lost+found -> 4097 type dir, fixing bcachefs (loop0): hash table key at wrong offset: should be at 7240767808199369985 u64s 8 type dirent 4096:9097378837824744618:U32_MAX len 0 ver 0: file.cold -> 536870914 type reg, fixing bcachefs (loop0): hash table key at wrong offset: should be at 4882803040921978557 u64s 7 type dirent 4098:5675548428000973578:U32_MAX len 0 ver 0: file1 -> 4100 type lnk, fixing bcachefs (loop0): hash table key at wrong offset: should be at 8120152370407090207 u64s 7 type dirent 4098:8977922886548783724:U32_MAX len 0 ver 0: file0 -> 4099 type reg, fixing bcachefs (loop0): check_dirents requires second pass bcachefs (loop0): dirent points to missing inode: u64s 7 type dirent 4096:381495342740118712:U32_MAX len 0 ver 0: file3 -> 536870913 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2300 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x1efd/0x3390 fs/bcachefs/fsck.c:2326 Read of size 1 at addr ffff8880557c00c0 by task syz.0.0/5319 CPU: 0 UID: 0 PID: 5319 Comm: syz.0.0 Not tainted 6.16.0-rc2-syzkaller-00318-g739a6c93cc75 #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_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 check_dirent fs/bcachefs/fsck.c:2300 [inline] bch2_check_dirents+0x1efd/0x3390 fs/bcachefs/fsck.c:2326 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3885 do_mount fs/namespace.c:4222 [inline] __do_sys_mount fs/namespace.c:4433 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4410 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fdd931900ca 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:00007fdd93f5ce68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fdd93f5cef0 RCX: 00007fdd931900ca RDX: 00002000000000c0 RSI: 0000200000000080 RDI: 00007fdd93f5ceb0 RBP: 00002000000000c0 R08: 00007fdd93f5cef0 R09: 0000000000818001 R10: 0000000000818001 R11: 0000000000000246 R12: 0000200000000080 R13: 00007fdd93f5ceb0 R14: 0000000000005978 R15: 0000200000000480 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x557c0 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 04fff00000000000 ffff88805ffd6f08 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 0x42800(GFP_NOWAIT|__GFP_COMP), pid 5319, tgid 5318 (syz.0.0), ts 69222566478, free_ts 69270820197 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704 prep_new_page mm/page_alloc.c:1712 [inline] get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3669 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959 __alloc_pages_noprof+0xa/0x30 mm/page_alloc.c:4993 __alloc_pages_node_noprof include/linux/gfp.h:284 [inline] alloc_pages_node_noprof include/linux/gfp.h:311 [inline] ___kmalloc_large_node+0x85/0x210 mm/slub.c:4272 __kmalloc_large_node_noprof+0x18/0x90 mm/slub.c:4300 __do_kmalloc_node mm/slub.c:4316 [inline] __kvmalloc_node_noprof+0x6d/0x5f0 mm/slub.c:5015 btree_bounce_alloc fs/bcachefs/btree_io.c:127 [inline] btree_node_sort+0x666/0x1760 fs/bcachefs/btree_io.c:326 bch2_btree_post_write_cleanup+0x11f/0xad0 fs/bcachefs/btree_io.c:2594 bch2_btree_node_prep_for_write+0x337/0x650 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x669/0xba0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:847 [inline] __bch2_trans_commit+0x2829/0x8880 fs/bcachefs/btree_trans_commit.c:1079 bch2_trans_commit fs/bcachefs/btree_update.h:242 [inline] bch2_str_hash_repair_key+0x2a2d/0x3fa0 fs/bcachefs/str_hash.c:293 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] check_dirent fs/bcachefs/fsck.c:2191 [inline] bch2_check_dirents+0x209b/0x3390 fs/bcachefs/fsck.c:2326 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 page last free pid 5319 tgid 5318 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1248 [inline] __free_pages_ok+0xa44/0xc20 mm/page_alloc.c:1424 __folio_put+0x21b/0x2c0 mm/swap.c:112 folio_put include/linux/mm.h:1356 [inline] free_large_kmalloc+0x145/0x200 mm/slub.c:4768 btree_bounce_free fs/bcachefs/btree_io.c:115 [inline] btree_node_sort+0x117f/0x1760 fs/bcachefs/btree_io.c:383 bch2_btree_post_write_cleanup+0x11f/0xad0 fs/bcachefs/btree_io.c:2594 bch2_btree_node_prep_for_write+0x337/0x650 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x669/0xba0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:847 [inline] __bch2_trans_commit+0x2829/0x8880 fs/bcachefs/btree_trans_commit.c:1079 bch2_trans_commit fs/bcachefs/btree_update.h:242 [inline] check_dirent fs/bcachefs/fsck.c:2295 [inline] bch2_check_dirents+0x1cdf/0x3390 fs/bcachefs/fsck.c:2326 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:485 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:540 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:611 bch2_fs_recovery+0x25fd/0x3950 fs/bcachefs/recovery.c:989 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1203 bch2_fs_get_tree+0xb02/0x14f0 fs/bcachefs/fs.c:2489 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3885 Memory state around the buggy address: ffff8880557bff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8880557c0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880557c0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880557c0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880557c0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================