Re: [PATCH net 08/12] net: systemport: Fix out-of-bounds array accesses in DSA queue mapping

From: Nicolai Buchwitz

Date: Tue Sep 22 2026 - 06:04:39 EST


Hi Florian

On 22.9.2026 01:13, Florian Fainelli wrote:
The priv->ring_map array has a fixed size of (DSA_MAX_PORTS * 8). In
bcm_sysport_select_queue(), bcm_sysport_map_queues(), and
bcm_sysport_unmap_queues(), indices calculated as
(qp + port * num_tx_queues) were accessed without checking against
ARRAY_SIZE(priv->ring_map). If unusual port or queue configurations are
encountered, this could lead to out-of-bounds array accesses.

Additionally, on SYSTEMPORT Lite, netif_set_real_num_tx_queues() was
called with slave_dev->num_tx_queues / 2, which could evaluate to 0 if
slave_dev->num_tx_queues is 1, causing netif_set_real_num_tx_queues() to
fail with -EINVAL.

Fix these by clamping the real number of queues to at least 1 and adding
bounds checks on priv->ring_map.

Fixes: d156576362c0 ("net: systemport: Establish lower/upper queue mapping")
Assisted-by: LLM
Signed-off-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 95cead1df160..130545cce045 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c

[...]

@@ -2352,7 +2356,8 @@ static int bcm_sysport_map_queues(struct net_device *dev,
ring->switch_queue = qp;
ring->switch_port = port;
ring->inspect = true;
- priv->ring_map[qp + port * num_tx_queues] = ring;
+ if (qp + port * num_tx_queues < ARRAY_SIZE(priv->ring_map))
+ priv->ring_map[qp + port * num_tx_queues] = ring;

Out of range rings would still have inspect = true but no ring_map
entry, so select_queue() can never pick them.

Bail out before marking the ring?

[...]

Thanks,
Nicolai