From: Ren Wei <weir@nebusec.ai>
To: netdev@vger.kernel.org, kuba@kernel.org, jhs@mojatatu.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
pabeni@redhat.com, vega@nebusec.ai, bronzed_45_vested@icloud.com,
enjou1224z@gmail.com, weir@nebusec.ai
Subject: [PATCH net v4 1/1] net: loopback: reject skbs with a short linear Ethernet header
Date: Mon, 5 Oct 2026 13:22:49 +0800 [thread overview]
Message-ID: <20261005052249.1914367-2-weir@nebusec.ai> (raw)
In-Reply-To: <20261005052249.1914367-1-weir@nebusec.ai>
From: Wyatt Feng <bronzed_45_vested@icloud.com>
loopback_xmit() calls eth_type_trans(), which reads the Ethernet header
from skb->data and consumes ETH_HLEN bytes. This requires at least
ETH_HLEN bytes in the skb's linear area.
An earlier transformation can leave a non-linear skb with fewer than
ETH_HLEN bytes in the linear area, even when skb->len is at least
ETH_HLEN. Pulling the header then makes skb->len smaller than
skb->data_len and triggers the BUG in __skb_pull().
Check skb_headlen(skb) before calling eth_type_trans(). Reject skbs
whose linear area is too short, including those whose total length is
less than ETH_HLEN, without attempting to pull bytes from fragments.
Free rejected skbs, account them as TX drops and return NETDEV_TX_OK.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Link: https://lore.kernel.org/all/2d4e79d252a57bdad83435999dddf2c4b708dcfa.1785049236.git.bronzed_45_vested@icloud.com/
Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Assisted-by: Codex:GPT-5.4
Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
Signed-off-by: Ren Wei <enjou1224z@gmail.com>
---
Changes in v4:
- Replace pskb_may_pull() with a direct skb_headlen() check, as
requested by Jamal after considering the Sashiko feedback.
- Update the commit message to match the linear-length check.
- Correct the Fixes tag to the earliest tracked occurrence of the
unchecked eth_type_trans() call and the skb pull invariant.
drivers/net/loopback.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 1fb6ce6843ad..eaa9a5a8542a 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -72,6 +72,12 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
{
int len;
+ if (unlikely(skb_headlen(skb) < ETH_HLEN)) {
+ kfree_skb(skb);
+ dev_core_stats_tx_dropped_inc(dev);
+ return NETDEV_TX_OK;
+ }
+
skb_tx_timestamp(skb);
/* do not fool net_timestamp_check() with various clock bases */
next prev parent reply other threads:[~2026-10-05 5:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 5:22 [PATCH net v4 0/1] net: loopback: reject skbs with a short linear Ethernet header Ren Wei
2026-10-05 5:22 ` Ren Wei [this message]
2026-10-05 6:14 ` [PATCH net v4 1/1] " Eric Dumazet
2026-10-05 20:23 ` [PATCH net v4 0/1] " Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261005052249.1914367-2-weir@nebusec.ai \
--to=weir@nebusec.ai \
--cc=andrew+netdev@lunn.ch \
--cc=bronzed_45_vested@icloud.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=enjou1224z@gmail.com \
--cc=jhs@mojatatu.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vega@nebusec.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox