[BUG] net/ipv6: use-after-free in seg6_bpf_has_valid_srh()

From: co <hidden>
Date: 2026-09-07 18:13:25
Also in: bpf, lkml

We found a bug reachable in:

    path    net/ipv6
    crash   use-after-free in seg6_bpf_has_valid_srh()
    commit  2f1baf1fc892 ("Merge tag 'trace-v7.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace")

Config, environment, the sanitizer report and a C reproducer follow.

== Notes ===============================================================
    If you patch the bug based on our artifacts, a tag would be
    appreciated:

Reported-by: co+adfca3e91be95776@bugs.sh

    Everything in this mail is validated by the reproducer below.

    We also hold an LLM-generated root-cause analysis and a candidate
    patch. The patch passes an A/B test: the same reproducer panics the
    unpatched kernel and runs clean on the patched one. Neither has had
    human review, so both still require validation before you send or
    apply them. Available on:

        patch.diff  https://bugs.sh/b/adfca3e91be95776/patch.diff
        report.md   https://bugs.sh/b/adfca3e91be95776/report.md

    This is an open science project. The code and the full set of PoCs
    are not public at this moment, as we intend to disclose our findings
    in an ethical way.

    Happy to test patches. Complaints and suggestions about our work
    are welcome at:

        cedalion@bugs.sh

== Environment =========================================================
    Reproduced on  2f1baf1fc892 ("Merge tag 'trace-v7.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace")
    VM setup       https://bugs.sh/b/adfca3e91be95776/run.sh
    config         https://bugs.sh/b/adfca3e91be95776/config.gz
    poc            https://bugs.sh/b/adfca3e91be95776/repro.c

== Sanitizer Report ====================================================
BUG: KASAN: slab-use-after-free in seg6_bpf_has_valid_srh (net/ipv6/seg6_local.c:1411)
Write of size 1 at addr ffff88803012c6b1 by task exploit/5008
CPU: 0 UID: 0 PID: 5008 Comm: exploit Not tainted 7.2.0-07242-g7cbfb180945c #65 PREEMPT(full)
Call Trace:
<IRQ>
dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
print_report (mm/kasan/report.c:378 mm/kasan/report.c:482)
kasan_report (mm/kasan/report.c:595)
seg6_bpf_has_valid_srh (net/ipv6/seg6_local.c:1411)
input_action_end_bpf (net/ipv6/seg6_local.c:1463 (discriminator 1))
seg6_local_input_core (net/ipv6/seg6_local.c:1628)
seg6_local_input (net/ipv6/seg6_local.c:1650 (discriminator 1))
lwtunnel_input (net/core/lwtunnel.c:465)
ipv6_rcv (./include/net/dst.h:480 (discriminator 7) net/ipv6/ip6_input.c:119 (discriminator 7) ./include/linux/netfilter.h:325 (discriminator 7) ./include/linux/netfilter.h:319 (discriminator 7) net/ipv6/ip6_input.c:351 (discriminator 7))
__netif_receive_skb_one_core (net/core/dev.c:6264 (discriminator 1))
__netif_receive_skb (net/core/dev.c:6377)
process_backlog (net/core/dev.c:6728)
__napi_poll.constprop.0 (net/core/dev.c:7787)
net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
handle_softirqs (kernel/softirq.c:645)
do_softirq (kernel/softirq.c:546 (discriminator 20) kernel/softirq.c:533 (discriminator 20))
</IRQ>
__local_bh_enable_ip (kernel/softirq.c:473)
__dev_queue_xmit (./include/linux/bottom_half.h:33 (discriminator 1) ./include/linux/rcupdate.h:914 (discriminator 1) net/core/dev.c:4961 (discriminator 1))
packet_xmit (./include/linux/netdevice.h:3461 net/packet/af_packet.c:277)
packet_sendmsg (net/packet/af_packet.c:3110 net/packet/af_packet.c:3142)
__sys_sendto (net/socket.c:800 (discriminator 1) net/socket.c:815 (discriminator 1) net/socket.c:2281 (discriminator 1))
__x64_sys_sendto (net/socket.c:2288 net/socket.c:2284 net/socket.c:2284)
do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Allocated by task 5008:
Freed by task 5008:
The buggy address belongs to the object at ffff88803012c680
which belongs to the cache skbuff_small_head of size 704
The buggy address is located 49 bytes inside of
freed 704-byte region [ffff88803012c680, ffff88803012c940)
The buggy address belongs to the physical page:
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 23240374303, free_ts 0
page_owner free stack trace missing
Memory state around the buggy address:
ffff88803012c580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb


---
The report format is based on syzbot bug report.

This report is generated by a bot. It may contain errors.
See https://github.com/n132/cedalion for more information.

For any issue with this report, reach out to cedalion@bugs.sh

If the report is already addressed, let us know by replying with:
#co fix: <commit hash>

If the report is a duplicate of another one, reply with:
#co dup: <lore link>

If you want to undo deduplication, reply with:
#co undup

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help