🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9111

[PATCH net v4 1/3] net: dsa: mxl862xx: bound FDB dump walk with a read limit

#9111
From: memoriaru
Date: Sat, 31 Oct 2026 08:18
73 lines
12238 bytes
From: Zhang Hewei <memoriaru@foxmail.com>

mxl862xx_port_fdb_dump() walks the MAC table in a while (true) loop
whose only exit is the device-controlled "last" flag. Entries whose
port id does not match the dumped port are skipped without invoking
the DSA callback, so the netlink dump buffer never fills either: a
device (or its firmware) that keeps answering with entries for other
ports and never sets last keeps the driver walking forever with RTNL
held.

The exact MAC table capacity is not part of the public driver API.
Use a conservative read limit (16k, well above any documented table
size for this family) and return -EIO when it is exceeded. The limit
is checked after the "last" test so that a correctly ended walk of a
full table is not rejected: the walk needs one read more than the
number of entries it reports.

Fixes: 340bdf984613c4a9 ("net: dsa: mxl862xx: implement bridge offloading")
Signed-off-by: Zhang Hewei <memoriaru@foxmail.com>
---
 drivers/net/dsa/mxl862xx/mxl862xx.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/dsa/mxl862xx/mxl862xx.c b/drivers/net/dsa/mxl862xx/mxl862xx.c
index e05ad52cd..37e8c18f1 100644
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
@@ -30,6 +30,11 @@
  */
 #define MXL862XX_STATS_POLL_INTERVAL	(2 * HZ)
 
+/* Conservative bound for the MAC table read loop: the exact capacity is
+ * not part of the public driver API (see mxl862xx_port_fdb_dump()).
+ */
+#define MXL862XX_MAC_TABLE_WALK_LIMIT	16384
+
 struct mxl862xx_mib_desc {
 	unsigned int size;
 	unsigned int offset;
@@ -1503,6 +1508,7 @@ static int mxl862xx_port_fdb_dump(struct dsa_switch *ds, int port,
 	struct mxl862xx_mac_table_read param = { .initial = 1 };
 	struct mxl862xx_priv *priv = ds->priv;
 	u32 entry_port_id;
+	int count = 0;
 	int ret;
 
 	while (true) {
@@ -1513,6 +1519,22 @@ static int mxl862xx_port_fdb_dump(struct dsa_switch *ds, int port,
 		if (param.last)
 			break;
 
+		/* The exact MAC table capacity is not part of the public
+		 * driver API. Use a conservative read limit: 16k is well
+		 * above any documented table size for this family, while a
+		 * device that never sets last (or keeps answering with
+		 * entries for other ports, which never reach the callback)
+		 * would otherwise keep us walking forever with RTNL held.
+		 * Checked after the "last" test so that a correctly ended
+		 * walk of a full table is not rejected.
+		 */
+		if (count++ >= MXL862XX_MAC_TABLE_WALK_LIMIT) {
+			dev_err(ds->dev,
+				"FDB dump walk exceeded %d reads, aborting\n",
+				MXL862XX_MAC_TABLE_WALK_LIMIT);
+			return -EIO;
+		}
+
 		entry_port_id = le32_to_cpu(param.port_id);
 
 		if (entry_port_id == port) {
-- 
2.39.5 (Apple Git-154)
Technical Details
Message-ID: <tencent_9AACA76E6D2CF7339050E800BD4E1329510A@qq.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354053-linux-kernel-netdev=dewy.ru
References: <20261031081813.64518-1-memoriaru@foxmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354053-linux-kernel-netdev=dewy.ru
From: memoriaru@foxmail.com
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 1/3] net: dsa: mxl862xx: bound FDB dump walk with a read limit
Date: Sat, 31 Oct 2026 16:18:11 +0800
Organization: Usenet Network
Message-ID: <tencent_9AACA76E6D2CF7339050E800BD4E1329510A@qq.com>
References: <20261031081813.64518-1-memoriaru@foxmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2408803"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YtqMXq84IxOOCSRJlV77mC/SX+4= sha256:wp5Iv1+l3b1e1HzLWHnudskKa8JIdczwyCmvUtM9z1w=
	sha1:z0YdRbA0Aimx0dHf6X2pQZgErOc= sha256:0+/a5YOdNoT9SjKsyTM8D9tLXjhK5blo1FcbfZH93iI=
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 E0B2F125CB8; Sat, 31 Oct 2026 11:18:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.147
X-Spam-Status: No, score=-3.147 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=foxmail.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 hvJnl1ZmJb3N;
	Sat, 31 Oct 2026 11:18:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354053-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=foxmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id CEA27125CB6; Sat, 31 Oct 2026 11:18:38 +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 3A2AB27F36; Sat, 31 Oct 2026 08:18:31 +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=1793434709;
	b=WgZc5DQvt9fRhZ1RUyQ6oTnA8B0/HLohwsxh+UtIa/Hoi4ALB/2QA4wsbttLH+h7qA4k
	 KUUCJfV5fndvS6/XYnBB9hv0eFU5YHQIq/Gvyxnzh+z6RSlmmM2FCYnJhPjZjocmY2RWq
	 uLNKkec+XTYZf3+hgqkPmM+vZ7mTd1w4ih0AdgmoNCuDQ9iWr/IfOog0h+kGaa4gpGKiK
	 x9dgRpyA+MZbesLNJHdiuQWYvkQAZaKhcpJqo/Kwo+acDOTxlHEJ3C5oyGQx5Qav4UduP
	 kau6Gj8niS4JbKCaQ8KVHzE+l9Ul161jHhHyk/8SsLTl0oC1lK3ytTp1F5ZdDXSGEeg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793434709;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:
	 Message-ID:X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:
	 X-OQ-MSGID: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;
	bh=Zmpvpv5AziW/jsJVHh5ej1EELzXwiOShgDeV454QDo4=;
	b=4/bBiTQxG16vl8tH/0XAaiuNzKhY6f3CDVjXjWuNbFHMv2tR3MhVXwkuWikLbsAw/JI1
	 Xb2PsXPWQGUoqw9RhJSaTLJOE92VDMRsrUv5SdajyU72OgqBi6bJ++pGMzbMUONcTRUrt
	 57TqYeTnjQSK9g9oR8Hp3+PxxC8gyle+50O93h+KzYbAiUpyLgxCbT4sNSM6av4nB9fxc
	 9V9QAb5BCXEbmM97oKO996HlZKnvn03m4ABEDbnsXmGwp5me+UviZFozHmdIZ2V7yES0I
	 j6H4FIE1wsroWRSgUuHYg6A/PtVVLsksoIUc1F8r8CiWcoCyDE60zs2HNE0Cv+x7gww==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=foxmail.com header.i=@foxmail.com header.a=rsa-sha256 header.s=s201512 header.b="Js3Ysh2/";
	dmarc=pass header.from=foxmail.com;
	spf=pass smtp.mailfrom=foxmail.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 28E86606A323;
	Sat, 31 Oct 2026 08:18:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=foxmail.com header.i=@foxmail.com header.a=rsa-sha256 header.s=s201512 header.b=Js3Ysh2/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.205.221.164
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793434708;
	b=0l/0ZzStxzLoSwO9NQFbUipW+SQjxuwIdxzMSFp8lM2wfBXhF6EZe264Cqj58R/8Mh0g
	 ctvtHkOJx6MPiMazrzwNkUldPf1m5OzQ5NUcA7yjav2IZZy6DKtQ9gd/76i2FKt2+VJED
	 Jfx9NB8vhcW8scVLEMmrjx20aNUkTudHrQdiZFwq0ycOXYrxAFeCzKnjqqEv6s6KDolvP
	 1lPoeL5dac6HtgNuSb7YHSrctzy6LmpdjpMtvTdHEbY6pRr6aYQlXcXZqnNN60u6n4ats
	 o8bQxQ6yUTJdgB/Gl9XTdUIPbzr50wnxd2/J8BrDXoOS1cCa124rz0MBCSi4TSKWqaA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793434708;
	h=DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:Message-ID:
	 X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:X-OQ-MSGID:
	 X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Zmpvpv5AziW/jsJVHh5ej1EELzXwiOShgDeV454QDo4=;
	b=vXY3pOdtt0W0QBMnTyup9hfNaTza/d/pJR4wTZ5TUmeShNn1rnEsAXgV4nGx40aULbyL
	 IoWqfEmPurmTPAtHkEhhChjFtg9gJEVSlXkKueIY56x3+0VCM0voWHw7VS+5eHayp9/z+
	 DYw3jcZ7d0Yzyi/RjJQA3V49U2+5Ivgjq9x29g1tdsVE5jDuzPk3zCkZ+D7ryueU/QfEo
	 SsWG9yf10S6ymMvdEF2PkExIEp19CmHIZ2jpM2w0WtbqePaGNZ03UIM8/EsTLc3oKLSan
	 B9iNrJXkpEqCgOmpprXjEv2lfo1TADa7pLdhqHWAqFTJm5cBSWpOkhU6Hkpvwy300og==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=foxmail.com;
	spf=pass smtp.mailfrom=foxmail.com;
	dkim=pass header.d=foxmail.com header.i=@foxmail.com header.a=rsa-sha256 header.s=s201512 header.b="Js3Ysh2/";
	arc=none smtp.remote-ip=203.205.221.164
X-Received: from out203-205-221-164.mail.qq.com (out203-205-221-164.mail.qq.com [203.205.221.164])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 218E4606A31A
	for <netdev@vger.kernel.org>; Sat, 31 Oct 2026 08:18:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 218E4606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxmail.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com;
	s=s201512; t=1793434698;
	bh=Zmpvpv5AziW/jsJVHh5ej1EELzXwiOShgDeV454QDo4=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=Js3Ysh2/9jqQWFURq6f9C+DIrQIcu12g/61Cjz+EhAwasklt4A/zUCa89Nx1blKYU
	 8ng6DBnT4eBfHkX2K9j+ZftGt9KLlvt1OsZa1YctNuVghUNJrfhEyyMc2yN4o9kOwJ
	 z59Rw+b7tKIZuSA0AW3fsJTc4h0VPGkDRP0Aw03U=
X-Received: from localhost.localdomain ([240e:3bb:302c:4eb1:751b:856d:f57c:9109])
	by newxmesmtplogicsvrsza63-0.qq.com (NewEsmtp) with SMTP
	id 48E960B1; Sat, 31 Oct 2026 16:18:14 +0800
X-QQ-mid: xmsmtpt1793434696tvqfklnc0
X-QQ-XMAILINFO: MRMtjO3A6C9XSOcZStsqqv9vFFsHfIWLVxapdqiIUL8Afps6YeSGEpw7Jxr/2O
	 rf9g1A6y+bwqiiWoqEoy3CPKcWYnde5RtMMr8gfUTSDmlwK5/Gku5cXDyvpsHRYzHCxCzRP0Kr8z
	 al+92EAZukVd3RkbQ7omhS9Jw4Ig0r9Nm5Iak+7/v5zZZ6QZi4bJEezy4GssmUk3OPcDu/GFAyxz
	 KMnPnmrbhqYWbD8SuRRC00CbU1lDxAXkloUhc7rrEVcnNbmcgBKcqBJVdCAz4OjJGr+pIusA+qla
	 mwBEN2/8qofi/c7BRdCeg/WXt36/or9qgL4r2eP0twOsocH/z9O1PW+Qtxgv5ZvNPfxVCQ2XVSUW
	 48W2EnpOcFOcXajq8O0rXftiHHxzCMTtNh9dNSt3BObf8zms79LXKC4ounrK9J0oeumtacoajD/9
	 d/Q46lrbFsRkKk9sV6Y2pEks72nQiULZiBlr/Ddq6/bNIl8LFgjvayM8fI5OLB+gFQLZOVZIhcSl
	 UVo17NJs4iMyu1Cej8U92Z0VLDOswx6FVjoq9S6N8d/tbeo0ZPqYQS6GVyckhISLqH1Y7HjiL9zu
	 lcjFhYxYiDYJNKaR8MzNVjLgczd+S8Xv5DsdvuMjS7IbVHpeFazoR939lbBd8+JzAELas6iWAAOm
	 /iv/+5kiHVWEbLYPdwOPU9m51xUZQQGCGMtU/83hhfSMvSueTU2zuV1QPmnjGNrfgAg/nY9kMj8B
	 rnAA2g2+xTUCMjF/ClT84qo4t21/bSAp4s4bOi+sss/dx1wtLHKkJCH5T1fShBRn+c2M5vPPYwG/
	 LbSXdRTeq0SuGeV+w8+bqmM1+Egu+O1J4cMIlzrNth8a5FF+95Go0N3qaifjJoh8VMD4rAsviXWM
	 agCL5AhQFkB6iWDIKQ1ynkH/4k1Oteea7wJ7rUxi6whrNtyeid1U2EKlUSPOAom7o1MC8BsyeeDy
	 Y1zdARR5NnQs/R9zVsFmO3LPBWVKHMsevzlDQT9nv0TJATl6DfKinWdS2roloFtd96EJuocKcwPa
	 +1Hi/Mv6oUk+t5XOPyjtNvIev/RAceHYTAeN1XPcKQjGJwDm6S70FMuXvboZs=
X-QQ-XMRINFO: OD9hHCdaPRBwH5bRRRw8tsiH4UAatJqXfg==
X-Cc: daniel@makrotopia.org,
	andrew@lunn.ch,
	f.fainelli@gmail.com,
	olteanv@gmail.com,
	johan@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com
X-OQ-MSGID: <20261031081813.64518-2-memoriaru@foxmail.com>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
X-In-Reply-To: <20261031081813.64518-1-memoriaru@foxmail.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