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 v8 11/19] net: ethernet: cortina: Validate RX fragment lengths
Date: Mon, 16 Nov 2026 14:45:49 +0000 [thread overview]
Message-ID: <179484034918.3136.1025801687896166519@kernel.org> (raw)
In-Reply-To: <20261112-gemini-ethernet-fixes-3-v8-11-f55bd43e02d3@kernel.org>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In drivers/net/ethernet/cortina/gemini.c, gmac_rx() calls
gmac_skb_if_good_frame() on the SOF descriptor.
--
net: ethernet: cortina: Validate RX fragment lengths
This patch adds checks in gmac_rx() so that an RX fragment cannot run
past its posted free queue fragment or past the page. Zero-length
non-final descriptors are now dropped, and an empty EOF descriptor
completes the frame that is already assembled.
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 72d2c002f8fc2..364504c9d441a 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]
Is this frame now counted as both received and dropped?
By the time this check runs, gmac_skb_if_good_frame() has already counted
the frame as received:
drivers/net/ethernet/cortina/gemini.c:gmac_skb_if_good_frame() {
...
update_exit:
port->stats.rx_bytes += frame_len;
port->stats.rx_packets++;
return skb;
}
err_drop then frees the skb and increments rx_dropped. The dropping flag
was reset to false on SOF, so that increment always happens:
err_drop:
if (skb) {
napi_free_frags(&port->napi);
...
if (!dropping) {
port->stats.rx_dropped++;
dropping = true;
}
Nothing takes back the earlier rx_packets and rx_bytes increments. The
rx_bytes value also comes from the hardware byte_count, which this patch
otherwise treats as untrusted.
The other new paths into err_drop that this patch adds later in gmac_rx()
do the same thing:
- the frame_len < ETH_ZLEN || frame_len < skb->len check on EOF
- the zero-length non-final descriptor
- the freeq_frag_len / PAGE_SIZE bounds check
The commit message says:
Account descriptor inconsistencies as drops rather than wire length
errors.
Is that accurate, given that these frames also show up in rx_packets and
rx_bytes?
The napi_get_frags() failure path and failures on later descriptors
already double count like this. This patch adds more ways to reach it. The
problem is also still there at the end of the series: "net: ethernet:
cortina: Scope RX statistics updates" only wraps the same update_exit
increments in u64_stats_update_begin()/u64_stats_update_end().
Could the rx_packets/rx_bytes update move to the napi_gro_frags()
completion point instead?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-gemini-ethernet-fixes-3-v8-0-f55bd43e02d3%40kernel.org
next prev parent reply other threads:[~2026-11-16 14:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 13:30 [PATCH net-next v8 00/19] net: ethernet: cortina: Fix Gemini RX/TX buffer management Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 01/19] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 02/19] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 03/19] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 04/19] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 05/19] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 06/19] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 07/19] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 08/19] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 09/19] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 11/19] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko [this message]
2026-11-12 13:30 ` [PATCH net-next v8 12/19] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 13/19] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 14/19] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 15/19] net: ethernet: cortina: Serialize TX completion statistics Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 16/19] net: ethernet: cortina: Scope RX statistics updates Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 17/19] net: ethernet: cortina: Drain RX coalescing timer on stop Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 18/19] net: ethernet: cortina: Reject TX rings smaller than retained pointers Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 19/19] net: ethernet: cortina: Fix ethtool statistics reads Linus Walleij
2026-11-16 14:45 ` netdev-bot+sashiko
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=179484034918.3136.1025801687896166519@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