u64s 8 type dirent 4096:9097378837824744618:U32_MAX len 0 ver 0: file.cold -> 172335562754 type reg, fixing ================================================================== BUG: KASAN: use-after-free in check_dirent+0x330b/0x3620 fs/bcachefs/fsck.c:2396 Read of size 1 at addr ffff8880b2440140 by task syz.4.3449/25758 CPU: 0 UID: 0 PID: 25758 Comm: syz.4.3449 Not tainted 6.17.0-rc1-syzkaller-00211-g90d970cade8e #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/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:378 [inline] print_report+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 check_dirent+0x330b/0x3620 fs/bcachefs/fsck.c:2396 bch2_check_dirents+0x429/0x950 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x2d5/0x10d0 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x2d1/0x480 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2f55/0x48a0 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xf82/0x1450 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xd9b/0x1b70 fs/bcachefs/fs.c:2488 vfs_get_tree+0x8e/0x340 fs/super.c:1815 do_new_mount fs/namespace.c:3805 [inline] path_mount+0x1482/0x1fd0 fs/namespace.c:4120 do_mount fs/namespace.c:4133 [inline] __do_sys_mount fs/namespace.c:4344 [inline] __se_sys_mount fs/namespace.c:4321 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4321 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fcc0559038a 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:00007fcc06460e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fcc06460ef0 RCX: 00007fcc0559038a RDX: 0000200000000080 RSI: 0000200000000000 RDI: 00007fcc06460eb0 RBP: 0000200000000080 R08: 00007fcc06460ef0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000200000000000 R13: 00007fcc06460eb0 R14: 000000000000599f R15: 00002000000000c0 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xb2440 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 00fff00000000000 ffffea0000deb808 ffff88813fffbf08 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 25758, tgid 25757 (syz.4.3449), ts 1148941426169, free_ts 1149077651015 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1851 prep_new_page mm/page_alloc.c:1859 [inline] get_page_from_freelist+0x132b/0x38e0 mm/page_alloc.c:3858 __alloc_frozen_pages_noprof+0x261/0x23f0 mm/page_alloc.c:5148 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416 ___kmalloc_large_node+0xed/0x160 mm/slub.c:4306 __kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:4337 __do_kmalloc_node mm/slub.c:4353 [inline] __kvmalloc_node_noprof.cold+0xb/0x65 mm/slub.c:5052 btree_bounce_alloc+0x115/0x200 fs/bcachefs/btree_io.c:127 btree_node_sort+0x1156/0x1560 fs/bcachefs/btree_io.c:326 bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2607 [inline] bch2_btree_post_write_cleanup+0x14b/0x860 fs/bcachefs/btree_io.c:2581 bch2_btree_node_prep_for_write+0x354/0x550 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x695/0x8c0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:850 [inline] __bch2_trans_commit+0x280d/0x8560 fs/bcachefs/btree_trans_commit.c:1085 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] bch2_str_hash_repair_key+0x2054/0x3fe0 fs/bcachefs/str_hash.c:294 __bch2_str_hash_check_key+0x77a/0x9e0 fs/bcachefs/str_hash.c:395 bch2_str_hash_check_key fs/bcachefs/str_hash.h:427 [inline] check_dirent+0x1593/0x3620 fs/bcachefs/fsck.c:2287 page last free pid 25758 tgid 25757 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1395 [inline] __free_pages_ok+0x720/0xfc0 mm/page_alloc.c:1571 btree_bounce_free fs/bcachefs/btree_io.c:115 [inline] btree_node_sort+0x101c/0x1560 fs/bcachefs/btree_io.c:383 bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2607 [inline] bch2_btree_post_write_cleanup+0x14b/0x860 fs/bcachefs/btree_io.c:2581 bch2_btree_node_prep_for_write+0x354/0x550 fs/bcachefs/btree_trans_commit.c:95 bch2_trans_lock_write+0x695/0x8c0 fs/bcachefs/btree_trans_commit.c:131 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:850 [inline] __bch2_trans_commit+0x280d/0x8560 fs/bcachefs/btree_trans_commit.c:1085 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] check_dirent+0x16c0/0x3620 fs/bcachefs/fsck.c:2391 bch2_check_dirents+0x429/0x950 fs/bcachefs/fsck.c:2422 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x2d5/0x10d0 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x2d1/0x480 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2f55/0x48a0 fs/bcachefs/recovery.c:1016 bch2_fs_start+0xf82/0x1450 fs/bcachefs/super.c:1213 bch2_fs_get_tree+0xd9b/0x1b70 fs/bcachefs/fs.c:2488 vfs_get_tree+0x8e/0x340 fs/super.c:1815 do_new_mount fs/namespace.c:3805 [inline] path_mount+0x1482/0x1fd0 fs/namespace.c:4120 do_mount fs/namespace.c:4133 [inline] __do_sys_mount fs/namespace.c:4344 [inline] __se_sys_mount fs/namespace.c:4321 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4321 Memory state around the buggy address: ffff8880b2440000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880b2440080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880b2440100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880b2440180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880b2440200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== bcachefs (loop4): fsck counted subdirectories wrong for inum 4096:4294967295: got 1 should be 2 bcachefs (loop4): check_dirents requires second pass done bcachefs (loop4): resume_logged_ops... done bcachefs (loop4): delete_dead_inodes... done bcachefs (loop4): Fixed errors, running fsck a second time to verify fs is clean bcachefs (loop4): check_extents_to_backpointers... done bcachefs (loop4): check_subvols... done bcachefs (loop4): check_inodes... done bcachefs (loop4): check_dirents... done bcachefs (loop4): resume_logged_ops... done bcachefs (loop4): delete_dead_inodes... done bcachefs (loop4): done starting filesystem bcachefs (loop4): shutting down bcachefs (loop4): going read-only bcachefs (loop4): finished waiting for writes to stop bcachefs (loop4): flushing journal and stopping allocators, journal seq 20 bcachefs (loop4): flushing journal and stopping allocators complete, journal seq 20 bcachefs (loop4): clean shutdown complete, journal seq 21 bcachefs (loop4): marking filesystem clean bcachefs (loop4): shutdown complete