CVE-2026-31700
JSON

7.8high

net/packet: fix TOCTOU race on mmap'd vnet_hdr in tpacket_snd()

Severity
7.8high CVSS:3.1 by Linux
Exploit likelihood
0.15% (higher than 4% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: net/packet: fix TOCTOU race on mmap'd vnet_hdr in tpacket_snd() In tpacket_snd(), when PACKET_VNET_HDR is enabled, vnet_hdr points directly into the mmap'd TX ring buffer shared with userspace. The kernel validates the header via __packet_snd_vnet_parse() but then re-reads all fields later in virtio_net_hdr_to_skb(). A concurrent userspace thread can modify the vnet_hdr fields between validation and use, bypassing all safety checks. The non-TPACKET path (packet_snd()) already correctly copies vnet_hdr to a stack-local variable. All other vnet_hdr consumers in the kernel (tun.c, tap.c, virtio_net.c) also use stack copies. The TPACKET TX path is the only caller of virtio_net_hdr_to_skb() that reads directly from user-controlled shared memory. Fix this by copying vnet_hdr from the mmap'd ring buffer to a stack-local variable before validation and use, consistent with the approach used in packet_snd() and all other callers.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 1d036d25e5609ba73fee6a88db01c306b140d512 before 0f4c9754956b86de158a4af5278c5cf5bda9439e, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 714aa973da8163925eda7efd49361ccbee21ee46, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 1490f82353bdabc09265a74e645b07f05cf4188e, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 74e2db36fe50e3ad9d5300d7fd0e6e2a15a6d121, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 3a1bf9116ea31470b89692585c3910dfe830dcdd, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 28324a3b62d9ce7f9bdd65a8ce63f382041d1b27, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 48a6ef291a17639e1b6ae0fbe9c8b2bb87d7804b, from 1d036d25e5609ba73fee6a88db01c306b140d512 before 2c054e17d9d41f1020376806c7f750834ced4dc5 and 1 more
Not affected: before 4.6, from 5.10.259 up to 5.10.*, from 5.15.210 up to 5.15.*, from 6.1.176 up to 6.1.*, from 6.6.136 up to 6.6.*, from 6.12.84 up to 6.12.*
CVE List
linux linux_kernelfrom 4.6 before 6.6.136, from 6.7 before 6.12.84, from 6.13 before 6.18.25, from 6.19 before 7.0.2, 7.1NVD

Classification

CWE-362CWE-367

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: net/packet: fix TOCTOU race on mmap'd vnet_hdr in tpacket_snd() In tpacket_snd(), when PACKET_VNET_HDR is enabled, vnet_hdr points directly into the mmap'd TX ring buffer shared with userspace. The kernel validates the header via __packet_snd_vnet_parse() but then re-reads all fields later in virtio_net_hdr_to_skb(). A concurrent userspace thread can modify the vnet_hdr fields between validation and use, bypassing all safety checks. The non-TPACKET path (packet_snd()) already correctly copies vnet_hdr to a stack-local variable. All other vnet_hdr consumers in the kernel (tun.c, tap.c, virtio_net.c) also use stack copies. The TPACKET TX path is the only caller of virtio_net_hdr_to_skb() that reads directly from user-controlled shared memory. Fix this by copying vnet_hdr from the mmap'd ring buffer to a stack-local variable before validation and use, consistent with the approach used in packet_snd() and all other callers.

NVD (es)

En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: net/packet: corregir la condición de carrera TOCTOU en vnet_hdr mapeado por mmap en tpacket_snd() En tpacket_snd(), cuando PACKET_VNET_HDR está habilitado, vnet_hdr apunta directamente al búfer de anillo TX mapeado por mmap compartido con el espacio de usuario. El kernel valida el encabezado a través de __packet_snd_vnet_parse() pero luego vuelve a leer todos los campos más tarde en virtio_net_hdr_to_skb(). Un hilo concurrente del espacio de usuario puede modificar los campos de vnet_hdr entre la validación y el uso, eludiendo todas las comprobaciones de seguridad. La ruta no-TPACKET (packet_snd()) ya copia correctamente vnet_hdr a una variable local de la pila. Todos los demás consumidores de vnet_hdr en el kernel (tun.c, tap.c, virtio_net.c) también usan copias en la pila. La ruta TPACKET TX es el único llamador de virtio_net_hdr_to_skb() que lee directamente de memoria compartida controlada por el usuario. Solucione esto copiando vnet_hdr del búfer de anillo mapeado por mmap a una variable local de la pila antes de la validación y el uso, consistente con el enfoque utilizado en packet_snd() y todos los demás llamadores.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-31700 changed 2026-11-10CVE Terms of Use
NVDCVE-2026-31700 changed 2026-11-11Public domain