Thread View: linux.kernel.netdev
6 messages
6 total messages
Started by Antonio Quartulli
Thu, 26 Nov 2026 16:32
[PATCH net 0/6] net: qualcomm: rmnet: fix TX aggregation and teardown bugs
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:32
Date: Thu, 26 Nov 2026 16:32
31 lines
10171 bytes
10171 bytes
Bugs in rmnet TX aggregation and bridge teardown, found while
reviewing [1]. Each commit message includes a reproducer.
All 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.
Although this patchset is targeting net, the described reproducers
should help maintainers understandsing if patches should rather be
demoted to net-next material...
Regards,
[1] https://lore.kernel.org/netdev/20261002143529.3217189-1-koen.vandeputte@citymesh.com/
Antonio Quartulli (6):
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
net: qualcomm: rmnet: stop TX aggregation after detaching the port
net: qualcomm: rmnet: account linearization failures on the real
device
net: qualcomm: rmnet: unlink the bridge from the vnd it is attached to
.../net/ethernet/qualcomm/rmnet/rmnet_config.c | 7 ++++---
.../net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 15 ++++++---------
2 files changed, 10 insertions(+), 12 deletions(-)
--
2.56.1
[PATCH net 2/6] net: qualcomm: rmnet: always arm the flush timer for a new aggregate
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:32
Date: Thu, 26 Nov 2026 16:32
60 lines
11880 bytes
11880 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, and 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 73b04fe386df..fdfc65c7c5e5 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -635,8 +635,8 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
if (skb->len > size) {
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;
@@ -658,14 +658,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 3/6] net: qualcomm: rmnet: fix TX aggregation timeout overflow on 32-bit
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:32
Date: Thu, 26 Nov 2026 16:32
33 lines
10443 bytes
10443 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 fdfc65c7c5e5..b156e864535f 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -689,7 +689,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
[PATCH net 5/6] net: qualcomm: rmnet: account linearization failures on the real device
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:32
Date: Thu, 26 Nov 2026 16:32
48 lines
11150 bytes
11150 bytes
When the real device lacks NETIF_F_FRAGLIST and linearizing an
aggregate fails, rmnet_send_skb() counts the drop on port->rmnet_dev.
That is the vnd created last on the port, never updated when it is
deleted, so it may point to a freed net_device.
The aggregate head is sized for tx-aggr-max-bytes, so linearizing only
allocates when that limit grows while an aggregate is pending.
Reproducer:
ip link add v0 mtu 16000 type veth peer name v1 mtu 16000
ethtool -K v0 tx-scatter-gather-fraglist off
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-time-usecs 2000
ip link del rmnet2
then flood UDP through rmnet1 with failslab on the senders (task-filter,
probability 10) while switching tx-aggr-max-bytes between 512 and
12288. KASAN reports a use-after-free in rmnet_send_skb().
Count the drop on the real device, where it happens: the aggregate may
hold packets from any vnd.
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 | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index b156e864535f..3de093198474 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -543,10 +543,7 @@ static void rmnet_send_skb(struct rmnet_port *port, struct sk_buff *skb)
{
if (skb_needs_linearize(skb, port->dev->features)) {
if (unlikely(__skb_linearize(skb))) {
- struct rmnet_priv *priv;
-
- priv = netdev_priv(port->rmnet_dev);
- this_cpu_inc(priv->pcpu_stats->stats.tx_drops);
+ dev_core_stats_tx_dropped_inc(port->dev);
dev_kfree_skb_any(skb);
return;
}
--
2.56.1
[PATCH net 6/6] net: qualcomm: rmnet: unlink the bridge from the vnd it is attached to
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:32
Date: Thu, 26 Nov 2026 16:32
54 lines
11166 bytes
11166 bytes
When the real device of a bridged port is unregistered or moved to
another netns, rmnet_unregister_bridge() unlinks the bridge device from
the real port's rmnet_dev: the vnd created last, never updated when it
is deleted. If the newest vnd was deleted before attaching the bridge to
the remaining one, the unlink reads and writes the freed net_device,
the actual bridge link is left in place and unregistering the vnd hangs
on its references.
Reproducer:
ip link add v0 type veth peer name v1
ip link add v2 type veth peer name v3
ip link set v0 up; ip link set v2 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
ip link del rmnet2
ip link set v2 master rmnet1
ip link del v0
Take the vnd from the bridge device's port, which records the one it is
attached to.
Fixes: d939b6d30bea ("net: rmnet: fix bridge mode bugs")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 2ff4b9519139..96129101e477 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -96,9 +96,9 @@ static void rmnet_unregister_bridge(struct rmnet_port *port)
if (port->rmnet_mode != RMNET_EPMODE_BRIDGE)
return;
- rmnet_dev = port->rmnet_dev;
if (!port->nr_rmnet_devs) {
/* bridge device */
+ rmnet_dev = port->rmnet_dev;
real_dev = port->bridge_ep;
bridge_dev = port->dev;
@@ -108,6 +108,7 @@ static void rmnet_unregister_bridge(struct rmnet_port *port)
} else {
/* real device */
bridge_dev = port->bridge_ep;
+ rmnet_dev = rmnet_get_port_rtnl(bridge_dev)->rmnet_dev;
port->bridge_ep = NULL;
port->rmnet_mode = RMNET_EPMODE_VND;
--
2.56.1
Re: [PATCH net 0/6] net: qualcomm: rmnet: fix TX aggregation and teardown bugs
Author: Antonio Quartulli
Date: Thu, 26 Nov 2026 16:47
Date: Thu, 26 Nov 2026 16:47
31 lines
10046 bytes
10046 bytes
Hi,
I just realized that patches 4, 5 and 6 duplicate fixes already in
net-next, which I missed (they are not in net yet):
4/6 == 0af0e210b5bd ("net: qualcomm: rmnet: fix TX aggregation
teardown race")
5/6, 6/6 are covered by 4f89bcfa1e16 ("net: qualcomm: rmnet: avoid
stale VND access on TX drop")
Therefore they can be dropped.
Patches 1-3 fix bugs still present in net-next, but 1 and 2 conflict
with 7bcccc40cdb5 ("net: qualcomm: rmnet: bound TX aggregates on
byte-limit update").
Since those related fixes went to net-next, I will just resend 1, 2 and
3 rebased on net-next.
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