In the Linux kernel, the following vulnerability has been resolved:
ila: serialize calls to nf_register_net_hooks()
syzbot found a race in ila_add_mapping() [1]
commit 031ae72825ce ("ila: call nf_unregister_net_hooks() sooner")
attempted to fix a similar issue.
Looking at the syzbot repro, we have concurrent ILA_CMD_ADD commands.
Add a mutex to make sure at most one thread is calling nf_register_net_hooks().
[1]
BUG: KASAN: slab-use-after-free in rht_key_hashfn include/linux/rhashtable.h:159[inline]BUG: KASAN: slab-use-after-free in __rhashtable_lookup.constprop.0+0x426/0x550include/linux/rhashtable.h:604Read of size 4 at addr ffff888028f40008 by task dhcpcd/5501
CPU: 1 UID: 0 PID: 5501 Comm: dhcpcd Not tainted 6.13.0-rc4-syzkaller-00054-gd6ef8b40d075 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:<IRQ>__dump_stacklib/dump_stack.c:94[inline]dump_stack_lvl+0x116/0x1f0lib/dump_stack.c:120print_address_descriptionmm/kasan/report.c:378[inline]print_report+0xc3/0x620mm/kasan/report.c:489kasan_report+0xd9/0x110mm/kasan/report.c:602rht_key_hashfninclude/linux/rhashtable.h:159[inline]__rhashtable_lookup.constprop.0+0x426/0x550include/linux/rhashtable.h:604rhashtable_lookupinclude/linux/rhashtable.h:646[inline]rhashtable_lookup_fastinclude/linux/rhashtable.h:672[inline]ila_lookup_wildcardsnet/ipv6/ila/ila_xlat.c:127[inline]ila_xlat_addrnet/ipv6/ila/ila_xlat.c:652[inline]ila_nf_input+0x1ee/0x620net/ipv6/ila/ila_xlat.c:185nf_hook_entry_hookfninclude/linux/netfilter.h:154[inline]nf_hook_slow+0xbb/0x200net/netfilter/core.c:626nf_hook.constprop.0+0x42e/0x750include/linux/netfilter.h:269NF_HOOKinclude/linux/netfilter.h:312[inline]ipv6_rcv+0xa4/0x680net/ipv6/ip6_input.c:309__netif_receive_skb_one_core+0x12e/0x1e0net/core/dev.c:5672__netif_receive_skb+0x1d/0x160net/core/dev.c:5785process_backlog+0x443/0x15f0net/core/dev.c:6117__napi_poll.constprop.0+0xb7/0x550net/core/dev.c:6883napi_pollnet/core/dev.c:6952[inline]net_rx_action+0xa94/0x1010net/core/dev.c:7074handle_softirqs+0x213/0x8f0kernel/softirq.c:561__do_softirqkernel/softirq.c:595[inline]invoke_softirqkernel/softirq.c:435[inline]__irq_exit_rcu+0x109/0x170kernel/softirq.c:662irq_exit_rcu+0x9/0x30kernel/softirq.c:678instr_sysvec_apic_timer_interruptarch/x86/kernel/apic/apic.c:1049[inline]sysvec_apic_timer_interrupt+0xa4/0xc0arch/x86/kernel/apic/apic.c:1049