From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, rafal@milecki.pl,
bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, horms@kernel.org, corbet@lwn.net,
jonas.gorski@gmail.com, olteanv@gmail.com, pablo@netfilter.org,
fw@strlen.de, phil@nwl.cc, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org
Subject: Re: [PATCH net-next 1/9] net: ethernet: bgmac: validate RX length against the DMA packet capacity
Date: Tue, 17 Nov 2026 23:29:15 +0000 [thread overview]
Message-ID: <179495815587.3136.10288920701294421777@kernel.org> (raw)
In-Reply-To: <20261116222519.1416501-2-florian.fainelli@broadcom.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1
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] In bgmac_dma_rx_read()
(drivers/net/ethernet/broadcom/bgmac.c:463), the patch now treats…
- [Low] The commit message is accurate but leaves out the user-visible
impact of the bugs this patch fixes in bgmac_dma_rx_read().
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is High
severity, and the new check does not close it.
--
net: ethernet: bgmac: validate RX length against the DMA packet capacity
This patch changes the upper bound of the RX length check in
bgmac_dma_rx_read() from BGMAC_RX_ALLOC_SIZE to BGMAC_RX_MAX_FRAME_SIZE.
It also rejects lengths shorter than ETH_FCS_LEN. Invalid lengths are
reported through a rate-limited netdev_err() and counted in rx_length_errors
and rx_errors.
> BGMAC_RX_ALLOC_SIZE includes skb_shared_info and alignment space beyond
> the DMA receive buffer. An invalid completion length can pass that check
> and reach skb_put() with more data than the skb tailroom permits.
>
> Limit received frames to BGMAC_RX_MAX_FRAME_SIZE and reject lengths too
> short for the FCS subtraction.
[Severity: Low]
This isn't a bug, but could the commit message state the user-visible
impact of what is being fixed?
For len < ETH_FCS_LEN, the u16 subtraction "len -= ETH_FCS_LEN" wraps to
65532..65535. The skb_put() that follows then ends in skb_over_panic() and
BUG().
Lengths between the skb tailroom limit (about 1602 bytes with
NET_SKB_PAD=64) and BGMAC_RX_ALLOC_SIZE also reach skb_over_panic().
Lengths from 1537 up to that tailroom limit got through skb_put(). They
delivered bytes past the 1536-byte DMA-mapped frame area. Those bytes come
from the non-zeroed netdev_alloc_frag() buffer, and the device never wrote
them.
The message names the tailroom and FCS cases. It does not say that they
end in a kernel BUG(), and it does not mention the stale data delivery.
> diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
> index 9ef239bc487d7..1c502bd64d7df 100644
> --- a/drivers/net/ethernet/broadcom/bgmac.c
> +++ b/drivers/net/ethernet/broadcom/bgmac.c
> @@ -457,10 +457,14 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
> break;
> }
>
> - if (len > BGMAC_RX_ALLOC_SIZE) {
> + /* The allocation also contains headroom and skb_shared_info;
> + * only the mapped packet area may be supplied by the DMA.
> + */
> + if (unlikely(len > BGMAC_RX_MAX_FRAME_SIZE || len < ETH_FCS_LEN)) {
> if (net_ratelimit())
> - netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
> - ring->start);
> + netdev_err(bgmac->net_dev,
> + "Invalid RX length %u at slot %d (flags %#x)\n",
> + len, ring->start, flags);
[Severity: Medium]
Does this new bound drop frames that the driver itself tells the MAC to
accept, and whose MTU it advertises?
bgmac_chip_init() sets the MAC max frame length to 1550:
bgmac_umac_write(bgmac, UMAC_MAX_FRAME_LEN, 32 + ETHER_MAX_LEN);
bgmac_change_mtu() sets it to 32 + mtu, which can be as large as 1564:
bgmac_umac_write(bgmac, UMAC_MAX_FRAME_LEN, 32 + mtu);
bgmac_enet_probe() sets max_mtu without subtracting ETH_HLEN or VLAN_HLEN:
net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE - ETH_FCS_LEN;
The driver accepts any MTU from 1519 to 1532. At those MTUs a full-sized
frame can be up to 14 + 1532 + 4 = 1550 bytes. Such a frame is now always
dropped, logged as an invalid RX length, and counted in rx_length_errors.
Before this patch these frames were delivered with stale tail bytes, so
dropping them is safer. However, the new comment and the commit message
assume that len > BGMAC_RX_MAX_FRAME_SIZE can only come from a DMA error.
Should max_mtu and/or UMAC_MAX_FRAME_LEN also be clamped to the
per-descriptor capacity? One option for max_mtu is
BGMAC_RX_MAX_FRAME_SIZE - ETH_HLEN - ETH_FCS_LEN, possibly minus VLAN_HLEN.
Could the commit message also mention that these frames are now dropped?
[Severity: High]
This is a pre-existing issue, and the new check does not appear to close
it. Can a remote sender get stale buffer contents delivered as a received
frame through an overflow-continue slot?
bgmac_dma_rx_ring_enable() turns on overflow-continue:
ctl |= BGMAC_DMA_RX_OVERFLOW_CONT;
Each descriptor holds only BGMAC_RX_BUF_SIZE, which is 30 + 1536 bytes.
The MAC accepts frames up to 1550 bytes by default, and up to 1564 bytes
after an MTU change.
With overflow-continue, the DMA64 engine writes the rest of an oversized
frame as raw data at offset 0 of the next descriptor's buffer. That buffer
has no RX status header. brcmsmac's dma_rx() drives the same engine with
the same 0x400 bit, and it handles these continuation buffers explicitly:
resid = len - (di->rxbufsize - di->rxoffset);
...
while ((resid > 0) && (p = _dma_getnextrxp(di, false))) {
pkt_len = min_t(uint, resid, di->rxbufsize);
bgmac_dma_rx_read() treats every slot as an independent frame. The new
check drops the first slot when len > 1536. The next slot is then parsed
as a fresh frame:
len = le16_to_cpu(rx->len);
flags = le16_to_cpu(rx->flags);
In that slot, rx->len and rx->flags are frame bytes 1536..1539, which the
sender controls. A value in [4, 1536] passes both the poison check and the
new bound. build_skb() and skb_put() then deliver up to about 1532 bytes
starting at buffer offset 30.
DMA wrote only the first (frame_len - 1536) bytes of that buffer in this
round, which is at most 28 bytes. The rest is stale netdev_alloc_frag()
memory, because bgmac_dma_rx_skb_for_slot() only writes the poison header.
The resulting skb goes to eth_type_trans() and napi_gro_receive(). From
there it can be processed locally, bridged, or forwarded.
The old BGMAC_RX_ALLOC_SIZE check let through an even wider range of
lengths. This patch narrows that range but does not remove it.
Could multi-descriptor frames be tracked so the continuation slots are
dropped too? Alternatively, could UMAC_MAX_FRAME_LEN and max_mtu be capped
at the single-buffer capacity?
> put_page(virt_to_head_page(buf));
> bgmac->net_dev->stats.rx_length_errors++;
> bgmac->net_dev->stats.rx_errors++;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116222519.1416501-1-florian.fainelli%40broadcom.com
next prev parent reply other threads:[~2026-11-17 23:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 22:25 [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 1/9] net: ethernet: bgmac: validate RX length against the DMA packet capacity Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko [this message]
2026-11-17 23:43 ` Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 2/9] netfilter: flowtable: reject non-host IPv4 packets before lookup Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 3/9] netfilter: flowtable: retain offload ownership until deletion completes Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 4/9] dt-bindings: net: describe the Northstar flow accelerator Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 5/9] net: dsa: add Broadcom FA metadata and IPv4 exception paths Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 7/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 8/9] net: add KUnit coverage for FA and flowtable path validation Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 9/9] docs: net: document Northstar FA setup and NAT qualification Florian Fainelli
2026-11-17 23:29 ` netdev-bot+sashiko
2026-11-16 22:38 ` [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload netdev-bot+sinfo
2026-11-16 22:45 ` Florian Fainelli
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=179495815587.3136.10288920701294421777@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=jonas.gorski@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=rafal@milecki.pl \
--cc=robh@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