Skip to contentSkip to conversation

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

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 1

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

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.

The Linux kernel CVE team has assigned CVE-2026-31700 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.6 with commit 1d036d25e5609ba73fee6a88db01c306b140d512 and fixed in 6.6.136 with commit 74e2db36fe50e3ad9d5300d7fd0e6e2a15a6d121
	Issue introduced in 4.6 with commit 1d036d25e5609ba73fee6a88db01c306b140d512 and fixed in 6.12.84 with commit 3a1bf9116ea31470b89692585c3910dfe830dcdd
	Issue introduced in 4.6 with commit 1d036d25e5609ba73fee6a88db01c306b140d512 and fixed in 6.18.25 with commit 28324a3b62d9ce7f9bdd65a8ce63f382041d1b27
	Issue introduced in 4.6 with commit 1d036d25e5609ba73fee6a88db01c306b140d512 and fixed in 7.0.2 with commit 48a6ef291a17639e1b6ae0fbe9c8b2bb87d7804b
	Issue introduced in 4.6 with commit 1d036d25e5609ba73fee6a88db01c306b140d512 and fixed in 7.1-rc1 with commit 2c054e17d9d41f1020376806c7f750834ced4dc5

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2026-31700

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
net/packet/af_packet.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/74e2db36fe50e3ad9d5300d7fd0e6e2a15a6d121
	https://git.kernel.org/stable/c/3a1bf9116ea31470b89692585c3910dfe830dcdd
	https://git.kernel.org/stable/c/28324a3b62d9ce7f9bdd65a8ce63f382041d1b27
	https://git.kernel.org/stable/c/48a6ef291a17639e1b6ae0fbe9c8b2bb87d7804b
	https://git.kernel.org/stable/c/2c054e17d9d41f1020376806c7f750834ced4dc5