Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by memoriaru
Sat, 31 Oct 2026 08:18
[PATCH net v4 1/3] net: dsa: mxl862xx: bound FDB dump walk with a read limit
Author: memoriaru
Date: Sat, 31 Oct 2026 08:18
Date: Sat, 31 Oct 2026 08:18
73 lines
12238 bytes
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)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads