🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15826

[PATCH net] net: dsa: mxl862xx: bound FDB dump walk with a read limit

#15826
From: memoriaru
Date: Fri, 13 Nov 2026 12:45
76 lines
12031 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-reported "last" flag, holding RTNL for
the whole duration. Entries for other ports are skipped without
invoking the DSA callback, so the netlink dump buffer never fills and
the loop has no other way to terminate.

If the firmware crashes or misbehaves mid-walk and never sets the last
flag, the driver spins forever with RTNL held, blocking all netlink
configuration and stack operations on the system.

Bound the walk with 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.

Not tested on real hardware; found by code inspection while auditing
the loop termination conditions.

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. Checked
+		 * after the "last" test so that a correctly ended walk of
+		 * a full table is not rejected; if the firmware dies or
+		 * misbehaves mid-walk this also stops us from spinning
+		 * forever with RTNL held.
+		 */
+		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_50548A0CA0A2E93225C5F5DD2DA865400607@qq.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362642-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362642-linux-kernel-netdev=dewy.ru
From: memoriaru@foxmail.com
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: dsa: mxl862xx: bound FDB dump walk with a read limit
Date: Fri, 13 Nov 2026 20:45:08 +0800
Organization: Usenet Network
Message-ID: <tencent_50548A0CA0A2E93225C5F5DD2DA865400607@qq.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1382012"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5BQpsilh1uwFXKO1wveju6hT3aw= sha256:xZz2AMiuGI74N03c78SVQTN0CjgdRSKCWYmoejK0sL8= sha1:oHBJAp2ee8sf15ebxdE6a2hVlA0= sha256:wwgI1DdSphkJJqenaGcPnkxGL5RYRj9uRzFI4IbqwpM=
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 E4A2F1145A3; Fri, 13 Nov 2026 19:25:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, 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, 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 3nVMAqtxXiPV; Fri, 13 Nov 2026 19:25:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-362642-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 696E811459E; Fri, 13 Nov 2026 19:25:17 +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 399151C9489; Fri, 13 Nov 2026 12:45:26 +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=1794573923; b=ZK4ZWGpNTugz/ik1k92/JPyYWY6daqo3pwgQ8A2Vwd0toWKJTbyV3Usdbh3mKukujO8r PfgKviJ9AZXoqjceFsLgdQP1F47AEmdvqZm8ebc1OZMc+WxSon0tNnWR0Hdw1Z0Qr7ZmP PQI7v5vBZWrEj9G2Y+dri3SGgHdUwEOAu4YWJU83EGMXQ2LVam5QavypPY7Sm1kU5s+bN wbfnB34O9Zxs9ePULKJuSbF+HVrN2zqBSXxnaDJD1b1rnXSIBE+tZGgwSW4d1DiOGg3Eg CrTE3iFUoNCoZy9p+1EpVLsuKbaXdRwL7DC6caoA3pIO2AbZqj10HxR5J/P9o+q+sCQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794573923; 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:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=HoGTW3gc9Rq9B8/aEMn7cAx7SDpJrptD9i9Rqej6gbY=; b=j9u1gDu4vWp8tj0t79KZrheZLTDGDQH8Hb+ORHXDoGDrCwqCmuLlEkmN3iw5hxvNvzXx nxQ8XvfbyigFckLNfgzRtn6ZNAMoVJ8XHdyKemuHzEgimiFZqCVncmQLwepKYMGuZykac tnsySzx1GiECpA8U/E39Zo6T9hyibcECgefHM05mHn6oqOOMBBHSYFQJhfOjbtM2Zv6NG us6mkr2Y8we+sQynVuL1PtYqgXzlwZ235mwyq0Flh7G9RYmapQrPgjdzj0hh9ns2v+NSR XJ/CYrV7FPBlXvoWlUroKkPppEpgnccPbWhNlSC5jhR34nQgazgV1USIODl4n/kWwdg==
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=k+iKId++; 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 EE4FE606A33A; Fri, 13 Nov 2026 12:45:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.a=rsa-sha256 header.s=s201512 header.b=k+iKId++
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.205.221.231
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794573922; b=UTvzTlyg7XumO/xUSdLciSX9oVi78FpOqW0ba1bpO4QZtlyBjg7mtJBWz76bRU730B0j q8rVos8S62RQtUw0X4hj5NO0sKsIhJK17VxcTfCM0jNKw+PjfBS/y3liiz/C9ukmpmVWx UaSOaJta4vbtYSGPW2zq0pW7QQtL/itwrkjmzqUWMihI8xA7WHTA07tDQteYDcy1BgYFk oPzOwd1nBl3NBPbbT6jcQS29zaMHxnGtjrWaINyLobosjFnpnx1TdZjVWms5Ncw58L1Ti v2lw3Pf+yqw6+qT7JmweVpfEhix1dOmQMcDtZM1K2KOsJ2ZVHiZu7NEEsXMmSmHwY+w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794573922; 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:MIME-Version:Content-Transfer-Encoding; bh=HoGTW3gc9Rq9B8/aEMn7cAx7SDpJrptD9i9Rqej6gbY=; b=PzxFpm0g7F1Rtz94RKpE7z8jBndDy6YzSsZQchL3Ioh3Vm3BCHd8vi646XZlt2qxZzY0 PfCB6gJGSeY9DmoCHVIQPpEIxA6zox5/t5uHl6maL0oQdQiFXadybuRyvcH7dXVL4XE2q s1lBs55QRMY4L4R2BvpHo9Ip6qTA8sVC2NOsVQpfI+4+53iP3G+3t4Xwvuii5JDMlh6c/ 5FgCL+2OSBKblZDRAOBHEMVJBRUA9aE306e3BRPUkKmkdGelETp4oacXfdwv2BZPTLMd4 IiexieHC9oq1yUkDJuXkPCNDL7YJP1nRN3DTcmBTrxcZ8mKUpq+1pxkhr9H48qa+ghA==
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=k+iKId++; arc=none smtp.remote-ip=203.205.221.231
X-Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) (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 3A42F606A327 for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 12:45:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3A42F606A327
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=1794573917; bh=HoGTW3gc9Rq9B8/aEMn7cAx7SDpJrptD9i9Rqej6gbY=; h=From:To:Cc:Subject:Date; b=k+iKId++VmmBg8wTjCZqW86iHSyLiEUen6piuYr3odewHwmNDsd4sprE0S43Y6HWx PulXbGz0a8MDmyx+FbZQ4WrUZ4YT4jtdQOD6OUxKCPqA/4PWMZmt3TYd6nwlGK3rrl tR92BXiPqN7QhfKjQcpkYosEEKfrEB1o/OpWDHlY=
X-Received: from localhost.localdomain ([240e:3bb:3033:7d41:3d43:876a:14ed:84bb]) by newxmesmtplogicsvrszb51-0.qq.com (NewEsmtp) with SMTP id B48B4646; Fri, 13 Nov 2026 20:45:08 +0800
X-QQ-mid: xmsmtpt1794573908txnuao84w
X-QQ-XMAILINFO: MC6m07AaSFhrgbdkfdoApSPzEkMLO5PpNxzn2dBY9RluIJ1hd0ySbPf4yfKPif 7EcA/lQbDg6SMYb9Nk1KR+y25GqGoJcnUumc5n0/nEX8TDoOUqAw3ECe8+8hpW/ZV49c6XPkQxM0 ICk4QgtLuim1qr/8jxkT8dddbqnDr8WskWddsmtfDF6I+XUFzdLLSIuMD3rqoP06RVh7glfKQrTm aqVvVqtsahVjy7Sho+ZxrrsvfsVOiML7eUZ8mF0UBXiZkoBV7Qa6jnzvuX8Dl8987guqYtSwiFjo SQKJdhb1zWf7mQx3iwYVFM3Zcf0hkLP4lGCtxbBOPtaSxbs/AGzVNRGSjdezc1PnkmnjqAlPvs6E OUv71Bn79m/15LJG9SlMH4tevFNyo5+GRBEJljs0QA6uRzkvjW4AkFeWQ583FUcVR+CInaIcebC5 TIh2oOXQp2W7+Rwiml14/DvghP8jP4J2xGi47+K3MXaw1+sneTsgqw1SVUg1Ad2PsiUnQb8lRJqx i7J8yK+mpjYJozSImUcMQZmLwwZPvTiLtB7gp93AKABNW/aqgkrjOgxAKPKYFcTYZ+s4dX/9i7F1 X5MugFHfr4oXQuFD6H+N+mSVUhXiMjoRiS/HcetVlqo1SFyqL5DrqTjCQfHWfKS90gHOkCJ4TQnh NYFP0mPiuDb5bMZ/644CukZIVEmnJPomGvqIdybo200xysclMqXUnTkj8pRo4NoQIFYVYufnIvUv i/UjyU0FYX1NfdDS0wiKPOqmvDWiUsdPQ7dcZ5Gm3biZwyzHKdak+Le5xNQlOp3ATP5l0kLbh3yW riZgIoNCcRGNZZAgynFoOSlhPOXog5g2PKEWXu4rWV4cqF1BKEGfy/Wd22geIQyUu6ocqzm8EkgZ HsQZtyflUCIUAHEiTqpkB2FWXH4301oF0oCpVLjI/uyz0s8LUI187JnL1a75EISuTsg6XC/ONrD6 oEr6ArTDrNFIYc/osoQym3ae/pMRRGd04iWd7mNWQ3QTFR+nPEXOJnVPvnmBis0l+xck9XK7ffLR 9CxES+m/N2AKIW8Hvgm7wmSbrJKkupl69pVGn1/CwK800dWfAiEDT+bUppu/gILO9j1CYgGA==
X-QQ-XMRINFO: MSVp+SPm3vtSI1QTLgDHQqIV1w2oNKDqfg==
X-Cc: daniel@makrotopia.org, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, kuba@kernel.org, pabeni@redhat.com, memoriaru@foxmail.com
X-OQ-MSGID: <20261113124508.30307-1-memoriaru@foxmail.com>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
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