bcachefs (loop1): error validating btree node at btree subvolumes level 0/0 u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq c0bef60d07ceb940 written 960 min_key POS_MIN durability: 1 ptr: 0:35:0 gen 0 node offset 8/960 bset u64s 60677 bset byte offset 40: bad k->u64s 0 (min 3 max 253), fixing ================================================================== BUG: KASAN: slab-use-after-free in bkey_packed_valid+0x3a8/0x4b0 fs/bcachefs/btree_io.c:847 Read of size 1 at addr ffff88805df20000 by task kworker/1:1H/58 CPU: 1 UID: 0 PID: 58 Comm: kworker/1:1H Not tainted 6.13.0-rc7-syzkaller-00149-g9bffa1ad25b8 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Workqueue: bcachefs_btree_read_complete btree_node_read_work 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 bkey_packed_valid+0x3a8/0x4b0 fs/bcachefs/btree_io.c:847 validate_bset_keys+0x98d/0x1610 fs/bcachefs/btree_io.c:955 bch2_btree_node_read_done+0x2402/0x5e90 fs/bcachefs/btree_io.c:1130 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1323 process_one_work kernel/workqueue.c:3236 [inline] process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3317 worker_thread+0x870/0xd30 kernel/workqueue.c:3398 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Allocated by task 6559: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345 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_lru_noprof+0x1dd/0x390 mm/slub.c:4187 __d_alloc+0x31/0x700 fs/dcache.c:1646 d_alloc_pseudo+0x1f/0xb0 fs/dcache.c:1778 alloc_path_pseudo fs/file_table.c:356 [inline] alloc_file_pseudo+0x123/0x290 fs/file_table.c:372 sock_alloc_file+0xb8/0x280 net/socket.c:468 sock_map_fd net/socket.c:493 [inline] __sys_socket+0x1dd/0x3c0 net/socket.c:1709 __do_sys_socket net/socket.c:1714 [inline] __se_sys_socket net/socket.c:1712 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1712 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 Freed by task 6559: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:582 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2353 [inline] slab_free mm/slub.c:4613 [inline] kmem_cache_free+0x195/0x410 mm/slub.c:4715 __dentry_kill+0x497/0x630 fs/dcache.c:644 dput+0x19f/0x2b0 fs/dcache.c:867 __fput+0x5ba/0xa50 fs/file_table.c:458 __do_sys_close fs/open.c:1554 [inline] __se_sys_close fs/open.c:1539 [inline] __x64_sys_close+0x7f/0x110 fs/open.c:1539 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 The buggy address belongs to the object at ffff88805df20000 which belongs to the cache dentry of size 312 The buggy address is located 0 bytes inside of freed 312-byte region [ffff88805df20000, ffff88805df20138) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5df20 head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff88807ca76501 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801baffa00 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000150015 00000001f5000000 ffff88807ca76501 head: 00fff00000000040 ffff88801baffa00 dead000000000122 0000000000000000 head: 0000000000000000 0000000000150015 00000001f5000000 ffff88807ca76501 head: 00fff00000000001 ffffea000177c801 ffffffffffffffff 0000000000000000 head: 0000000000000002 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 6559, tgid 6559 (syz-executor), ts 113180583605, free_ts 15398982387 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+0x3651/0x37a0 mm/page_alloc.c:3476 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4753 alloc_pages_mpol_noprof+0x3e1/0x780 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] kmem_cache_alloc_lru_noprof+0x26c/0x390 mm/slub.c:4187 __d_alloc+0x31/0x700 fs/dcache.c:1646 d_alloc_pseudo+0x1f/0xb0 fs/dcache.c:1778 alloc_path_pseudo fs/file_table.c:356 [inline] alloc_file_pseudo+0x123/0x290 fs/file_table.c:372 sock_alloc_file+0xb8/0x280 net/socket.c:468 sock_map_fd net/socket.c:493 [inline] __sys_socket+0x1dd/0x3c0 net/socket.c:1709 __do_sys_socket net/socket.c:1714 [inline] __se_sys_socket net/socket.c:1712 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1712 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 page last free pid 1 tgid 1 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0xd2c/0x1000 mm/page_alloc.c:2659 free_contig_range+0x14c/0x430 mm/page_alloc.c:6632 destroy_args+0x92/0x910 mm/debug_vm_pgtable.c:1017 debug_vm_pgtable+0x4be/0x550 mm/debug_vm_pgtable.c:1397 do_one_initcall+0x248/0x870 init/main.c:1266 do_initcall_level+0x157/0x210 init/main.c:1328 do_initcalls+0x3f/0x80 init/main.c:1344 kernel_init_freeable+0x435/0x5d0 init/main.c:1577 kernel_init+0x1d/0x2b0 init/main.c:1466 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Memory state around the buggy address: ffff88805df1ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88805df1ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88805df20000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88805df20080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805df20100: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fa ==================================================================