All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2] net: xdp: fix generic XDP on skbs without an Ethernet header
Date: Tue, 24 Nov 2026 12:16:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-231117@kernel.org> (raw)
In-Reply-To: <20261123121540.275576-1-jiayuan.chen@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: xdp: incomplete Ethernet check in
  netif_receive_generic_xdp()
--

commit 2ed38b0924ab170f5d151d7bc82023a0581fce18
Author: Jiayuan Chen <jiayuan.chen@linux.dev>

net: xdp: fix generic XDP on skbs without an Ethernet header

This commit rejects generic XDP attachment on devices whose type is not
ARPHRD_ETHER or ARPHRD_LOOPBACK, and skips generic XDP processing in
netif_receive_generic_xdp() when skb->data - skb_mac_header(skb) < ETH_HLEN.

> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6140fd9d11cd0..df335f361706d 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5823,6 +5823,10 @@ static u32 netif_receive_generic_xdp(struct sk_buff **pskb,
>  	if (skb_is_redirected(skb))
>  		return XDP_PASS;
>  
> +	/* XDP is Ethernet only, skip skbs without an Ethernet header. */
> +	if (skb->data - skb_mac_header(skb) < ETH_HLEN)
> +		return XDP_PASS;
> +
>  	/* XDP packets must have sufficient headroom of XDP_PACKET_HEADROOM
>  	 * bytes. This is the guarantee that also native XDP provides,
>  	 * thus we need to do it here as well.

[Severity: Medium]
Does checking for < ETH_HLEN still let skbs with mac_len > ETH_HLEN or a
non-Ethernet skb->dev->type reach bpf_prog_run_generic_xdp()?

On a VLAN device with VLAN_FLAG_REORDER_HDR cleared, vlan_do_receive()
pulls ETH_HLEN + VLAN_HLEN (18 bytes) and resets skb->mac_len to 18.
Similarly, if an empty bond or team device has generic XDP attached and
then enslaves an ARPHRD_INFINIBAND or ARPHRD_IPGRE port, skb->dev->type
changes and received skbs arrive with skb->data - skb_mac_header(skb) >=
24.

When mac_len > ETH_HLEN, the header-mangle fixup in
bpf_prog_run_generic_xdp() pushes ETH_HLEN (14) and calls
eth_type_trans(), leaving skb->mac_header at skb->data - ETH_HLEN while
skb->mac_len is still 18 or 24, which triggers the same skb_vlan_push()
warning on TC ingress.  In addition, xdp_prepare_buff() includes mac_len
bytes ahead of skb->data while bpf_xdp_adjust_head() only enforces a
minimum frame size of ETH_HLEN, allowing off > skb_headlen(skb) in
__skb_pull(skb, off) to underflow skb->len or hit BUG() when
skb->data_len > 0.

Should netif_receive_generic_xdp() check skb->data - skb_mac_header(skb)
!= ETH_HLEN as well as skb->dev->type != ARPHRD_ETHER && skb->dev->type !=
ARPHRD_LOOPBACK?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123121540.275576-1-jiayuan.chen@linux.dev?part=1

  reply	other threads:[~2026-11-24 12:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 12:15 [PATCH net v2] net: xdp: fix generic XDP on skbs without an Ethernet header Jiayuan Chen
2026-11-24 12:16 ` sashiko-bot [this message]
2026-11-24 12:24 ` netdev-bot+sashiko
2026-11-24 14:23   ` Jiayuan Chen

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=sashiko-outbox-231117@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.