Netdev List
 help / color / mirror / Atom feed
From: Ren Wei <weir@nebusec.ai>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, tim.bird@sony.com,
	opurdila@ixiacom.com, vega@nebusec.ai, petalzu987@gmail.com,
	weir@nebusec.ai
Subject: [PATCH net 1/1] llc: reserve device headroom for allocated frames
Date: Tue, 22 Sep 2026 17:41:54 +0800	[thread overview]
Message-ID: <5002123a7fd47989926bcefe4d5bdeb824f40b63.1789987105.git.petalzu987@gmail.com> (raw)
In-Reply-To: <cover.1789987105.git.petalzu987@gmail.com>

From: Zixuan Chai <petalzu987@gmail.com>

llc_alloc_frame() reserves link-layer headroom using the device type.
This is insufficient for stacked Ethernet devices such as VLAN devices,
where vlan_dev_hard_header() pushes a VLAN header before the lower
device's Ethernet header. An LLC response on such a device can
therefore underflow skb headroom in eth_header().

Use LL_RESERVED_SPACE() to account for the device's actual required
headroom while preserving the existing reservation for the LLC header.

Fixes: bf9ae5386bca ("llc: use dev_hard_header")
Cc: stable@vger.kernel.org
Reported-by: VEGA <vega@nebusec.ai>
Assisted-by: LLM
Signed-off-by: Zixuan Chai <petalzu987@gmail.com>
Signed-off-by: Ren Wei <weir@nebusec.ai>
---
 net/llc/llc_sap.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index 1bd446a21092..4b203ffb1e83 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -19,16 +19,6 @@
 #include <linux/llc.h>
 #include <linux/slab.h>
 
-static int llc_mac_header_len(unsigned short devtype)
-{
-	switch (devtype) {
-	case ARPHRD_ETHER:
-	case ARPHRD_LOOPBACK:
-		return sizeof(struct ethhdr);
-	}
-	return 0;
-}
-
 /**
  *	llc_alloc_frame - allocates sk_buff for frame
  *	@sk:  socket to allocate frame to
@@ -45,7 +35,7 @@ struct sk_buff *llc_alloc_frame(struct sock *sk, struct net_device *dev,
 	int hlen = type == LLC_PDU_TYPE_U ? 3 : 4;
 	struct sk_buff *skb;
 
-	hlen += llc_mac_header_len(dev->type);
+	hlen += LL_RESERVED_SPACE(dev);
 	skb = alloc_skb(hlen + data_size, GFP_ATOMIC);
 
 	if (skb) {
-- 
2.34.1

  reply	other threads:[~2026-09-22  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  9:41 [PATCH net 0/1] llc: reserve device headroom for allocated frames Ren Wei
2026-09-22  9:41 ` Ren Wei [this message]
2026-09-22 11:40   ` [PATCH net 1/1] " Eric Dumazet

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=5002123a7fd47989926bcefe4d5bdeb824f40b63.1789987105.git.petalzu987@gmail.com \
    --to=weir@nebusec.ai \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=opurdila@ixiacom.com \
    --cc=pabeni@redhat.com \
    --cc=petalzu987@gmail.com \
    --cc=tim.bird@sony.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