bcachefs (loop2): hash table key at wrong offset: btree dirents inode 4096 offset 4330382808765833931, hashed to 8607060773457356477 u64s 7 type dirent 4096:4330382808765833931:U32_MAX len 0 ver 0:  -> 536870912 type unknown, fixing ================================================================== BUG: KASAN: slab-use-after-free in __bch2_str_hash_check_key+0xb22/0x3ac0 fs/bcachefs/str_hash.c:261 Read of size 8 at addr ffff888176e3e028 by task syz-executor/2959 CPU: 1 UID: 0 PID: 2959 Comm: syz-executor Not tainted 6.15.0-rc4-syzkaller #0 PREEMPT(undef) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: dump_stack_lvl+0xf4/0x170 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xb4/0x290 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 __bch2_str_hash_check_key+0xb22/0x3ac0 fs/bcachefs/str_hash.c:261 bch2_str_hash_check_key fs/bcachefs/str_hash.h:418 [inline] bch2_readdir+0xf10/0x15c0 fs/bcachefs/dirent.c:702 bch2_vfs_readdir+0x3d0/0x530 fs/bcachefs/fs.c:1581 iterate_dir+0x1a7/0x4c0 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:403 [inline] __se_sys_getdents64+0xd3/0x1a0 fs/readdir.c:389 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x8f/0x170 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f95105c1293 Code: c1 66 0f 1f 44 00 00 48 83 c4 08 48 89 ef 5b 5d e9 72 3e f8 ff 66 90 b8 ff ff ff 7f 48 39 c2 48 0f 47 d0 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 05 c3 0f 1f 40 00 48 c7 c2 a8 ff ff ff f7 d8 RSP: 002b:00007ffd1f893688 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9 RAX: ffffffffffffffda RBX: 000055556ad04600 RCX: 00007f95105c1293 RDX: 0000000000008000 RSI: 000055556ad04600 RDI: 0000000000000005 RBP: 000055556ad045d4 R08: 0000000000028a41 R09: 0000000000000000 R10: 00007f9510784ca0 R11: 0000000000000293 R12: ffffffffffffffa8 R13: 0000000000000010 R14: 000055556ad045d0 R15: 00007ffd1f895940 Allocated by task 2959: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4341 [inline] __kmalloc_node_track_caller_noprof+0x25f/0x4f0 mm/slub.c:4360 __do_krealloc mm/slub.c:4918 [inline] krealloc_noprof+0x122/0x300 mm/slub.c:4971 __bch2_trans_kmalloc+0x19d/0x980 fs/bcachefs/btree_iter.c:3187 bch2_trans_kmalloc_nomemzero_ip fs/bcachefs/btree_iter.h:586 [inline] bch2_trans_kmalloc_nomemzero fs/bcachefs/btree_iter.h:621 [inline] __bch2_bkey_make_mut_noupdate fs/bcachefs/btree_update.h:285 [inline] bch2_bkey_make_mut_noupdate fs/bcachefs/btree_update.h:300 [inline] __bch2_str_hash_check_key+0x1e7c/0x3ac0 fs/bcachefs/str_hash.c:292 bch2_str_hash_check_key fs/bcachefs/str_hash.h:418 [inline] bch2_readdir+0xf10/0x15c0 fs/bcachefs/dirent.c:702 bch2_vfs_readdir+0x3d0/0x530 fs/bcachefs/fs.c:1581 iterate_dir+0x1a7/0x4c0 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:403 [inline] __se_sys_getdents64+0xd3/0x1a0 fs/readdir.c:389 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x8f/0x170 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 2959: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x62/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2398 [inline] slab_free mm/slub.c:4656 [inline] kfree+0x179/0x3e0 mm/slub.c:4855 krealloc_noprof+0x1cb/0x300 mm/slub.c:-1 __bch2_trans_kmalloc+0x19d/0x980 fs/bcachefs/btree_iter.c:3187 bch2_trans_kmalloc_ip fs/bcachefs/btree_iter.h:604 [inline] bch2_trans_kmalloc fs/bcachefs/btree_iter.h:616 [inline] bch2_hash_delete_at fs/bcachefs/str_hash.h:363 [inline] __bch2_str_hash_check_key+0x3003/0x3ac0 fs/bcachefs/str_hash.c:310 bch2_str_hash_check_key fs/bcachefs/str_hash.h:418 [inline] bch2_readdir+0xf10/0x15c0 fs/bcachefs/dirent.c:702 bch2_vfs_readdir+0x3d0/0x530 fs/bcachefs/fs.c:1581 iterate_dir+0x1a7/0x4c0 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:403 [inline] __se_sys_getdents64+0xd3/0x1a0 fs/readdir.c:389 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x8f/0x170 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888176e3e000 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 40 bytes inside of freed 128-byte region [ffff888176e3e000, ffff888176e3e080) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x176e3e anon flags: 0x100000000000000(node=0|zone=2) page_type: f5(slab) raw: 0100000000000000 ffff888100041a00 ffffea0005db89c0 dead000000000003 raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 1442, tgid 1442 (udevd), ts 10470055918, free_ts 7418661746 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0xec/0x120 mm/page_alloc.c:1718 prep_new_page mm/page_alloc.c:1726 [inline] get_page_from_freelist+0x3bf8/0x3d50 mm/page_alloc.c:3688 __alloc_frozen_pages_noprof+0x26b/0x460 mm/page_alloc.c:4970 alloc_pages_mpol+0x150/0x320 mm/mempolicy.c:2301 alloc_slab_page mm/slub.c:2468 [inline] allocate_slab+0x8a/0x350 mm/slub.c:2632 new_slab mm/slub.c:2686 [inline] ___slab_alloc+0x9dc/0x10e0 mm/slub.c:3872 __slab_alloc mm/slub.c:3962 [inline] __slab_alloc_node mm/slub.c:4037 [inline] slab_alloc_node mm/slub.c:4198 [inline] __do_kmalloc_node mm/slub.c:4340 [inline] __kmalloc_noprof+0x2e8/0x500 mm/slub.c:4353 kmalloc_noprof include/linux/slab.h:909 [inline] kzalloc_noprof include/linux/slab.h:1039 [inline] tomoyo_encode2 security/tomoyo/realpath.c:45 [inline] tomoyo_encode+0xa5/0x460 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x51a/0x550 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x1a6/0x520 security/tomoyo/file.c:771 security_file_open+0x45/0xd0 security/security.c:3114 do_dentry_open+0x2fd/0x1060 fs/open.c:933 vfs_open+0x36/0x2b0 fs/open.c:1086 do_open fs/namei.c:3880 [inline] path_openat+0x23e3/0x2bb0 fs/namei.c:4039 do_filp_open+0x1e4/0x3c0 fs/namei.c:4066 do_sys_openat2+0xfa/0x180 fs/open.c:1429 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:1262 [inline] __free_frozen_pages+0x9f9/0xbe0 mm/page_alloc.c:2725 __free_pages mm/page_alloc.c:5080 [inline] free_contig_range+0x149/0x3b0 mm/page_alloc.c:6936 destroy_args+0x6d/0x360 mm/debug_vm_pgtable.c:1017 debug_vm_pgtable+0x2d0/0x460 mm/debug_vm_pgtable.c:1397 do_one_initcall+0x194/0x4d0 init/main.c:1257 do_initcall_level+0x117/0x1d0 init/main.c:1319 do_initcalls+0x59/0xa0 init/main.c:1335 kernel_init_freeable+0x306/0x460 init/main.c:1567 kernel_init+0x17/0x130 init/main.c:1457 ret_from_fork+0x32/0x70 arch/x86/kernel/process.c:153 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Memory state around the buggy address: ffff888176e3df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888176e3df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888176e3e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888176e3e080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888176e3e100: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================