CVE-2026-143342: net: stmmac: fix VLAN tag stripping on short and non-linear RX frames
In the Linux kernel, the following vulnerability has been resolved:
net: stmmac: fix VLAN tag stripping on short and non-linear RX frames
stmmacrxvlan() reads the VLAN header straight from skb->data and removes it with skbpull(), assuming the header is fully present in the linear part of the skb. XDP can change the frame length and head layout before the tag is stripped.
An XDP program can use bpfxdpadjusttail() to shrink a frame to as little as ETHHLEN while bytes 12-13 still contain a VLAN ethertype. The driver then reads hvlanTCI past skb->len and pops the tag, leaving less than ETHHLEN in the skb. ethtypetrans() cannot pull the MAC header, so a malformed skb is passed up. The TCI is also read from the wrong place when the tag is not fully in the linear head, e.g. when it spans into a frag.
Read hvlanproto after pulling ETHHLEN into the linear part, and check it together with the device features. Only if the tag is actually going to be popped, pull VLANETHHLEN and re-derive the header pointer afterwards, as pskbmaypull() may reallocate the skb head. Return an error so the callers can drop a frame that claims a VLAN tag but cannot provide the full header. This also drops and counts frames shorter than ETHHLEN in rxdropped, even when VLAN RX offload is disabled; bpfxdpadjusthead() and bpfxdpadjusttail() cannot produce such a frame, so it only affects a runt that reaches the driver, and dropping it is safer than handing it to ethtypetrans().
Also move the XDP metadata written with bpfxdpadjustmeta() together with the MAC header when the tag is popped, so datameta still points at the metadata after ethtypetrans() anchors macheader, instead of at the first bytes of the destination MAC.
Affected Software
Event History
Frequently Asked Questions
What conditions are needed to trigger the malformed-frame path?
The described case requires the stmmac receive path to process a frame whose bytes 12-13 indicate a VLAN ethertype after XDP has altered the frame. An XDP program can use bpf_xdp_adjust_tail() to shrink the frame to ETH_HLEN before VLAN stripping occurs.
Can non-linear received packets also be affected?
Yes. The VLAN TCI can be read from the wrong location when the VLAN header is not wholly in the linear skb head, such as when part of it resides in a fragment.
What is the intended handling for a frame that claims a VLAN tag but lacks a complete VLAN header?
The corrected behavior is to return an error so callers can drop the frame. VLAN stripping should occur only after ensuring VLAN_ETH_HLEN can be pulled into the linear skb area.