🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14245

[PATCH net-next v7 12/18] net: ethernet: cortina: Release partial RX frames on stop

#14245
From: Linus Walleij
Date: Tue, 10 Nov 2026 22:13
54 lines
9827 bytes
A NAPI poll can retain a partially assembled frame across invocations. The
stop path clears port->rx_skb without freeing the skb retained in
napi->skb. If the interface is reopened, napi_get_frags() returns that
stale skb. The next frame overwrites its fragment array from index zero
while len and data_len still include the partial frame.

This can lose page references belonging to the old fragments or pass an
skb with inconsistent fragment accounting to GRO. If the interface is
removed without reopening, NAPI teardown eventually frees the stale skb.

Free a pending fragment skb after disabling NAPI and before clearing the
saved RX state. Count the discarded frame as dropped under the RX
statistics sequence counter. Use the irqsave update helpers because
ndo_stop runs in preemptible process context while 32-bit statistics
writers must not be preempted.

The issue was found by inspecting the partial frame lifetime and statistics
writer contexts. The series was tested on a D-Link DIR-685 with media
playback and ksmbd transfers under ping load.

Fixes: 06937db21ee3 ("net: ethernet: cortina: Make RX SKB per-port")
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
 drivers/net/ethernet/cortina/gemini.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 73ba008a9c7f..d08dbb0aabcf 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2228,12 +2228,19 @@ static int gmac_open(struct net_device *netdev)
 static int gmac_stop(struct net_device *netdev)
 {
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
+	unsigned long flags;
 
 	hrtimer_cancel(&port->rx_coalesce_timer);
 	netif_tx_stop_all_queues(netdev);
 	gmac_disable_tx_rx(netdev);
 	gmac_stop_dma(port);
 	napi_disable(&port->napi);
+	if (port->rx_skb) {
+		napi_free_frags(&port->napi);
+		flags = u64_stats_update_begin_irqsave(&port->rx_stats_syncp);
+		port->stats.rx_dropped++;
+		u64_stats_update_end_irqrestore(&port->rx_stats_syncp, flags);
+	}
 	port->rx_skb = NULL;
 	port->rx_frag_nr = 0;
 	port->rx_dropping = false;

-- 
2.56.0
Technical Details
Message-ID: <20261110-gemini-ethernet-fixes-3-v7-12-9c32a1a46aec@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360680-linux-kernel-netdev=dewy.ru
References: <20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360680-linux-kernel-netdev=dewy.ru
From: linusw@kernel.org (Linus Walleij)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v7 12/18] net: ethernet: cortina: Release partial
 RX frames on stop
Date: Tue, 10 Nov 2026 23:13:27 +0100
Organization: Usenet Network
Message-ID: <20261110-gemini-ethernet-fixes-3-v7-12-9c32a1a46aec@kernel.org>
References: <20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="716292"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Qdo/j7Sxi4cSurhOCzJamaAom1w= sha256:TTxZxpi1dZfzkkVyBybS+tdrM2ANPiYvqqp+8Mvljc4=
	sha1:cH62DXToL2lE09hHtGnEGsOh5zM= sha256:aQxQwIc0VO6RELNVPHP64XXHyTo02SjwpsgS+ARknLw=
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 DBADD113D6C; Wed, 11 Nov 2026 01:19:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org
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 bdFNo1Y_Rzz6;
	Wed, 11 Nov 2026 01:19:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-360680-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 352EE113D74; Wed, 11 Nov 2026 01:19:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 457CE601F8F; Tue, 10 Nov 2026 22:14:17 +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=1794348838;
	b=VygRuO8yqb2nZqifInbYYwKmPL/lXu4AkH9cxHigbvtSExIpT5LrPEOhZwLfARljaGvI
	 WCAdqsWYXLjJi5WSeMbegaADPWYfiDLkuKPFpnvIciM9+KjV05WUYin/L7w0mCCy/BWZD
	 wMWbw4W95aX62WxpcJFhdqqSWTZ6cRjylBacqyroBxRnVjmYIaoZOy9obde4SgjTh7uPB
	 BUKmQ7ycYlX4HpiqdAmlrX3VVHTQ+V+/ZA3DNIQud+uOkUIF8qxyI0WxRbz63OWa8J6ZB
	 ixCothZ4iLGxcrFBetMnlTSSmov1rcedLgnTMcpTGhs0SO79wiXBgEwy0yNpKXef5KA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794348838;
	h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer;
	bh=cOkTPVWBCHuP1zGUI8ZXA5imLKoMmBYYAcQcmlTHROM=;
	b=sJFt4OrtQKhV5k42AiBCPp7N1Eh/AWQzOiAR9a6a/bldYg3Ja7jT8CH3eLY/ZsUKzQm5
	 jpHx8NK3S96blOOxP84c5hDOLAWpwaNQFfnsbFp202ygaj/PoDc5BVD0Mf9jZU57ef3JR
	 a7Pd0YFQ2lXar1oHiwtGjSdnDGqKOo+/EK8HepiHzIbLE12cm2wByrcgZP/IeNX4AxliB
	 uy221kaoDqJ/P7Zx/Cx6CdIZFzQNV4AsZtsJAWMVKpH+7rRb8VqNsRV6hXhcr47gIG/MU
	 CO48R0fl6iJgDbAsrvTG76YF2auwfYov9wTK+4qsgjJS5250pVT9zaPvJWax4LbIhkQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QzgmRBSo;
	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 CC05660A2618;
	Tue, 10 Nov 2026 22:13:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QzgmRBSo
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794348838;
	b=MHOZehTHdc+mW6siAEEn9KIG24UjzdATXm5/eiuWWMU/JiKeUAiMycSEVxaq+qSyrKjY
	 nB7TqAEQzO3PxTFrhWm8Fo4iVDeUoI2dI0w7iVeosJYCDVV+JidMoJQ0RP8aLwzyrmC9F
	 +CzoV/cajl6oYOPH1q73EHvUSoCm1RcezirnYP2Oe1EZ+xQfo0slfuMrCZZY3KFodAaPv
	 AD+DUZWFTA7adNawj2WubtBXa41D1rITfLI9hxGtnYhXcU3GzWM2TL0cWdXBuqDKoJpQ1
	 JecfOG1aAgeXEIjhZP1Rn6ic1b1v1sF2oKSaonlYiQ05Wyzhoi+W/ByOczyMM5e+TBA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794348838;
	h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer;
	bh=cOkTPVWBCHuP1zGUI8ZXA5imLKoMmBYYAcQcmlTHROM=;
	b=N74ijaHvutWWB/Gud/otdu+bviXySCl95en2YHiWV/1j2MU1CYQgadOxKzTPHfxeGRjq
	 Y4jeyQ7WnrL0O3ZiGECUcJInMmaoQZlVFju0NbZwDuuWyOOZDzPwcMLoZ4PGdZh8Xnjmq
	 X5vkhz2Sp/Ds9QPdP50mHurXObTRBfr1uUXJIQbYOlSe7Fe+2PuNvmTSbGSbEOtDKekn7
	 X/D3ute+flkqD0ypeBGAKAKlQ0YB2KLKOVmw5IEGGgXnCx7RzJqAqdinVlGSimIJqvBTp
	 JEcO5TJc61AiJiZD+Yi1k81uvy8ht4SbiLvcWgnsxFCl6/BlKeQtgCyG8PdsFStmbyg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QzgmRBSo;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC37F606A31C
	for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 22:13:57 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A1F51F008A3;
	Tue, 10 Nov 2026 22:13:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794348837;
	bh=cOkTPVWBCHuP1zGUI8ZXA5imLKoMmBYYAcQcmlTHROM=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc;
	b=QzgmRBSoXIZnLGiW1bnOv7ALAgkmc4w6PN5xvw6OTnB94QX8SYYOvaSvrRUa/KZhe
	 zWvAsA4dw5aImSIZ+DYej7YAfeKJpYBC3MIV8aQ5AMRLkmqzOQaunaZCZDPKk885lv
	 8RhiI707TLiR3XlJrlePIG3mANQTCtNfzzKK02iw3ZiYJOzeE0JVTsD8/u4NDGpU0a
	 y8HrUM9nv4+uwEXGsEYhxk2cZU+dhUF7TxHQWPJC/t1j3RghyUmvCiN6DhIlLdDbJ4
	 UYBp0oq+pQyPv1alWaQ6hpdcCeLQ4vdAlGsR0jj6V60ZgRuwtVJZ55cZBs8TwWBz88
	 13qc0y9DSb0qw==
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-In-Reply-To: <20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec@kernel.org>
X-Cc: netdev@vger.kernel.org, Linus Walleij <linusw@kernel.org>
X-Mailer: b4 0.16.0