From: netdev-bot+sashiko@kernel.org
To: linusw@kernel.org
Cc: ulli.kroll@googlemail.com, andrew+netdev@lunn.ch,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
mirq-linux@rere.qmqm.pl, mhun512@gmail.com, edumazet@kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next v9 11/14] net: ethernet: cortina: Validate RX fragment lengths
Date: Tue, 24 Nov 2026 18:29:56 +0000 [thread overview]
Message-ID: <179554499621.3135.11543355488056577743@kernel.org> (raw)
In-Reply-To: <20261120-gemini-ethernet-fixes-3-v9-11-298671d799d5@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] The patch treats two descriptor layouts inconsistently.
- [Low] The patch fixes descriptor-length bugs that date back to the
driver's initial commit, but it has no Fixes: tag and no Cc: stable.
- [Low] net: ethernet: cortina: double-counted RX stats on err_drop in
gmac_rx()
--
net: ethernet: cortina: Validate RX fragment lengths
This patch adds bounds checks on RX descriptor lengths in gmac_rx(), so a
fragment can no longer underflow or run past the posted free queue
fragment or the page. Zero-length non-final descriptors are now dropped.
An EOF descriptor that carries no new data now completes the frame that
has already been assembled.
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 8431f0a2e34a4..fe23ef8be9e51 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
[ ... ]
> @@ -1864,6 +1865,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
> if (!skb)
> goto err_drop;
>
> + if (frag_len < NET_IP_ALIGN)
> + goto err_drop;
> +
> page_offs += NET_IP_ALIGN;
> frag_len -= NET_IP_ALIGN;
> frag_nr = 0;
[Severity: Low]
Should this patch have a Fixes: tag, and possibly Cc: stable?
According to git blame, all of the following come from the initial driver
commit:
- the unchecked frag_len -= NET_IP_ALIGN above
- the frag_len = frame_len - skb->len underflow at EOF
- the skb_fill_page_desc() append of zero-length or oversized fragments
So the tag would be:
Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Without the tag, stable tooling cannot tell which trees need this fix.
> @@ -1872,15 +1876,33 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
> goto err_drop;
> }
>
> - if (word3.bits32 & EOF_BIT)
> + if (word3.bits32 & EOF_BIT) {
> + if (frame_len < ETH_ZLEN ||
> + frame_len < skb->len)
> + goto err_drop;
> frag_len = frame_len - skb->len;
> + }
> +
> + if (!frag_len) {
> + if (word3.bits32 & EOF_BIT) {
> + put_page(page);
> + page = NULL;
> + goto complete_frame;
> + }
[Severity: Low]
Does this count rejected frames twice in the interface statistics?
gmac_skb_if_good_frame() is called on the SOF descriptor. On success it
falls through to update_exit, which does:
port->stats.rx_bytes += frame_len;
port->stats.rx_packets++;
That happens before gmac_rx() runs any of the new checks. The chain can
still be rejected afterwards by one of them:
- frag_len < NET_IP_ALIGN on the SOF descriptor
- frame_len < ETH_ZLEN or frame_len < skb->len at EOF
- a zero-length non-EOF descriptor
- frag_len running past the free queue fragment or the page
In each case the code goes to err_drop. That frees the skb with
napi_free_frags() and increments port->stats.rx_dropped. The earlier
rx_packets and rx_bytes increments are left in place.
So the same frame shows up as both received and dropped. rx_bytes also
includes a byte_count that gmac_rx() has just judged inconsistent.
The commit message says descriptor inconsistencies are now accounted as
drops, but they are still counted as received as well.
Should the rx_packets and rx_bytes accounting move to the complete_frame
path? Then it would only happen once the frame is actually handed to
napi_gro_frags().
The existing MAX_SKB_FRAGS drop and the restarted-SOF drop already have
the same problem. This patch adds several more ways to reach it.
[Severity: Medium]
Are these two EOF cases handled consistently?
The empty EOF path delivers the frame when frame_len == skb->len at EOF.
For a valid frame, this seems possible only if two things are true:
- the GMAC writes trailing bytes that byte_count does not count (probably
the 4-byte FCS) into the free queue buffers
- buffer_size in the earlier descriptors includes those bytes
If the hardware works that way, the trailing bytes could also straddle a
buffer boundary. gmac_start_dma() sets:
dma_ctrl.bits.rd_insert_bytes = NET_IP_ALIGN;
Take 2048-byte fragments and a jumbo frame with byte_count 2044. The first
buffer would be full: buffer_size is 2048, and frag_len is 2046 after the
NET_IP_ALIGN adjustment, which includes 2 FCS bytes. The other 2 FCS bytes
land in the EOF buffer.
At EOF, frame_len (2044) < skb->len (2046). Wouldn't this valid, CRC-good
frame then go to err_drop and be counted in rx_dropped?
Could the last appended fragment be trimmed by skb->len - frame_len, and
the frame completed, instead?
Frames only span several descriptors with jumbo MTUs. The driver supports
them: max_mtu is MTU_SIZE_BIT_MASK - VLAN_ETH_HLEN, and
gmac_pick_rx_max_len() allows 9212 and 10236. Testing at the default MTU
would not hit this case.
If the hardware does behave this way, a 3-byte window of frame sizes just
below each 2048-byte boundary would always be dropped. Whether buffer_size
counts bytes that byte_count leaves out is defined only by the Gemini
datasheet.
> +
> + if (net_ratelimit())
> + netdev_err(netdev,
> + "Received fragment with len = 0\n");
> + goto err_drop;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5%40kernel.org
next prev parent reply other threads:[~2026-11-24 18:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:29 [PATCH net-next v9 00/14] net: ethernet: cortina: Fix Gemini RX buffer management Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 01/14] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 02/14] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 03/14] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 04/14] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 05/14] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 06/14] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 07/14] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 08/14] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 09/14] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 10/14] net: ethernet: cortina: Separate RX buffer capacity from free queue size Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 11/14] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko [this message]
2026-11-20 17:29 ` [PATCH net-next v9 12/14] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 13/14] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 14/14] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
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=179554499621.3135.11543355488056577743@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=mhun512@gmail.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ulli.kroll@googlemail.com \
/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