u64s 7 type dirent 4096:4330382808765833931:U32_MAX len 0 ver 0: file1 -> 536870912 type reg, fixing bcachefs (loop2): dirent points to missing inode: u64s 7 type dirent 4096:4594721809437749936:U32_MAX len 0 ver 0: file3 -> 536870913 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2418 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x1fac/0x33f0 fs/bcachefs/fsck.c:2444 Read of size 1 at addr ffff888046260110 by task syz.2.2871/18361 CPU: 0 UID: 0 PID: 18361 Comm: syz.2.2871 Not tainted 6.16.0-rc4-syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 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:2418 [inline] bch2_check_dirents+0x1fac/0x33f0 fs/bcachefs/fsck.c:2444 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x395/0x1010 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2690/0x3a50 fs/bcachefs/recovery.c:1005 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1212 bch2_fs_get_tree+0xafc/0x14f0 fs/bcachefs/fs.c:2490 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 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:0x7fa71f3900ca 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:00007fa720134e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fa720134ef0 RCX: 00007fa71f3900ca RDX: 00002000000000c0 RSI: 0000200000000080 RDI: 00007fa720134eb0 RBP: 00002000000000c0 R08: 00007fa720134ef0 R09: 0000000000818001 R10: 0000000000818001 R11: 0000000000000246 R12: 0000200000000080 R13: 00007fa720134eb0 R14: 0000000000005978 R15: 0000200000000480 The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x46260 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x100cc0(GFP_USER), pid 18391, tgid 18391 (syz-executor), ts 977746688488, free_ts 977710669705 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 mm/page_alloc.c:4993 [inline] alloc_pages_bulk_noprof+0x560/0x710 mm/page_alloc.c:4913 ___alloc_pages_bulk mm/kasan/shadow.c:344 [inline] __kasan_populate_vmalloc mm/kasan/shadow.c:368 [inline] kasan_populate_vmalloc+0xba/0x1a0 mm/kasan/shadow.c:417 alloc_vmap_area+0xd51/0x1490 mm/vmalloc.c:2084 __get_vm_area_node+0x1f8/0x300 mm/vmalloc.c:3179 __vmalloc_node_range_noprof+0x301/0x12f0 mm/vmalloc.c:3845 vmalloc_user_noprof+0xad/0xf0 mm/vmalloc.c:4038 kcov_ioctl+0x55/0x640 kernel/kcov.c:716 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 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 page last free pid 18361 tgid 18360 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:2582 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:850 [inline] __bch2_trans_commit+0x2773/0x8870 fs/bcachefs/btree_trans_commit.c:1085 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] check_dirent fs/bcachefs/fsck.c:2413 [inline] bch2_check_dirents+0x1c5c/0x33f0 fs/bcachefs/fsck.c:2444 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x395/0x1010 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2690/0x3a50 fs/bcachefs/recovery.c:1005 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1212 bch2_fs_get_tree+0xafc/0x14f0 fs/bcachefs/fs.c:2490 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 Memory state around the buggy address: ffff888046260000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888046260080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888046260100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ ffff888046260180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888046260200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================