loop0: detected capacity change from 0 to 32768 bcachefs (loop0): starting version 1.7: mi_btree_bitmap opts=metadata_checksum=crc64,compression=lz4,str_hash=crc32c,fix_errors=yes,norecovery,nojournal_transaction_names invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq c6c25c03258c59c5 written 16 min_key POS_MIN durability: 1 ptr: 0:27:0 gen 0 pointer before first bucket (27 < 1024): delete?, fixing invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 7589ab5e0c11cc7a written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0 pointer before first bucket (38 < 1024): delete?, fixing invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 9aa2895aefce4bdf written 24 min_key POS_MIN durability: 1 ptr: 0:41:0 gen 0 pointer before first bucket (41 < 1024): delete?, fixing invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 2285c34bed0abe32 written 16 min_key POS_MIN durability: 1 ptr: 0:31:0 gen 0 pointer before first bucket (31 < 1024): delete?, fixing invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq ac62141f8dc7e261 written 24 min_key POS_MIN durability: 1 ptr: 0:26:0 gen 0 pointer before first bucket (26 < 1024): delete?, fixing invalid bkey u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq c0bef60d07ceb940 written 16 min_key POS_MIN durability: 1 ptr: 0:35:0 gen 0 pointer before first bucket (35 < 1024): delete?, fixing ================================================================== BUG: KASAN: use-after-free in bucket_gen_get_rcu fs/bcachefs/buckets.h:109 [inline] BUG: KASAN: use-after-free in dev_ptr_stale_rcu+0x316/0x320 fs/bcachefs/buckets.h:178 Read of size 1 at addr ffff888000c67848 by task syz.0.0/5313 CPU: 0 UID: 0 PID: 5313 Comm: syz.0.0 Not tainted 6.13.0-rc6-syzkaller-00262-gb62cef9a5c67 #0 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 lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x169/0x550 mm/kasan/report.c:489 kasan_report+0x143/0x180 mm/kasan/report.c:602 bucket_gen_get_rcu fs/bcachefs/buckets.h:109 [inline] dev_ptr_stale_rcu+0x316/0x320 fs/bcachefs/buckets.h:178 bch2_extent_ptr_to_text+0x4d6/0x640 fs/bcachefs/extents.c:1101 bch2_bkey_ptrs_to_text+0xf77/0x1510 fs/bcachefs/extents.c:1139 bch2_btree_ptr_v2_to_text+0x209/0x2f0 fs/bcachefs/extents.c:228 __bch2_bkey_fsck_err+0x1c8/0x280 fs/bcachefs/error.c:457 bch2_bkey_ptrs_validate+0x1462/0x1a60 journal_validate_key+0x59e/0xbf0 fs/bcachefs/journal_io.c:370 journal_entry_btree_root_validate+0x160/0x480 fs/bcachefs/journal_io.c:455 bch2_sb_clean_validate_late fs/bcachefs/sb-clean.c:40 [inline] bch2_read_superblock_clean+0x207/0x520 fs/bcachefs/sb-clean.c:168 bch2_fs_recovery+0x1f4/0x39d0 fs/bcachefs/recovery.c:639 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1037 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170 vfs_get_tree+0x90/0x2b0 fs/super.c:1814 do_new_mount+0x2be/0xb40 fs/namespace.c:3511 do_mount fs/namespace.c:3851 [inline] __do_sys_mount fs/namespace.c:4061 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4038 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f6496f874ca 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:00007f6497d41e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f6497d41ef0 RCX: 00007f6496f874ca RDX: 00000000200058c0 RSI: 0000000020000000 RDI: 00007f6497d41eb0 RBP: 00000000200058c0 R08: 00007f6497d41ef0 R09: 0000000000008000 R10: 0000000000008000 R11: 0000000000000246 R12: 0000000020000000 R13: 00007f6497d41eb0 R14: 0000000000005979 R15: 0000000020000240 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xc67 flags: 0x7ff00000000000(node=0|zone=0|lastcpupid=0x7ff) raw: 007ff00000000000 0000000000000000 ffffea00000319c8 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 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4727, tgid 4727 (udevd), ts 22642282780, free_ts 22804597061 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1558 prep_new_page mm/page_alloc.c:1566 [inline] get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3476 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4753 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2269 alloc_slab_page+0x6a/0x110 mm/slub.c:2423 allocate_slab+0x5a/0x2b0 mm/slub.c:2589 new_slab mm/slub.c:2642 [inline] ___slab_alloc+0xc27/0x14a0 mm/slub.c:3830 __slab_alloc+0x58/0xa0 mm/slub.c:3920 __slab_alloc_node mm/slub.c:3995 [inline] slab_alloc_node mm/slub.c:4156 [inline] __do_kmalloc_node mm/slub.c:4297 [inline] __kmalloc_noprof+0x2e6/0x4c0 mm/slub.c:4310 kmalloc_noprof include/linux/slab.h:905 [inline] tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x258/0x4f0 security/tomoyo/file.c:771 security_file_open+0xac/0x250 security/security.c:3105 do_dentry_open+0x328/0x1b70 fs/open.c:928 vfs_open+0x3e/0x330 fs/open.c:1075 do_open fs/namei.c:3828 [inline] path_openat+0x2c84/0x3590 fs/namei.c:3987 do_filp_open+0x27f/0x4e0 fs/namei.c:4014 page last free pid 4734 tgid 4734 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0xd3f/0x1010 mm/page_alloc.c:2659 discard_slab mm/slub.c:2688 [inline] __put_partials+0x160/0x1c0 mm/slub.c:3157 put_cpu_partial+0x17c/0x250 mm/slub.c:3232 __slab_free+0x290/0x380 mm/slub.c:4483 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4119 [inline] slab_alloc_node mm/slub.c:4168 [inline] kmem_cache_alloc_noprof+0x1d9/0x380 mm/slub.c:4175 getname_flags+0xb7/0x540 fs/namei.c:139 do_sys_openat2+0xd2/0x1d0 fs/open.c:1396 do_sys_open fs/open.c:1417 [inline] __do_sys_openat fs/open.c:1433 [inline] __se_sys_openat fs/open.c:1428 [inline] __x64_sys_openat+0x247/0x2a0 fs/open.c:1428 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888000c67700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888000c67780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888000c67800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888000c67880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888000c67900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================