Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: antonio@mandelbit.com
Cc: netdev@vger.kernel.org,
	subash.a.kasiviswanathan@oss.qualcomm.com,
	sean.tranchetti@oss.qualcomm.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, dnlplm@gmail.com,
	koen.vandeputte@citymesh.com, Jeremy.Jean@oss.cyber.gouv.fr
Subject: Re: [PATCH net-next v2 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it
Date: Sat, 28 Nov 2026 15:39:12 +0000	[thread overview]
Message-ID: <179588035206.3135.9208603226356983404@kernel.org> (raw)
In-Reply-To: <20261127150827.785753-2-antonio@mandelbit.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

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 rmnet_map_tx_aggregate()
  (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c), the retry path…
- [Medium] In rmnet_map_tx_aggregate()
  (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c), the flush-and-…

--

net: qualcomm: rmnet: recheck the aggregate after flushing it

This commit moves the new_packet label in rmnet_map_tx_aggregate() so that
it sits before the skbagg_head check. When the pending aggregate is flushed
with agg_lock dropped, the retry now sees any aggregate another CPU started
in the meantime. Before, that aggregate could be overwritten and leaked.

> diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
> index 7ee2bc33433f6..048a6a35ea28f 100644
> --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
> +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
> @@ -597,11 +597,11 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
>  	memcpy(&last, &port->agg_last, sizeof(struct timespec64));
>  	ktime_get_real_ts64(&port->agg_last);
>  
> +new_packet:

[Severity: Medium]
With the label here, the retry can reach the existing-aggregate branch
holding an aggregate that another CPU created while agg_lock was dropped.
Are the timestamps still valid at that point?

port->agg_last is refreshed only once, at function entry, above the label.
Consider this sequence:

CPU A
  rmnet_map_tx_aggregate()
    flushes the aggregate, spin_unlock_bh(&port->agg_lock)

CPU B
  rmnet_map_tx_aggregate()
    ktime_get_real_ts64(&port->agg_last);   /* tB */
    port->skbagg_head = skb_copy_expand(...);
    ktime_get_real_ts64(&port->agg_time);   /* tB' > tB */

CPU A
    spin_lock_bh(&port->agg_lock);
    goto new_packet;
    ...
    diff = timespec64_sub(port->agg_last, port->agg_time);

Here diff is tB - tB', which is negative. set_normalized_timespec64() turns
it into tv_sec = -1 and tv_nsec close to 1e9. For any time_nsec under about
one second, that makes this check true:

	if (diff.tv_sec > 0 || diff.tv_nsec > port->egress_agg_params.time_nsec ||

Would CPU B's new aggregate then be flushed as soon as CPU A's skb is
appended, while it holds only two packets?

The !skbagg_head branch has a similar problem on retry. It compares
port->agg_last against CPU A's entry-time last, and another CPU may have
changed agg_last in the meantime.

Could the label go before the memcpy(&last, ...) and
ktime_get_real_ts64(&port->agg_last) pair, so the timestamps are refreshed
on each retry?

>  	if (!port->skbagg_head) {
>  		/* Check to see if we should agg first. If the traffic is very
>  		 * sparse, don't aggregate.
>  		 */
> -new_packet:

[Severity: Medium]
Does the flush-and-retry path now become a loop with no bound?

Before this patch, goto new_packet jumped into the body of
if (!port->skbagg_head), so there was at most one retry. Now each retry
runs the full check again, and this branch in rmnet_map_tx_aggregate() can
be taken again:

	if (port->skbagg_head->len >= port->egress_agg_params.bytes ||
	    skb->len > port->egress_agg_params.bytes - port->skbagg_head->len) {
		agg_skb = port->skbagg_head;
		reset_aggr_params(port);
		spin_unlock_bh(&port->agg_lock);
		hrtimer_cancel(&port->hrtimer);
		rmnet_send_skb(port, agg_skb);
		spin_lock_bh(&port->agg_lock);
		goto new_packet;
	}

Each pass drops agg_lock and transmits through rmnet_send_skb(). In that
window, other CPUs sending through other lltx vnds on the same port can
start a new aggregate.

Take a large skb, for example 4000 bytes with tx-aggr-max-bytes 4096. It
fails the fit check against any head larger than 96 bytes. Could one sender
then keep flushing other CPUs' aggregates for as long as they keep sending?
All of this runs in the ndo_start_xmit path with BH disabled, and the
sender's own skb never gets queued.

Would it help to bound this? For example, the skb could be sent through
no_aggr, or only one retry could be allowed if the skb still does not fit
after a flush.

>  		diff = timespec64_sub(port->agg_last, last);
>  		size = port->egress_agg_params.bytes;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127150827.785753-1-antonio%40mandelbit.com

  reply	other threads:[~2026-11-28 15:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 15:08 [PATCH net-next v2 0/3] net: qualcomm: rmnet: fix TX aggregation bugs Antonio Quartulli
2026-11-27 15:08 ` [PATCH net-next v2 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it Antonio Quartulli
2026-11-28 15:39   ` netdev-bot+sashiko [this message]
2026-11-27 15:08 ` [PATCH net-next v2 2/3] net: qualcomm: rmnet: always arm the flush timer for a new aggregate Antonio Quartulli
2026-11-27 15:08 ` [PATCH net-next v2 3/3] net: qualcomm: rmnet: fix TX aggregation timeout overflow on 32-bit Antonio Quartulli
2026-11-27 15:14 ` [PATCH net-next v2 0/3] net: qualcomm: rmnet: fix TX aggregation bugs netdev-bot+sinfo
2026-11-27 15:16   ` Antonio Quartulli

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=179588035206.3135.9208603226356983404@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Jeremy.Jean@oss.cyber.gouv.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=antonio@mandelbit.com \
    --cc=davem@davemloft.net \
    --cc=dnlplm@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=koen.vandeputte@citymesh.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sean.tranchetti@oss.qualcomm.com \
    --cc=subash.a.kasiviswanathan@oss.qualcomm.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