From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me,
eddie.wai@broadcom.com, prashant@broadcom.com,
huangjw@broadcom.com, gospo@broadcom.com, brett.creeley@amd.com,
ap420073@gmail.com, joe@dama.to, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net 5/5] eth: bnxt: hand XDP frags over to the copybreak skb
Date: Tue, 27 Oct 2026 16:49:40 -0700 [thread overview]
Message-ID: <20261027234940.1267225-6-kuba@kernel.org> (raw)
In-Reply-To: <20261027234940.1267225-1-kuba@kernel.org>
With a multi-buffer XDP program attached, a packet only has agg
buffers if it filled its head buffer, which in page mode holds most
of a page. The program can still move the start of the packet forward
with bpf_xdp_adjust_head() and leave at most rx_copybreak bytes in the
head. bnxt_rx_pkt() then copies the head into a new skb, puts the head
page back on the ring, and calls bnxt_xdp_build_skb() on the copy.
bnxt_xdp_build_skb() only sets nr_frags and the skb's length
accounting, because it expects an skb built around the head page,
sharing its shinfo with the xdp_buff. The copy ends up with nr_frags
set but no frag descriptors, and the stack later reads and releases
whatever its frags array happens to contain. The real frags leak.
Copy the frag descriptors to the new skb in bnxt_copy_xdp(), so that
bnxt_xdp_build_skb() finds the frags where it expects them. The frags
now belong to the skb, and the head page goes back on the ring as
before.
Pointed out in LLM review of the first patch of the series.
Confirmed by reading the code, the unfixed kernel was not run with
the reproducer below.
Tested on a BCM57504 at MTU 9000 with rx-copybreak raised to 1024
and a frags-capable XDP program moving the start of multi-buffer
frames 3000B forward with bpf_xdp_adjust_head(), receiving 8000B
ICMPv6 echo requests (a head and two agg buffers each). All 60k
frames took the copybreak path with frags attached, the sampled skbs
reached GRO with len=4998 data_len=4492 nr_frags=2, and were freed by
the stack with the page pools' inflight count staying flat, no KASAN
or DEBUG_PAGEALLOC splats.
Fixes: 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 4607c31eedf8..757c7266ce15 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1511,6 +1511,14 @@ static struct sk_buff *bnxt_copy_xdp(struct bnxt_napi *bnapi,
__skb_pull(skb, metasize);
}
+ if (unlikely(xdp_buff_has_frags(xdp))) {
+ struct skb_shared_info *sinfo;
+
+ sinfo = xdp_get_shared_info_from_buff(xdp);
+ memcpy(skb_shinfo(skb)->frags, sinfo->frags,
+ sinfo->nr_frags * sizeof(skb_frag_t));
+ }
+
return skb;
}
--
2.56.0
next prev parent reply other threads:[~2026-10-27 23:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 23:49 [PATCH net 0/5] eth: bnxt: fix Rx buffer leaks under OOM Jakub Kicinski
2026-10-27 23:49 ` [PATCH net 1/5] eth: bnxt: recycle agg buffers when Rx head buffer allocation fails Jakub Kicinski
2026-10-28 6:58 ` Michael Chan
2026-10-28 23:52 ` netdev-bot+sashiko
2026-10-29 0:49 ` Jakub Kicinski
2026-10-27 23:49 ` [PATCH net 2/5] eth: bnxt: resize Rx head buffers when rx-copybreak changes Jakub Kicinski
2026-10-28 23:52 ` netdev-bot+sashiko
2026-10-29 0:58 ` Jakub Kicinski
2026-10-29 5:32 ` Michael Chan
2026-10-27 23:49 ` [PATCH net 3/5] eth: bnxt: don't leak buffers when XDP agg buffer allocation fails Jakub Kicinski
2026-10-27 23:49 ` [PATCH net 4/5] eth: bnxt: free XDP frags when xdp_do_redirect() fails Jakub Kicinski
2026-10-29 5:49 ` Michael Chan
2026-10-27 23:49 ` Jakub Kicinski [this message]
2026-10-29 5:59 ` [PATCH net 0/5] eth: bnxt: fix Rx buffer leaks under OOM Michael Chan
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=20261027234940.1267225-6-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=eddie.wai@broadcom.com \
--cc=edumazet@google.com \
--cc=gospo@broadcom.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=huangjw@broadcom.com \
--cc=joe@dama.to \
--cc=john.fastabend@gmail.com \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=prashant@broadcom.com \
--cc=sdf@fomichev.me \
/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