CVE-2026-143186: nsh: limit recursion in nsh_gso_segment()
In the Linux kernel, the following vulnerability has been resolved:
nsh: limit recursion in nshgsosegment()
nshgsosegment() calls skbmacgsosegment() for the inner packet, which calls nshgsosegment() again when the next protocol is NSH, either directly or behind an inner Ethernet header (ETHPTEB).
Nothing limits the depth: a GSO packet made of stacked 8-byte NSH headers recurses once per header, and a 64KB packet can hold about 8000 of them, overflowing the kernel stack.
Such a packet can be injected with a packet socket using PACKETVNETHDR, or with tun/tap or virtionet, as nothing checks that a GSO packet with VIRTIONETHDRFNEEDSCSUM carries the protocol it claims. It is then segmented in software if the output device does not support the GSO type:
BUG: TASK stack guard page was hit at ffffcad5c0ab3ff8 (stack is ffffcad5c0ab4000..ffffcad5c0ab8000) Oops: stack guard page: 0000 [#1] SMP NOPTI CPU: 3 UID: 0 PID: 337 Comm: nshgso Tainted: G E 7.4.0-rc1+ #118 PREEMPT(lazy) RIP: 0010:lockacquire (kernel/locking/lockdep.c:5902) Call Trace: <TASK> skbmacgsosegment (include/linux/rcupdate.h:309 include/linux/rcupdate.h:849 net/core/gso.c:50) nshgsosegment (net/nsh/nsh.c:110) nsh skbmacgsosegment (net/core/gso.c:53) nshgsosegment (net/nsh/nsh.c:110) nsh [...] skbmacgsosegment (net/core/gso.c:53) skbgsosegment (net/core/gso.c:129) validatexmitskb (net/core/dev.c:4238) devqueuexmit (net/core/dev.c:5087) packetsendmsg (net/packet/afpacket.c:3157 net/packet/afpacket.c:3189) syssendto (net/socket.c:800 net/socket.c:818 net/socket.c:2283) x64syssendto (net/socket.c:2290 net/socket.c:2286 net/socket.c:2286) dosyscall64 (arch/x86/entry/syscall64.c:61 arch/x86/entry/syscall64.c:84) entrySYSCALL64afterhwframe (arch/x86/entry/entry64.S:121)
Use gsorecursioninctest(), added in commit 006c8b834aed ("net: gso: limit recursive IP-in-IP segmentation"), with the same limit as IPv4 and IPv6. The counter is shared with them: a packet with four NSH headers in front of an IPv4 header is still segmented, one more NSH header and it is dropped.
The NSH -> ETHPTEB -> NSH route is covered as well, as each round goes through nshgsosegment().
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.120 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.66 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.7
Event History
Frequently Asked Questions
What traffic pattern triggers the stack overflow?
A GSO packet containing deeply stacked 8-byte NSH headers can cause recursive segmentation when the next protocol is NSH, either directly or behind an inner Ethernet header using ETH_P_TEB. A 64KB packet can contain roughly 8,000 such headers, exhausting the kernel stack.
Which packet injection paths can carry the crafted packet?
The crafted GSO packet can be injected through a packet socket using PACKET_VNET_HDR, or through tun/tap or virtio_net. These paths do not verify that a GSO packet marked with VIRTIO_NET_HDR_F_NEEDS_CSUM carries the protocol it claims.
When is the vulnerable segmentation path reached?
The packet is segmented in software when the output device does not support the relevant GSO type. During that software segmentation, nsh_gso_segment() can recursively re-enter itself for each stacked NSH header.