From: sashiko-bot@kernel.org
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v7 7/7] net: bcmgenet: reject MTU changes incompatible with XDP
Date: Thu, 16 Apr 2026 20:47:40 +0000 [thread overview]
Message-ID: <20260416204740.A7A09C2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <20260416054743.1289191-8-nb@tipi-net.de>
Sashiko AI review found 1 potential issue(s):
- [Medium] The added XDP MTU bounds check in `bcmgenet_change_mtu` is mathematically dead code and contains a logic error regarding L2 overhead.
--
commit ed63f1ac315cb265c4f6425861261ded1cad7433
Author: Nicolai Buchwitz <nb@tipi-net.de>
net: bcmgenet: reject MTU changes incompatible with XDP
Add a minimal ndo_change_mtu that rejects MTU values too large for
single-page XDP buffers when an XDP program is attached.
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 02ad2f410d6c6..4d1ec68ec0c59 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,
> return sent;
> }
>
> +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 check reachable? The bcmgenet driver appears to rely on the
ether_setup() default of dev->max_mtu = ETH_DATA_LEN (1500) and never
overrides it to support jumbo frames.
The core networking stack's dev_validate_mtu() enforces new_mtu <=
dev->max_mtu before invoking ndo_change_mtu. Assuming a minimum Linux
PAGE_SIZE of 4096, this check requires new_mtu to be greater than ~3510
bytes, which should never be possible.
Also, does this formula account for L2 overhead?
new_mtu represents the L3 payload size, but the hardware will DMA the full L2
frame into the buffer, including the Ethernet header, VLAN tags, and the
Frame Check Sequence. If jumbo frames are enabled later and an MTU exactly
matched this limit, would the L2 frame silently overflow the page boundary
and corrupt the skb_shared_info structure?
> + 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/20260416054743.1289191-1-nb@tipi-net.de?part=7
next prev parent reply other threads:[~2026-04-16 20:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 5:47 [PATCH net-next v7 0/7] net: bcmgenet: add XDP support Nicolai Buchwitz
2026-04-16 5:47 ` [PATCH net-next v7 2/7] net: bcmgenet: register xdp_rxq_info for each RX ring Nicolai Buchwitz
2026-04-16 5:47 ` [PATCH net-next v7 3/7] net: bcmgenet: add basic XDP support (PASS/DROP) Nicolai Buchwitz
2026-04-16 5:47 ` [PATCH net-next v7 4/7] net: bcmgenet: add XDP_TX support Nicolai Buchwitz
2026-04-16 18:54 ` sashiko-bot
2026-04-16 5:47 ` [PATCH net-next v7 5/7] net: bcmgenet: add XDP_REDIRECT and ndo_xdp_xmit support Nicolai Buchwitz
2026-04-16 19:46 ` sashiko-bot
2026-04-16 5:47 ` [PATCH net-next v7 6/7] net: bcmgenet: add XDP statistics counters Nicolai Buchwitz
2026-04-16 20:08 ` sashiko-bot
2026-04-16 5:47 ` [PATCH net-next v7 7/7] net: bcmgenet: reject MTU changes incompatible with XDP Nicolai Buchwitz
2026-04-16 20:47 ` sashiko-bot [this message]
2026-04-16 8:06 ` [PATCH net-next v7 0/7] net: bcmgenet: add XDP support Paolo Abeni
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=20260416204740.A7A09C2BCAF@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