From: sashiko-bot@kernel.org
To: "Lorenzo Bianconi" <lorenzo.bianconi@oss.qualcomm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v5 2/3] net: stmmac: rework stmmac_rx to support XDP rx multi-buff
Date: Sat, 10 Oct 2026 10:27:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-166431@kernel.org> (raw)
In-Reply-To: <20261009-stmmac-rx-mb-v5-2-c38fa4eaa138@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: stmmac: OOB read in stmmac_rx_zc() for multi-buffer frames
--
commit b6459feb6b07a40586d4710878eea688f9a8b50c
Author: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
net: stmmac: rework stmmac_rx to support XDP rx multi-buff
This commit reworks stmmac_rx to build the xdp_buff by accumulating all
descriptors that make up a frame. This allows the XDP program to run on
the full, possibly fragmented packet instead of just the first buffer. It
lays the groundwork for extending XDP to jumbo frames and SPH.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 6128e6d9504c8..be2cba8fcbc6d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[ ... ]
> @@ -5798,6 +5804,118 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
> return failure ? limit : (int)count;
> }
[Severity: High]
Since this patch series removes the MTU check and enables jumbo frame
support, does it expose an out-of-bounds read in stmmac_rx_zc for
multi-buffer frames?
Looking at stmmac_rx_zc, when AF_XDP Zero-Copy is active and intermediate
fragments are dropped, the len accumulator is not updated:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_rx_zc() {
...
/* XSK pool expects RX frame 1:1 mapped to XSK buffer */
if (likely(status & rx_not_ls)) {
xsk_buff_free(buf->xdp);
buf->xdp = NULL;
dirty++;
count++;
goto read_again;
}
ctx = xsk_buff_to_stmmac_ctx(buf->xdp);
...
buf1_len = stmmac_rx_buf1_len(priv, p, status, len);
len += buf1_len;
...
buf->xdp->data_end = buf->xdp->data + buf1_len;
}
When the final descriptor arrives (status without rx_not_ls), len is
still 0. The stmmac_rx_buf1_len function then calculates
buf1_len = min(dma_buf_sz, plen - 0).
If plen is greater than dma_buf_sz, buf1_len is set to dma_buf_sz, but the
final descriptor only contains the tail bytes of the frame. This gives the
XDP program a buffer length that exceeds the actual data written by DMA,
potentially exposing up to dma_buf_sz of uninitialized XSK UMEM memory.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009-stmmac-rx-mb-v5-0-c38fa4eaa138@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-10-10 10:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 10:26 [PATCH net-next v5 0/3] net: stmmac: introduce XDP rx multi-buff support Lorenzo Bianconi
2026-10-09 10:26 ` [PATCH net-next v5 1/3] net: stmmac: take ownership of saved RX state at poll entry Lorenzo Bianconi
2026-10-10 10:27 ` sashiko-bot
2026-10-10 10:57 ` netdev-bot+sashiko
2026-10-09 10:26 ` [PATCH net-next v5 2/3] net: stmmac: rework stmmac_rx to support XDP rx multi-buff Lorenzo Bianconi
2026-10-10 10:27 ` sashiko-bot [this message]
2026-10-10 10:57 ` netdev-bot+sashiko
2026-10-09 10:26 ` [PATCH net-next v5 3/3] net: stmmac: allow non-linear xdp_buff in XDP mode Lorenzo Bianconi
2026-10-10 10:27 ` sashiko-bot
2026-10-10 10:57 ` netdev-bot+sashiko
2026-10-09 10:30 ` [PATCH net-next v5 0/3] net: stmmac: introduce XDP rx multi-buff support netdev-bot+sinfo
2026-10-09 11:11 ` Lorenzo Bianconi
2026-10-12 20:30 ` Lorenzo Bianconi
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-166431@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox