================================================================== BUG: KASAN: slab-use-after-free in bch2_str_hash_repair_key+0x2d42/0x3fa0 fs/bcachefs/str_hash.c:335 Read of size 8 at addr ffff8880336bb828 by task syz-executor/6319 CPU: 0 UID: 0 PID: 6319 Comm: syz-executor Not tainted 6.16.0-rc1-syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 bch2_str_hash_repair_key+0x2d42/0x3fa0 fs/bcachefs/str_hash.c:335 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] bch2_readdir+0x11cd/0x16f0 fs/bcachefs/dirent.c:685 bch2_vfs_readdir+0x4d0/0x6c0 fs/bcachefs/fs.c:1581 iterate_dir+0x5af/0x770 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:410 [inline] __se_sys_getdents64+0xe4/0x260 fs/readdir.c:396 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f83a29c1293 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:00007ffd874dd278 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9 RAX: ffffffffffffffda RBX: 00005555871e6600 RCX: 00007f83a29c1293 RDX: 0000000000008000 RSI: 00005555871e6600 RDI: 0000000000000005 RBP: 00005555871e65d4 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000001000 R11: 0000000000000293 R12: ffffffffffffffa8 R13: 0000000000000010 R14: 00005555871e65d0 R15: 00007ffd874df530 Allocated by task 6319: 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:4328 [inline] __kmalloc_node_track_caller_noprof+0x271/0x4e0 mm/slub.c:4347 __do_krealloc mm/slub.c:4905 [inline] krealloc_noprof+0x124/0x340 mm/slub.c:4958 __bch2_trans_kmalloc+0x26c/0xc80 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_str_hash_repair_key+0x2a65/0x3fa0 fs/bcachefs/str_hash.c:251 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] bch2_readdir+0x11cd/0x16f0 fs/bcachefs/dirent.c:685 bch2_vfs_readdir+0x4d0/0x6c0 fs/bcachefs/fs.c:1581 iterate_dir+0x5af/0x770 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:410 [inline] __se_sys_getdents64+0xe4/0x260 fs/readdir.c:396 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 6319: 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:2381 [inline] slab_free mm/slub.c:4643 [inline] kfree+0x18e/0x440 mm/slub.c:4842 krealloc_noprof+0x1cd/0x340 mm/slub.c:-1 __bch2_trans_kmalloc+0x26c/0xc80 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_repair_key+0x2a96/0x3fa0 fs/bcachefs/str_hash.c:267 __bch2_str_hash_check_key+0xa65/0xd40 fs/bcachefs/str_hash.c:394 bch2_str_hash_check_key fs/bcachefs/str_hash.h:429 [inline] bch2_readdir+0x11cd/0x16f0 fs/bcachefs/dirent.c:685 bch2_vfs_readdir+0x4d0/0x6c0 fs/bcachefs/fs.c:1581 iterate_dir+0x5af/0x770 fs/readdir.c:108 __do_sys_getdents64 fs/readdir.c:410 [inline] __se_sys_getdents64+0xe4/0x260 fs/readdir.c:396 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff8880336bb800 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 40 bytes inside of freed 64-byte region [ffff8880336bb800, ffff8880336bb840) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x336bb ksm flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801a4418c0 ffffea00051ca200 dead000000000003 raw: 0000000000000000 0000000080200020 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 5172, tgid 5172 (rcS), ts 24204341873, free_ts 22845073981 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704 prep_new_page mm/page_alloc.c:1712 [inline] get_page_from_freelist+0x21d5/0x22b0 mm/page_alloc.c:3669 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2419 alloc_slab_page mm/slub.c:2451 [inline] allocate_slab+0x8a/0x3b0 mm/slub.c:2619 new_slab mm/slub.c:2673 [inline] ___slab_alloc+0xbfc/0x1480 mm/slub.c:3859 __slab_alloc mm/slub.c:3949 [inline] __slab_alloc_node mm/slub.c:4024 [inline] slab_alloc_node mm/slub.c:4185 [inline] __do_kmalloc_node mm/slub.c:4327 [inline] __kmalloc_noprof+0x305/0x4f0 mm/slub.c:4340 kmalloc_noprof include/linux/slab.h:909 [inline] tomoyo_add_entry security/tomoyo/common.c:2132 [inline] tomoyo_supervisor+0xbd5/0x1480 security/tomoyo/common.c:2204 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline] tomoyo_path_permission+0x25a/0x380 security/tomoyo/file.c:587 tomoyo_check_open_permission+0x24d/0x3b0 security/tomoyo/file.c:777 security_file_open+0xb1/0x270 security/security.c:3114 do_dentry_open+0x35e/0x1970 fs/open.c:941 vfs_open+0x3b/0x340 fs/open.c:1094 do_open fs/namei.c:3887 [inline] path_openat+0x2ee5/0x3830 fs/namei.c:4046 do_filp_open+0x1fa/0x410 fs/namei.c:4073 do_sys_openat2+0x121/0x1c0 fs/open.c:1437 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:1248 [inline] __free_frozen_pages+0xc65/0xe60 mm/page_alloc.c:2706 kasan_depopulate_vmalloc_pte+0x74/0xa0 mm/kasan/shadow.c:472 apply_to_pte_range mm/memory.c:3032 [inline] apply_to_pmd_range mm/memory.c:3076 [inline] apply_to_pud_range mm/memory.c:3112 [inline] apply_to_p4d_range mm/memory.c:3148 [inline] __apply_to_page_range+0xb8f/0x1380 mm/memory.c:3184 kasan_release_vmalloc+0xa2/0xd0 mm/kasan/shadow.c:593 kasan_release_vmalloc_node mm/vmalloc.c:2241 [inline] purge_vmap_node+0x214/0x8f0 mm/vmalloc.c:2258 __purge_vmap_area_lazy+0x7a4/0xb40 mm/vmalloc.c:2348 _vm_unmap_aliases+0x70f/0x7b0 mm/vmalloc.c:2943 change_page_attr_set_clr+0x305/0xeb0 arch/x86/mm/pat/set_memory.c:2085 change_page_attr_set arch/x86/mm/pat/set_memory.c:2126 [inline] set_memory_nx+0xd6/0x110 arch/x86/mm/pat/set_memory.c:2315 free_init_pages arch/x86/mm/init.c:933 [inline] free_kernel_image_pages+0x85/0x100 arch/x86/mm/init.c:952 kernel_init+0x31/0x1d0 init/main.c:1482 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Memory state around the buggy address: ffff8880336bb700: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc ffff8880336bb780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff8880336bb800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff8880336bb880: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc ffff8880336bb900: 00 00 00 00 00 00 00 01 fc fc fc fc fc fc fc fc ==================================================================