u64s 7 type dirent 4096:189491840996961599:U32_MAX len 0 ver 0: file0 -> 4098 type dir, fixing ================================================================== 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 ffff88807807d728 by task syz.3.29/6088 CPU: 1 UID: 0 PID: 6088 Comm: syz.3.29 Not tainted 6.16.0-rc1-syzkaller-00157-g02adc1490e6d #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_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 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:0x7fb34338e929 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fb34428f038 EFLAGS: 00000246 ORIG_RAX: 000000000000004e RAX: ffffffffffffffda RBX: 00007fb3435b5fa0 RCX: 00007fb34338e929 RDX: 00000000000000b8 RSI: 0000200000001fc0 RDI: 0000000000000004 RBP: 00007fb343410b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb3435b5fa0 R15: 00007ffcf1ee5f58 Allocated by task 6088: 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_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 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 6088: 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_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:364 [inline] bch2_str_hash_repair_key+0x2fde/0x3fa0 fs/bcachefs/str_hash.c:289 __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_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 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 ffff88807807d700 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 40 bytes inside of freed 128-byte region [ffff88807807d700, ffff88807807d780) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7807d ksm flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801a441a00 ffffea0000a80500 0000000000000007 raw: 0000000000000000 0000000080100010 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 0x252800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 5826, tgid 5826 (syz-executor), ts 98649213531, free_ts 98649159291 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_slab_page mm/slub.c:2453 [inline] allocate_slab+0x65/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_node_noprof+0x2fd/0x4e0 mm/slub.c:4334 kmalloc_array_node_noprof include/linux/slab.h:1020 [inline] alloc_slab_obj_exts+0x39/0xa0 mm/slub.c:1992 __memcg_slab_post_alloc_hook+0x31e/0x7f0 mm/memcontrol.c:3177 memcg_slab_post_alloc_hook mm/slub.c:2180 [inline] slab_post_alloc_hook mm/slub.c:4158 [inline] slab_alloc_node mm/slub.c:4197 [inline] __do_kmalloc_node mm/slub.c:4327 [inline] __kvmalloc_node_noprof+0x466/0x5f0 mm/slub.c:5015 xt_alloc_table_info+0x3b/0xa0 net/netfilter/x_tables.c:1193 do_replace net/ipv4/netfilter/ip_tables.c:1126 [inline] do_ipt_set_ctl+0x881/0xcd0 net/ipv4/netfilter/ip_tables.c:1635 nf_setsockopt+0x26f/0x290 net/netfilter/nf_sockopt.c:101 do_sock_setsockopt+0x257/0x3e0 net/socket.c:2296 __sys_setsockopt net/socket.c:2321 [inline] __do_sys_setsockopt net/socket.c:2327 [inline] __se_sys_setsockopt net/socket.c:2324 [inline] __x64_sys_setsockopt+0x18b/0x220 net/socket.c:2324 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 page last free pid 5826 tgid 5826 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 vfree+0x25a/0x400 mm/vmalloc.c:3426 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:866 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline] do_ipt_get_ctl+0xebc/0x1180 net/ipv4/netfilter/ip_tables.c:1668 nf_getsockopt+0x26b/0x290 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x1c4/0x220 net/ipv4/ip_sockglue.c:1777 do_sock_getsockopt+0x35d/0x650 net/socket.c:2357 __sys_getsockopt net/socket.c:2386 [inline] __do_sys_getsockopt net/socket.c:2393 [inline] __se_sys_getsockopt net/socket.c:2390 [inline] __x64_sys_getsockopt+0x1a5/0x250 net/socket.c:2390 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 Memory state around the buggy address: ffff88807807d600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88807807d680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807807d700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807807d780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807807d800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================