Thread View: linux.kernel.netdev
8 messages
8 total messages
Started by Antonio Quartulli
Fri, 27 Nov 2026 15:08
[PATCH net-next v2 0/3] net: qualcomm: rmnet: fix TX aggregation bugs
Author: Antonio Quartulli
Date: Fri, 27 Nov 2026 15:08
Date: Fri, 27 Nov 2026 15:08
29 lines
10061 bytes
10061 bytes
Fixes for rmnet TX aggregation bugs still present in net-next. Each
commit message includes a reproducer; all three were reproduced in a VM
(KASAN, kmemleak, DEBUG_OBJECTS) before the fix and are gone after it.
Patch 2 needs a debug udelay() to widen the race window, patch 3 a
32-bit kernel.
Patches 1 and 2 build on 7bcccc40cdb5 ("net: qualcomm: rmnet: bound TX
aggregates on byte-limit update"), which touches the same lines.
Changes in v2:
- drop patches 4-6, already fixed in net-next by 0af0e210b5bd and
4f89bcfa1e16
- rebase on and retarget to net-next like the related fixes
v1: https://lore.kernel.org/netdev/20261126163219.1744750-1-antonio@mandelbit.com/
Antonio Quartulli (3):
net: qualcomm: rmnet: recheck the aggregate after flushing it
net: qualcomm: rmnet: always arm the flush timer for a new aggregate
net: qualcomm: rmnet: fix TX aggregation timeout overflow on 32-bit
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
base-commit: ccb81d5e317b0ae2cc66ca1c628c0ca907928f94
--
2.56.1
[PATCH net-next v2 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it
Author: Antonio Quartulli
Date: Fri, 27 Nov 2026 15:08
Date: Fri, 27 Nov 2026 15:08
48 lines
11177 bytes
11177 bytes
When an skb does not fit in the pending aggregate,
rmnet_map_tx_aggregate() flushes it with agg_lock dropped, then jumps
back past the skbagg_head check. rmnet vnds are lltx and can share a
port, so another CPU may start an aggregate meanwhile: it is then
overwritten and leaked along with the packets chained to it, or
overtaken by a skb sent without aggregation.
Reproducer, with UDP sent through both vnds from several CPUs:
ip link add v0 mtu 9000 type veth peer name v1 mtu 9000
ip link set v0 up; ip link set v1 up
ip link add link v0 name rmnet1 type rmnet mux_id 1
ip link add link v0 name rmnet2 type rmnet mux_id 2
ethtool -C rmnet1 tx-aggr-max-frames 64 tx-aggr-max-bytes 4096 \
tx-aggr-time-usecs 2000
The tx_bytes of rmnet1 and rmnet2 stay above those of v0 after the flush
timeout, and kmemleak reports skbs allocated by skb_copy_expand() in
rmnet_map_tx_aggregate().
Move the label before the skbagg_head check.
Fixes: 64b5d1f8f2d1 ("net: qualcomm: rmnet: add tx packets aggregation")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 7ee2bc33433f..048a6a35ea28 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:
if (!port->skbagg_head) {
/* Check to see if we should agg first. If the traffic is very
* sparse, don't aggregate.
*/
-new_packet:
diff = timespec64_sub(port->agg_last, last);
size = port->egress_agg_params.bytes;
--
2.56.1
[PATCH net-next v2 2/3] net: qualcomm: rmnet: always arm the flush timer for a new aggregate
Author: Antonio Quartulli
Date: Fri, 27 Nov 2026 15:08
Date: Fri, 27 Nov 2026 15:08
61 lines
12013 bytes
12013 bytes
On flush, rmnet_map_tx_aggregate() resets agg_state and drops agg_lock
before cancelling the flush timer. A CPU starting a new aggregate in
that window finds the old timer active, so it neither arms it nor sets
agg_state. Once the old timer is cancelled, the new aggregate waits for
the next packet; if the port is torn down first,
rmnet_map_tx_aggregate_exit() leaks it because agg_state is not
-EINPROGRESS.
To make reproducing this bug easier, a udelay(2000) was added
after agg_lock is dropped in the flush paths. Then, with two vnds on one
port, tx-aggr-max-frames 2 and tx-aggr-time-usecs 100000, one CPU sends
3 packets on the first vnd (bypass, new aggregate, flush) and another
sends 1 packet on the second vnd 0.5 ms later: that packet stays queued
past the timeout.
Cancel the timer under agg_lock, so a timer armed for a newer aggregate
cannot be cancelled, and arm it whenever agg_state is not -EINPROGRESS;
hrtimer_start() copes with a timer that is still enqueued or running.
If the cancel races with a running callback, the flush work it queued
finds either no aggregate or the new one, which it flushes early.
Fixes: 64b5d1f8f2d1 ("net: qualcomm: rmnet: add tx packets aggregation")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 048a6a35ea28..033699aa0385 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -632,8 +632,8 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
skb->len > port->egress_agg_params.bytes - port->skbagg_head->len) {
agg_skb = port->skbagg_head;
reset_aggr_params(port);
+ hrtimer_try_to_cancel(&port->hrtimer);
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;
@@ -655,14 +655,14 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
port->skbagg_head->len == port->egress_agg_params.bytes) {
agg_skb = port->skbagg_head;
reset_aggr_params(port);
+ hrtimer_try_to_cancel(&port->hrtimer);
spin_unlock_bh(&port->agg_lock);
- hrtimer_cancel(&port->hrtimer);
rmnet_send_skb(port, agg_skb);
return len;
}
schedule:
- if (!hrtimer_active(&port->hrtimer) && port->agg_state != -EINPROGRESS) {
+ if (port->agg_state != -EINPROGRESS) {
port->agg_state = -EINPROGRESS;
hrtimer_start(&port->hrtimer,
ns_to_ktime(port->egress_agg_params.time_nsec),
--
2.56.1
[PATCH net-next v2 3/3] net: qualcomm: rmnet: fix TX aggregation timeout overflow on 32-bit
Author: Antonio Quartulli
Date: Fri, 27 Nov 2026 15:08
Date: Fri, 27 Nov 2026 15:08
33 lines
10464 bytes
10464 bytes
On 32-bit, time * NSEC_PER_USEC is computed in 32 bits before being
stored in the u64 time_nsec, so a tx-aggr-time-usecs above 4294967
wraps: 5000000 is stored as 705032704 ns and read back as 705032.
Reproducer:
ethtool -C rmnet0 tx-aggr-max-frames 64 tx-aggr-time-usecs 5000000
ethtool -c rmnet0
Do the multiplication in 64 bits.
Fixes: 64b5d1f8f2d1 ("net: qualcomm: rmnet: add tx packets aggregation")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 033699aa0385..46dcfba86b3f 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -686,7 +686,7 @@ void rmnet_map_update_ul_agg_config(struct rmnet_port *port, u32 size,
spin_lock_bh(&port->agg_lock);
port->egress_agg_params.bytes = size;
WRITE_ONCE(port->egress_agg_params.count, count);
- port->egress_agg_params.time_nsec = time * NSEC_PER_USEC;
+ port->egress_agg_params.time_nsec = (u64)time * NSEC_PER_USEC;
spin_unlock_bh(&port->agg_lock);
}
--
2.56.1
Re: [PATCH net-next v2 0/3] net: qualcomm: rmnet: fix TX aggregation bugs
Author: netdev-bot+sinfo
Date: Fri, 27 Nov 2026 15:14
Date: Fri, 27 Nov 2026 15:14
19 lines
8703 bytes
8703 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net-next v2 0/3] net: qualcomm: rmnet: fix TX aggregation bugs
Author: Antonio Quartulli
Date: Fri, 27 Nov 2026 15:16
Date: Fri, 27 Nov 2026 15:16
24 lines
10100 bytes
10100 bytes
On 27/11/2026 16:14, netdev-bot+sinfo@kernel.org wrote: > Hi! > > This is an automated message. This series looks like a fix, but its > commit messages seem to be missing some information: > > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. Bugs were identified while reviewing [1]. They were then reproduced with AI assistance and fixed. [1] https://lore.kernel.org/netdev/20261002143529.3217189-1-koen.vandeputte@citymesh.com/ -- Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
Re: [PATCH net-next v2 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it
Author: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 15:39
Date: Sat, 28 Nov 2026 15:39
122 lines
12671 bytes
12671 bytes
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
Re: [PATCH net-next v2 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it
Author: Antonio Quartulli
Date: Mon, 30 Nov 2026 13:37
Date: Mon, 30 Nov 2026 13:37
36 lines
10234 bytes
10234 bytes
Hi, On 28/11/2026 16:39, netdev-bot+sashiko@kernel.org wrote: > 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-… > Yeah, although minor, both are valid.. Will spin v3. Regards, pw-bot: cr -- Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads