🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24816

[PATCH net-next v3 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it

#24816
From: Antonio Quartulli
Date: Mon, 30 Nov 2026 22:01
82 lines
12624 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.

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 sum of the tx_bytes of rmnet1 and rmnet2 stays above that 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, and before the timestamps
are taken, so that an aggregate found on retry is not aged against a
stale agg_last and flushed early. Flush at most once per skb: if it
still does not fit the aggregate found on retry, send it without
aggregation (or drop it if it exceeds the byte limit) rather than
flushing again, which could otherwise repeat for as long as other CPUs
keep starting aggregates. A retried skb no longer qualifies for the
sparse-traffic bypass, as an aggregate was just sent.

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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 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..f02ea5d728d0 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -591,9 +591,11 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
 	struct timespec64 diff, last;
 	unsigned int len = skb->len;
 	struct sk_buff *agg_skb;
+	bool flushed = false;
 	unsigned int size;
 
 	spin_lock_bh(&port->agg_lock);
+new_packet:
 	memcpy(&last, &port->agg_last, sizeof(struct timespec64));
 	ktime_get_real_ts64(&port->agg_last);
 
@@ -601,7 +603,6 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
 		/* 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;
 
@@ -630,12 +631,20 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
 	diff = timespec64_sub(port->agg_last, port->agg_time);
 	if (port->skbagg_head->len >= port->egress_agg_params.bytes ||
 	    skb->len > port->egress_agg_params.bytes - port->skbagg_head->len) {
+		if (flushed) {
+			if (skb->len > port->egress_agg_params.bytes) {
+				spin_unlock_bh(&port->agg_lock);
+				return 0;
+			}
+			goto no_aggr;
+		}
 		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);
+		flushed = true;
 		goto new_packet;
 	}
 
-- 
2.56.1
Technical Details
Message-ID: <20261130220200.3378310-2-antonio@mandelbit.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374492-linux-kernel-netdev=dewy.ru
References: <20261130220200.3378310-1-antonio@mandelbit.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374492-linux-kernel-netdev=dewy.ru
From: antonio@mandelbit.com (Antonio Quartulli)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 1/3] net: qualcomm: rmnet: recheck the aggregate after flushing it
Date: Mon, 30 Nov 2026 23:01:58 +0100
Organization: Usenet Network
Message-ID: <20261130220200.3378310-2-antonio@mandelbit.com>
References: <20261130220200.3378310-1-antonio@mandelbit.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1550522"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Tma0pllTRpl073Nzphz0hEkuvUg= sha256:reN2BNXEH3JljuL82kkYLATT3yTdCJhVEnHlXchHSvc=
	sha1:8P3PJE0bBPGdwSV08aoI2nDDCwY= sha256:xUJ2SrtFm9V48kUXaJYwU8bxKvymjZ65rmJksFxms+Q=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 7D99712600E; Tue,  1 Dec 2026 01:02:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=mandelbit.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8mFu4cg7b8cA;
	Tue,  1 Dec 2026 01:02:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374492-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A52D3126010; Tue,  1 Dec 2026 01:02:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id AD7222CA0D; Mon, 30 Nov 2026 22:02:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796076130;
	b=3HcRxZHy9fFmpM2k7G2X9GTRW5qtizWt655CoojugJTECZURZGO6EGD1Pr5b11Bdq+JA
	 fzEhAHvoSyoh1mwD5yBRy4jo5WuoYwyaZE2+lPt/PGaHGAV2nK3XBmPdDX1hahlJfkYxN
	 bWaba3nH0/RJa+tZgipx4yTTzEKaLdoQpFQAGkQa7f6xWfx1jxy6hih8iXyVyVErQrvXx
	 iqFCwONeC/Y3RST5FC20eELDhhFVd9yDtvoHXl9jT1Z27V0CXLBlsFtnnN5wzH9Iaoqbl
	 Xm/gnryE4q0LMsBHrs3Alwr+30C2IUH40KxzKbG8gf+Myup71juGUX2O5suHNWfMqKA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796076130;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-Rspamd-Queue-Id;
	bh=xB5a2xQFQazsoLv389nA9A1d28BBanPzdphnTA8p158=;
	b=hnklzps7Ck3Ljc/FqHIqHAH4PgsqXnqvTK8Zmr2O4fCVOxFlya8Ima85GMgQ82WugEHa
	 gNEXIWIY9JG5uWGJLV4cdzSFe0orMUWXB6iOOommY4Stj7ealijp6RHK08/wJh5fq6ek9
	 dBPBU5BKplZbX+euicklee5TwhWUX8je4lS77KqU9HyFXWxIZafQEHlo3PmsbSpdAc4ZF
	 IPRieKsqrcYWfPbh/sxGXdc3bOrNBvH79DdRQcK6q4V9gvUM1zH4uX8eXXCW+za2r+TEz
	 uC41kiu9pTm8fO2p7jtN4oM/MpiU5yKPclWuMSU78TPJazMK6xMeFsPlX0OvURTJBUA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=0YqTyIur;
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D53F606A680;
	Mon, 30 Nov 2026 22:02:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=0YqTyIur
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.55
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796076129;
	b=k73oaYWJm8FwItFC8EbtUD+mpQGRnTXH+1fB6BvmCmxyS1VBABkaZ6SGO6saPHE/bxxZ
	 RaLbMnsXh4jVhjmYI/Ca8dSpW0rX/oqmw+i96HOmuA/EyemG31WT2dvBa2Zy9gOU4UlX5
	 pjoVE+do6Gb5WHpXQ+Z5BopKMD3RbJoTpuyv+ERPBdsUUrYlYBYfVqXdiMml54SMQL0ug
	 m/oeQhUaRoVnmtY9SRL4Ke7tmY/b+aKsEQ/17KugRoREMFXEb//i4JhKHu7990DXk/Un2
	 jBvDW4/ulK1dgUldrBippOb8fHUyf+5yBlHVuDnPgGoG5M65OTh0Mqb0F1UADxKjzlg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796076129;
	h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Rspamd-Queue-Id;
	bh=xB5a2xQFQazsoLv389nA9A1d28BBanPzdphnTA8p158=;
	b=eVjGCeYx3BW8wJhwsuJel7MtDY7R6KTec9vKvBG8XP132TMg/d6Q8NqbaZyl1cUX8kz1
	 aE6TMbrms22bnQg1P6dAQ1wkI5XtSQ2xt9f2l7yLCwl2MOHE3HxrvecjFlJVgvJnfA0qx
	 bznBY6DjIDXuDzazrFzNYcOTXYG/WuwGVxUdaod/axaPk5m4eYATkIPp4IPX3I8l76lzI
	 krdMZup9iD3RrDgwVDIBSQMfqWdm7ocS6VQiVP/Ey9tnEYFX0lM8Bv2dCTninenBZDxKw
	 yqCJtHBFO05PVEdjj5G4S1uK7mruDVkinV9qIYf6Kgahw/YMfo4mZp2mxCZrIbfwBcQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=0YqTyIur;
	arc=none smtp.remote-ip=195.10.208.55
X-Received: from mout-b-110.mailbox.org (mout-b-110.mailbox.org [195.10.208.55])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF8A606A31A
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 22:02:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0FF8A606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com
X-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by mout-b-110.mailbox.org (Postfix) with ESMTPS id 4jddKS1bxLzNkWr;
	Mon, 30 Nov 2026 23:02:04 +0100 (CET)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com;
	s=MBO0001; t=1796076124;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=xB5a2xQFQazsoLv389nA9A1d28BBanPzdphnTA8p158=;
	b=0YqTyIurkRkktWwwSy9v5aUS3glo6sTXYmtS0hhYbLLKMeEA1J1Ca4/nibzWwpvRiCRiVy
	n/x5K9Ag3/vcNMQComBqtjqRfz74UqxF/4bMXoynWvf1uL3dTjGerRQGht6TA4jY9xTvv2
	SmwCZpuQQ/2vn1wii5CyIxy70jIGmGZEGu39IaNfgIUaqD9qCBy67JrZTfM16xeALm6xaN
	yfUMeubOzxC6B5vuJcZErHOSnLfOUFCqD3/SoW2HuecOarvSGfjMHO4ujQPc6lIeT1ufHi
	NzONJYyY2zeKLAZmwPP6BU4yDhq/1TxaK3xsUz/cTd3ECqX0HZ8p4F1XP7gBNw==
X-Authentication-Results: outgoing_mbo_mout;
	dkim=none;
	spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=antonio@mandelbit.com
X-Cc: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>,
	Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Daniele Palmas <dnlplm@gmail.com>,
	Koen Vandeputte <koen.vandeputte@citymesh.com>,
	Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>,
	Antonio Quartulli <antonio@mandelbit.com>
X-Mailer: git-send-email 2.56.1
X-In-Reply-To: <20261130220200.3378310-1-antonio@mandelbit.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Rspamd-Queue-Id: 4jddKS1bxLzNkWr