================================================================== BUG: KASAN: use-after-free in check_dirent fs/bcachefs/fsck.c:2205 [inline] BUG: KASAN: use-after-free in bch2_check_dirents+0x2acb/0x3ba0 fs/bcachefs/fsck.c:2230 Read of size 1 at addr ffff8880537e0140 by task syz.1.69/6332 CPU: 1 UID: 0 PID: 6332 Comm: syz.1.69 Not tainted 6.14.0-syzkaller-12886-ga1b5bd45d4ee #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 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+0x2acb/0x3ba0 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+0x292a/0x3e20 fs/bcachefs/recovery.c:936 bch2_fs_start+0x2fb/0x610 fs/bcachefs/super.c:1060 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:3878 do_mount fs/namespace.c:4218 [inline] __do_sys_mount fs/namespace.c:4429 [inline] __se_sys_mount+0x38c/0x400 fs/namespace.c:4406 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:0x7f4d3738e90a 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:00007f4d3829de68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f4d3829def0 RCX: 00007f4d3738e90a RDX: 000020000000f640 RSI: 00002000000001c0 RDI: 00007f4d3829deb0 RBP: 000020000000f640 R08: 00007f4d3829def0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00002000000001c0 R13: 00007f4d3829deb0 R14: 000000000000f61c R15: 0000200000000080 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x537e0 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 00fff00000000000 ffffea00013fc808 ffff88813fffc688 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 6332, tgid 6331 (syz.1.69), ts 117066583422, free_ts 130391234567 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+0x351d/0x36b0 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] bch2_btree_node_read_done+0x393c/0x62c0 fs/bcachefs/btree_io.c:1224 btree_node_read_work+0x6cb/0x1400 fs/bcachefs/btree_io.c:1366 bch2_btree_node_read+0x2427/0x29e0 fs/bcachefs/btree_io.c:-1 __bch2_btree_root_read fs/bcachefs/btree_io.c:1796 [inline] bch2_btree_root_read+0x656/0x7e0 fs/bcachefs/btree_io.c:1818 read_btree_roots+0x3d7/0xa80 fs/bcachefs/recovery.c:581 bch2_fs_recovery+0x28e4/0x3e20 fs/bcachefs/recovery.c:928 bch2_fs_start+0x2fb/0x610 fs/bcachefs/super.c:1060 bch2_fs_get_tree+0x113e/0x18f0 fs/bcachefs/fs.c:2253 vfs_get_tree+0x90/0x2b0 fs/super.c:1759 page last free pid 6332 tgid 6331 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1262 [inline] __free_pages_ok+0xb17/0xd90 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:2501 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+0x2820/0x3ba0 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+0x292a/0x3e20 fs/bcachefs/recovery.c:936 bch2_fs_start+0x2fb/0x610 fs/bcachefs/super.c:1060 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: ffff8880537e0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880537e0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880537e0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880537e0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880537e0200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================