🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24836

[PATCH net] net: ethernet: mtk_eth_soc: reset dma_addr for every RX

#24836
From: Sandeep Haemoon
Date: Mon, 30 Nov 2026 23:16
78 lines
11619 bytes
mtk_poll_rx() keeps one dma_addr_t across the whole poll loop and only
refreshes it when a replacement buffer was mapped for the descriptor
being processed.  The paths that jump straight to release_desc (no
netdev for the source port, MTK_RESETTING set, or a refill allocation
failure) re-arm the descriptor with the buffer it still holds.  The
address written back must therefore come from the descriptor's own
rxd2, and the release path relies on dma_addr being DMA_MAPPING_ERROR
to select those bits.

The declaration was moved to function scope and initialised to
DMA_MAPPING_ERROR by commit e10a35abb3da ("net: ethernet: mtk_eth_soc:
fix uninitialized variable"), which also added the first check for
that sentinel on the release path.  The check was later replaced with
the FIELD_GET(rxd2) fallback below by commit 6e0490fc36cd ("net:
ethernet: mtk_eth_soc: fix SER panic with 4GB+ RAM").  Because the
sentinel is
only still true before the first successful mapping in a poll, that
fallback has only ever been taken before that point.  From the
second iteration on, the previous descriptor's high address bits are
combined with the current descriptor's low bits in rxd1.  With
MTK_36BIT_DMA and DRAM above 4 GiB the hardware then DMAs the next
frame into kernel memory the driver does not own, silently corrupting
it, and the driver passes the stale contents of the untouched buffer up
the stack.  mtk_rx_clean() unmaps the same mismatched address during a
SER, which is the panic that commit was fixing.

Eugene Markus reports that on an MT7988 board with 8 GiB of RAM,
misdirected frames corrupted page-cache and page-table pages.

Reset dma_addr to DMA_MAPPING_ERROR at the start of every iteration,
so a descriptor that is released without a new mapping keeps its own
address bits.

This change depends on the FIELD_GET(rxd2) fallback, so that commit or
its stable backport has to be present: on a tree without it the
release path would clear the high bits instead of preserving them.

Fixes: 2d75891ebc09 ("net: ethernet: mtk_eth_soc: support 36-bit DMA addressing on MT7988")
Cc: stable@vger.kernel.org
Reported-by: Eugene Markus <eugene@fiftyone-percent.net>
Link: https://lore.kernel.org/all/17e86b6f-25af-43fc-b0ca-a0eb982e6cf4@fiftyone-percent.net/
Tested-by: Eugene Markus <eugene@fiftyone-percent.net>
Signed-off-by: Sandeep Haemoon <sandeeph@loljews.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 21abeccfe0..6c8b039fad 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2210,7 +2210,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 	u8 *data, *new_data;
 	struct mtk_rx_dma_v2 *rxd, trxd;
 	int done = 0, bytes = 0;
-	dma_addr_t dma_addr = DMA_MAPPING_ERROR;
+	dma_addr_t dma_addr;
 	int ppe_idx = 0;
 
 	while (done < budget) {
@@ -2219,6 +2219,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 		u32 hash, reason;
 		int mac = 0;
 
+		/* The release paths below hand the descriptor back with the
+		 * buffer it still holds, so only overwrite its address when
+		 * a new buffer was actually mapped for it.
+		 */
+		dma_addr = DMA_MAPPING_ERROR;
+
 		ring = mtk_get_rx_ring(eth);
 		if (unlikely(!ring))
 			goto rx_done;

base-commit: 76fca30e8d34eb151fcf4f363b51c21b7e8c4709
-- 
2.53.0
Technical Details
Message-ID: <patch-d7f0fb2678768cc97f1e9fb7ff0a27b5@loljews.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-374526-linux-kernel-netdev=dewy.ru

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-374526-linux-kernel-netdev=dewy.ru
From: sandeeph@loljews.com (Sandeep Haemoon)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: ethernet: mtk_eth_soc: reset dma_addr for every RX
Date: Tue, 01 Dec 2026 01:16:10 +0200
Organization: Usenet Network
Message-ID: <patch-d7f0fb2678768cc97f1e9fb7ff0a27b5@loljews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1564211"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Ylxrl8LnV5ihVsKfwsjy3cj0h7w= sha256:dUbuN0E89Zz/PKln6HX9ZZcvdhtVtVwlks8SgjsiU7c=
	sha1:YA6Y9sZmiahlhE1jFueQh01tZU0= sha256:zTLmkxl81tfGD2ay07+sQFEisvZxCQ0jBvRQ9bcoalY=
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 326DA126019; Tue,  1 Dec 2026 02:17:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[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=loljews.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 gpFadgysfPIG;
	Tue,  1 Dec 2026 02:17:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374526-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=loljews.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 42D0312600C; Tue,  1 Dec 2026 02:17:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id D1F23265B5; Mon, 30 Nov 2026 23:17:23 +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=1796080641;
	b=egNxRsgN1Cm3mAQqcNBTam7csIuSG/tHbG+VULxPp5UKmcs0rZBEpPAmdAyfatrL0m8D
	 J1zKVewQjtu4BiZGRAqSgGU9x89EADBHxtkv2OpDbmvBZX6U6+DFMvcKg42KT8fDlw3lS
	 wCbSTt/IJNq3C5J2ZDsEfhbkd4pAQ/c2BmRc3hVmXctlPEsjYB5Ca1gHZjQryP7xdeVQW
	 E8dNDxdt+K38mAn8cUnWtQ+P4MGi54cdtx7rv1vdPtTWRrHjmEss4wJcFKzm4gGxVpidq
	 v8AVu1n678VLxquxE0wcYBpW4WR/EE41mI7d0FuVLgrTCywJhNdZTT0IzvXShBQHCmQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796080641;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-Id:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Transfer-Encoding;
	bh=Avr8eKTu3j5mTnVWFgKmGakZ8gqFBKuKwjClbF66t4k=;
	b=2wnf1BpJJU6kiicc7Edkpj7BvbpRGb929AnSN0krDl//Hlg/A8wUUuH7zdMdHwrpgSh1
	 YHI/I7CQ+iLNz+VOJ9dNgBnSgCzL/NzB3zeSDpc5Bl4S90LYqvANtQ3uTSMhdtWq+ZHil
	 4of+yjjle6rswUkA7A+tbCj2jTO/rEpzYHxd9zY56WijYF0K2AXhT7IOPkSkcmMNaev+l
	 wGBDN5+pZXkUfW5oh4Q70u0i9hNyBG91IeFQdRW8SPKl1cwpYzNljH20pe+mvzNyKm0aQ
	 R0AoAD5vlqRJ0rpxh7dHbvll8FhRV7lHZ6MIfuzzAkQRovG5z6wGqJc/bIAku257O2w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b=lLfC+mVE;
	dmarc=pass header.from=loljews.com;
	spf=pass smtp.mailfrom=loljews.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 33749606A699;
	Mon, 30 Nov 2026 23:17:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b=lLfC+mVE
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.38.221.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796080640;
	b=Tzx4NivQjlttbPuze41jqLHECqIFR2FM3Q7qyVbLgg9rThndUtO9hsLsF2DEjD8Qdyke
	 4iQfc3qXFsYCWGV0m907VL8xuaYRZtcqs+JAPtDSjUcWrCtLNfCyVat5I48oIohsRMxWY
	 F7mj6XlktktA6iN6ZMAUZSFRepTpWBncIJOCVBh28J83XIuUk7TfrSpN58021pa1YLOxH
	 UGpLtPU8MigPum0gitU8B+qVEwEmwjWzdI+QSiof+1K8t6vUHCzehi+U+o5LvVjde7Awk
	 ydAgmUqZV5Swg47ZikCycfBwUubuapgoPV/fH3iJTnmV69WGYSd/kA3fYJQppGDU08w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796080640;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=Avr8eKTu3j5mTnVWFgKmGakZ8gqFBKuKwjClbF66t4k=;
	b=F3Prx2A0hbnqHUGGKJqEk8ACrsgHMbKP1iTLpsAtDrooMEMGTysdst/6FpqUwSytGBcy
	 4vMVufe64JgOfgoT3K6NmEylD6ru8eVbDiwXVsBpSfePOnxwbl8AeMof1ACRy/8PauXd4
	 nlj+pdT+yw/w5jobpNuVdy2uw3uzl5JqGxTJnhipabz8qX6vcbo8rLepO9E/yN7VLOk8D
	 8OecXDondKWFicYh24JVMKja5C3IiRnj+GFpZndg5cXdN/8Soq2fR69rpRAEe1WyYeeOj
	 jyegbRMWYUk9foWJ2F6VTyVXoqL3VQN3+uJojIWzPBUUvYR82g7QKwNsZlfGGDU/0+A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=loljews.com;
	spf=pass smtp.mailfrom=loljews.com;
	dkim=pass header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b=lLfC+mVE;
	arc=none smtp.remote-ip=54.38.221.178
X-Received: from mnc015mcc432.ss7-reroute.local (unknown [54.38.221.178])
	(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 CCC88606A329;
	Mon, 30 Nov 2026 23:17:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CCC88606A329
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=loljews.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loljews.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=loljews.com; s=mail;
	t=1796080627; bh=Avr8eKTu3j5mTnVWFgKmGakZ8gqFBKuKwjClbF66t4k=;
	h=From:To:Cc:Subject:Date;
	b=lLfC+mVEJkP0EIPENS/KNiPeCY6DXt+mhEYwb6VYY039YRK4l4rWNjyuimRZ9NZ3v
	 b91u6OZ0mbsoAYqQbKSJMnfdxKBy/5ZUcNfJy9t//61zvFaoz2xvmGnFviJyd+m1aE
	 FOYr7QpHQu6e/i3PQoKOxjdE/R6vptJZvFWSyBF/t5KofiObP0Nf6/o5C9PX1Mombu
	 GbcF4aJvLADsCGXiQzfCcILy1eyS0GbQCma/vymqZIUousSl1/9jbJkGtq+XLt7VCv
	 QAcwH0w92nvpbfFUTfLb8hihT2sEAkEx8hcP1pP9MvHvi7G+ittrz7ZVIgSDPA4V+N
	 l8nS6GaGmfG1A==
X-Received: from loljews.com (localhost [127.0.0.1])
	by postfix (Postfix) with ESMTP id C74DD27A3214;
	Tue, 01 Dec 2026 01:17:07 +0200 (EET)
X-Cc: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi <lorenzo@kernel.org>, David S. Miller <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Daniel Golle <daniel@makrotopia.org>, Eugene Markus <eugene@fiftyone-percent.net>, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
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