Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: edumazet@kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, netdev@vger.kernel.org, stable@vger.kernel.org,
	sfle@kth.se, edumazet@google.com, michael.chan@broadcom.com,
	pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch,
	berni@debian.org
Subject: Re: [PATCH v2 net] bnxt_en: fix DMA mapping length for padded small packets
Date: Wed, 07 Oct 2026 04:22:37 +0000	[thread overview]
Message-ID: <179134695789.434549.53526916334276884@kernel.org> (raw)
In-Reply-To: <20261006042153.199444-1-edumazet@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] Regression in the software UDP GSO path.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the sister
  bnge driver has the same stale-fragment ordering bug that the bnxt v2…

--

bnxt_en: fix DMA mapping length for padded small packets

This patch moves short-frame padding in bnxt_start_xmit() to the top of
the function and uses skb_put_padto(). As a result, skb_headlen() now
includes the pad when the linear head is DMA-mapped. This fixes the IOMMU
read faults that happened when the TX BD length was larger than the
mapped length.

Closes: https://lore.kernel.org/netdev/20261004122616.56714cbd@nargothrond/

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index d7728d0c5b6e6..7f379f21fe465 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c

[ ... ]

> @@ -507,6 +507,11 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	txr = &bp->tx_ring[bp->tx_ring_map[i]];
>  	prod = txr->tx_prod;
>  
> +	if (skb_put_padto(skb, BNXT_MIN_PKT_SIZE)) {
> +		/* SKB already freed. */
> +		goto tx_kick_pending;
> +	}
> +

[Severity: Medium]
Does moving the pad ahead of the SW USO branch change what
bnxt_sw_udp_gso_xmit() puts on the wire?

Before this patch, padding only ran at normal_tx:, after the SW USO branch
had already returned. So bnxt_sw_udp_gso_xmit() always got the unpadded
skb.

Now a UDP GSO skb shorter than 52 bytes is padded first. On devices
without BNXT_FLAG_UDP_GSO_CAP it then goes here:

	if (skb_is_gso(skb) &&
	    (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) &&
	    !(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) {
		int rc = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb);

bnxt_sw_udp_gso_xmit() in bnxt_gso.c then computes:

	total_payload = skb->len - hdr_len;
	num_segs = DIV_ROUND_UP(total_payload, mss);

This counts the zero pad as UDP payload. tso_build_hdr() builds
iph->tot_len and the UDP length from the segment payload, and the NIC
fills in valid checksums. Would the receiver then accept the pad bytes as
real UDP data?

For example, Ethernet 14 + IPv4 20 + UDP 8 + 2 bytes of data is 44 bytes.
With gso_size=1 that is padded to 52. total_payload goes from 2 to 10, so
10 datagrams are sent instead of 2, and eight of them carry only zeros.

An unprivileged UDP socket can trigger this by setting UDP_SEGMENT to a
small gso_size and sending a few bytes over IPv4.

Also, BNXT_MIN_PKT_SIZE is a per-frame minimum. Padding the super-packet
still leaves the individual SW USO segments (for example 43 bytes)
shorter than that.

Should the pad be skipped for skb_is_gso() skbs, or applied after the SW
USO branch?

[Severity: High]
This isn't a bug introduced by this patch, but the sister bnge driver
seems to have the ordering problem that this v2 placement avoids for
bnxt. In bnge_start_xmit() in drivers/net/ethernet/broadcom/bnge/bnge_txrx.c,
the frag count is read before padding:

	last_frag = skb_shinfo(skb)->nr_frags;
	...
	tx_buf->nr_frags = last_frag;
	...
	if (eth_skb_pad(skb))
		goto tx_kick_pending;

A nonlinear skb shorter than ETH_ZLEN has skb_tailroom() of 0. In that
case __skb_pad() goes through pskb_expand_head() and skb_linearize().
That pulls the frag data into the head, drops the frag page references
and sets nr_frags to 0.

bnge_start_xmit() then keeps using the stale last_frag:

	flags = (len << TX_BD_LEN_SHIFT) | TX_BD_TYPE_LONG_TX_BD |
		TX_BD_CNT(last_frag + 2);
	...
	for (i = 0; i < last_frag; i++) {
		frag = &skb_shinfo(skb)->frags[i];
		...
		mapping = skb_frag_dma_map(bd->dev, frag, 0, len,
					   DMA_TO_DEVICE);

Can this DMA-map frag pages that the skb no longer holds a reference to?
If so, the NIC would send the frag data twice and read pages that may
already be freed or recycled, such as page_pool pages.

Two ways to get such skbs are AF_PACKET TX_RING SOCK_RAW frames and
forwarded small packets whose payload stayed in a frag after
pskb_trim_rcsum().

As a separate fix, would it make sense to call eth_skb_pad() before
nr_frags is read in bnge_start_xmit(), the same way this patch does for
bnxt?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006042153.199444-1-edumazet%40kernel.org

  parent reply	other threads:[~2026-10-07  4:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  4:21 [PATCH v2 net] bnxt_en: fix DMA mapping length for padded small packets Eric Dumazet
2026-10-06  7:38 ` Michael Chan
2026-10-07  4:22 ` netdev-bot+sashiko [this message]
2026-10-07  4:52   ` 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=179134695789.434549.53526916334276884@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=berni@debian.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=sfle@kth.se \
    --cc=stable@vger.kernel.org \
    /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