bcachefs (loop4): check_extents... done
bcachefs (loop4): check_dirents...
dirent points to missing inode:
u64s 8 type dirent 4096:6728544935518790663:U32_MAX len 0 ver 0: lost+found -> 4097 type dir, fixing
==================================================================
BUG: KASAN: use-after-free in check_dirent+0x2455/0x2620 fs/bcachefs/fsck.c:2443
Read of size 1 at addr ffff888066404048 by task syz-executor384/5844
CPU: 1 UID: 0 PID: 5844 Comm: syz-executor384 Not tainted 6.14.0-rc3-syzkaller-00137-g27eddbf34490 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
<TASK>
__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:408 [inline]
print_report+0xc3/0x670 mm/kasan/report.c:521
kasan_report+0xd9/0x110 mm/kasan/report.c:634
check_dirent+0x2455/0x2620 fs/bcachefs/fsck.c:2443
bch2_check_dirents+0x409/0x780 fs/bcachefs/fsck.c:2468
bch2_run_recovery_pass+0x91/0x1a0 fs/bcachefs/recovery_passes.c:226
bch2_run_recovery_passes+0x3f4/0x8f0 fs/bcachefs/recovery_passes.c:291
bch2_fs_recovery+0x3c1b/0x43d0 fs/bcachefs/recovery.c:973
bch2_fs_start+0x343/0x660 fs/bcachefs/super.c:1041
bch2_fs_get_tree+0x1118/0x1760 fs/bcachefs/fs.c:2203
vfs_get_tree+0x8e/0x340 fs/super.c:1814
do_new_mount fs/namespace.c:3560 [inline]
path_mount+0x14e6/0x1f10 fs/namespace.c:3887
do_mount fs/namespace.c:3900 [inline]
__do_sys_mount fs/namespace.c:4111 [inline]
__se_sys_mount fs/namespace.c:4088 [inline]
__x64_sys_mount+0x28f/0x310 fs/namespace.c:4088
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f54eae1a3ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 5e 04 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffda345d9a8 EFLAGS: 00000282 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffda345d9c0 RCX: 00007f54eae1a3ea
RDX: 0000400000000000 RSI: 0000400000000040 RDI: 00007ffda345d9c0
RBP: 0000400000000000 R08: 00007ffda345da00 R09: 0000000000005956
R10: 0000000001000001 R11: 0000000000000282 R12: 0000400000000040
R13: 0000000000000004 R14: 0000000000000003 R15: 00007ffda345da00
</TASK>
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x66404
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 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 5844, tgid 5844 (syz-executor384), ts 93104285109, free_ts 93483581928
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551
prep_new_page mm/page_alloc.c:1559 [inline]
get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3477
__alloc_frozen_pages_noprof+0x221/0x2470 mm/page_alloc.c:4739
__alloc_pages_noprof+0xb/0x1b0 mm/page_alloc.c:4773
__alloc_pages_node_noprof include/linux/gfp.h:265 [inline]
alloc_pages_node_noprof include/linux/gfp.h:292 [inline]
___kmalloc_large_node+0x84/0x1b0 mm/slub.c:4239
__kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:4266
__do_kmalloc_node mm/slub.c:4282 [inline]
__kmalloc_node_noprof.cold+0x5/0x5f mm/slub.c:4300
__kvmalloc_node_noprof+0x6f/0x1a0 mm/util.c:662
btree_bounce_alloc+0x11e/0x210 fs/bcachefs/btree_io.c:123
btree_node_sort+0x1104/0x14f0 fs/bcachefs/btree_io.c:322
bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2293 [inline]
bch2_btree_post_write_cleanup+0x145/0x600 fs/bcachefs/btree_io.c:2267
bch2_btree_node_prep_for_write+0x35b/0x550 fs/bcachefs/btree_trans_commit.c:93
bch2_trans_lock_write+0x6c5/0x8e0 fs/bcachefs/btree_trans_commit.c:129
do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:862 [inline]
__bch2_trans_commit+0x2264/0x7d70 fs/bcachefs/btree_trans_commit.c:1070
bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline]
__bch2_str_hash_check_key+0x2097/0x3800 fs/bcachefs/str_hash.c:292
bch2_str_hash_check_key fs/bcachefs/str_hash.h:415 [inline]
check_dirent+0x12d3/0x2620 fs/bcachefs/fsck.c:2373
page last free pid 5844 tgid 5844 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1127 [inline]
__free_pages_ok+0x62b/0xe50 mm/page_alloc.c:1271
__folio_put+0x32a/0x450 mm/swap.c:112
kvfree+0x47/0x50 mm/util.c:705
btree_bounce_free fs/bcachefs/btree_io.c:111 [inline]
btree_node_sort+0xf9f/0x14f0 fs/bcachefs/btree_io.c:379
bch2_btree_post_write_cleanup fs/bcachefs/btree_io.c:2293 [inline]
bch2_btree_post_write_cleanup+0x145/0x600 fs/bcachefs/btree_io.c:2267
bch2_btree_node_prep_for_write+0x35b/0x550 fs/bcachefs/btree_trans_commit.c:93
bch2_trans_lock_write+0x6c5/0x8e0 fs/bcachefs/btree_trans_commit.c:129
do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:862 [inline]
__bch2_trans_commit+0x2264/0x7d70 fs/bcachefs/btree_trans_commit.c:1070
bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline]
check_dirent+0xff1/0x2620 fs/bcachefs/fsck.c:2438
bch2_check_dirents+0x409/0x780 fs/bcachefs/fsck.c:2468
bch2_run_recovery_pass+0x91/0x1a0 fs/bcachefs/recovery_passes.c:226
bch2_run_recovery_passes+0x3f4/0x8f0 fs/bcachefs/recovery_passes.c:291
bch2_fs_recovery+0x3c1b/0x43d0 fs/bcachefs/recovery.c:973
bch2_fs_start+0x343/0x660 fs/bcachefs/super.c:1041
bch2_fs_get_tree+0x1118/0x1760 fs/bcachefs/fs.c:2203
vfs_get_tree+0x8e/0x340 fs/super.c:1814
Memory state around the buggy address:
ffff888066403f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888066403f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888066404000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888066404080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888066404100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
directory 4096:4294967295 with wrong i_size: got 288, should be 352, fixing
done
bcachefs (loop4): resume_logged_ops... done
bcachefs (loop4): delete_dead_inodes... done
bcachefs (loop4): Second fsck run was not clean
bcachefs (loop4): going read-only
bcachefs (loop4): finished waiting for writes to stop
bcachefs (loop4): flushing journal and stopping allocators, journal seq 23
bcachefs (loop4): flushing journal and stopping allocators complete, journal seq 24
bcachefs (loop4): clean shutdown complete, journal seq 25
bcachefs (loop4): marking filesystem clean
bcachefs (loop4): done starting filesystem
syz-executor384 (5844) used greatest stack depth: 15712 bytes left