BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v8 7/7] net: bcmgenet: reject MTU changes incompatible with XDP
Date: Wed, 29 Apr 2026 21:17:04 +0000	[thread overview]
Message-ID: <20260429211705.4CF4CC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260428205846.2625550-8-nb@tipi-net.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The XDP MTU validation logic contains a mathematical error (ignoring L2 headers) and is structurally unreachable (dead code) because the device's maximum MTU is fixed at 1500.
--

commit b8018c0a123b4927db5ca8c39c8395c751532069
Author: Nicolai Buchwitz <nb@tipi-net.de>

net: bcmgenet: reject MTU changes incompatible with XDP

This commit introduces a minimal ndo_change_mtu function to the bcmgenet
driver. It checks if an XDP program is attached and rejects MTU values that
would exceed the capacity of a single-page XDP buffer.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 02ad2f410d6c..4d1ec68ec0c5 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -4085,6 +4085,20 @@ static int bcmgenet_xdp_xmit(struct net_device *dev, int num_frames,
[ ... ]
> +static int bcmgenet_change_mtu(struct net_device *dev, int new_mtu)
> +{
> +	struct bcmgenet_priv *priv = netdev_priv(dev);
> +
> +	if (priv->xdp_prog && new_mtu > PAGE_SIZE - GENET_RX_HEADROOM -
> +	    SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) {

Is this condition actually reachable, and does it correctly account for L2
headers?

The bcmgenet driver does not appear to override dev->max_mtu, which
defaults to ETH_DATA_LEN (1500). Because dev_validate_mtu() in the core
networking stack checks that new_mtu <= dev->max_mtu before calling
ndo_change_mtu, new_mtu will never exceed 1500.

Given that PAGE_SIZE (typically 4096) minus GENET_RX_HEADROOM and the
skb_shared_info alignment is roughly 3454 bytes, the check new_mtu > 3454
will always evaluate to false.

Also, new_mtu represents the L3 payload size. Shouldn't the check add the
L2 header overhead when comparing against the L2 buffer capacity?

Furthermore, is it possible for an MTU change to corrupt the XDP buffer
layout as the commit message claims?

The hardware DMA appears to be statically configured to write a maximum of
RX_BUF_LENGTH (2048) bytes per buffer, and bcmgenet_desc_rx() explicitly
drops any packet larger than 2048 bytes. It seems structurally impossible
to overflow the 4096-byte page and corrupt skb_shared_info.

> +		netdev_warn(dev, "MTU too large for single-page XDP buffer\n");
> +		return -EINVAL;
> +	}
> +
> +	WRITE_ONCE(dev->mtu, new_mtu);
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260428205846.2625550-1-nb@tipi-net.de?part=7

  reply	other threads:[~2026-04-29 21:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 20:58 [PATCH net-next v8 0/7] net: bcmgenet: add XDP support Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 2/7] net: bcmgenet: register xdp_rxq_info for each RX ring Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 3/7] net: bcmgenet: add basic XDP support (PASS/DROP) Nicolai Buchwitz
2026-04-29 21:17   ` sashiko-bot
2026-04-29 22:24     ` Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 4/7] net: bcmgenet: add XDP_TX support Nicolai Buchwitz
2026-04-29 21:17   ` sashiko-bot
2026-04-29 22:28     ` Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 5/7] net: bcmgenet: add XDP_REDIRECT and ndo_xdp_xmit support Nicolai Buchwitz
2026-04-29 21:17   ` sashiko-bot
2026-04-29 22:50     ` Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 6/7] net: bcmgenet: add XDP statistics counters Nicolai Buchwitz
2026-04-29 21:17   ` sashiko-bot
2026-04-29 22:39     ` Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 7/7] net: bcmgenet: reject MTU changes incompatible with XDP Nicolai Buchwitz
2026-04-29 21:17   ` sashiko-bot [this message]
2026-04-29 22:35     ` Nicolai Buchwitz

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=20260429211705.4CF4CC19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox