macsec: reject frames that decapsulate into runt Ethernet frames
Subsystems (3)
PATCH 1/1 macsec: reject frames that decapsulate into runt Ethernet frames
When an SCI is unknown and the C bit is clear, macsec_handle_frame() removes the SecTAG and the default ICV without checking how much of the frame remains. A short frame can therefore become an skb shorter than ETH_HLEN. eth_type_trans() cannot pull its Ethernet header, and a second stacked MACsec device can copy stale skb headroom into a packet delivered to a packet socket.
The matched-SCI path has a related hole: macsec_validate_skb() accepts a short_length of one, so a frame that passes the existing length check can still become a 13-byte Ethernet frame.
Require enough bytes for the MACsec overhead and a complete Ethernet header before decapsulating an unknown-SCI frame. Apply the same bound in macsec_validate_skb(), using the selected SecY's ICV length, to cover the no-SA, synchronous-decrypt and asynchronous-decrypt delivery paths. Leave other unknown-SCI handling unchanged.
---
I have a reproducer for this issue and can share via DM
drivers/net/macsec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/macsec.c +10 -5
@@ -408,8 +408,10 @@ static bool macsec_validate_skb(struct sk_buff *skb, u16 icv_len, bool xpn)int len = skb->len -2 *ETH_ALEN ;int extra_len =macsec_extra_len (!!(h->tci_an &MACSEC_TCI_SC )) + icv_len; -/* a) It comprises at least 17 octets */ -if (skb->len <=16 ) +/* a) It comprises at least 17 octets. The SecTAG and ICV must +* also leave a complete Ethernet header. +*/ +if (skb->len <ETH_HLEN + extra_len)return false;/* b) MACsec EtherType: already checked */
@@ -1331,9 +1333,12 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb) nosci:/* 10.6.1 if the SC is not found */ cbit = !!(hdr->tci_an &MACSEC_TCI_C ); -if (!cbit) -macsec_finalize_skb (skb,MACSEC_DEFAULT_ICV_LEN , -macsec_extra_len (macsec_skb_cb (skb)->has_sci)); +if (!cbit) { + len =macsec_extra_len (macsec_skb_cb (skb)->has_sci); +if (skb->len <ETH_HLEN + len +MACSEC_DEFAULT_ICV_LEN ) + goto drop_nosc; +macsec_finalize_skb (skb,MACSEC_DEFAULT_ICV_LEN , len); + }list_for_each_entry_rcu (macsec, &rxd->secys, secys) {struct sk_buff *nskb;
base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3
Signature · 1 line
2.56.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
This patch was applied to netdev/net.git (main) by Dave Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main) by Dave Miller <[email protected]>:
Quoted 8 lines · On Thu, 29 Oct 2026 21:22:37 -0700 you wrote:
When an SCI is unknown and the C bit is clear,
macsec_handle_frame()removes the SecTAG and the default ICV without checking how much of the frame remains. A short frame can therefore become an skb shorter thanETH_HLEN.eth_type_trans()cannot pull its Ethernet header, and a second stacked MACsec device can copy stale skb headroom into a packet delivered to a packet socket.[...]
Here is the summary with links:
- macsec: reject frames that decapsulate into runt Ethernet frames
https://git.kernel.org/netdev/net/c/1d5e2c57e9ff
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html