Skip to contentSkip to conversation

net: systemport: fix index check to avoid an array out of bounds access

PATCH In review Colin King 2 participants 2 messages Mar 12, 2020

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 net: systemport: fix index check to avoid an array out of bounds access

From: Colin Ian King <[email protected]>

Currently the bounds check on index is off by one and can lead to an out of bounds access on array priv->filters_loc when index is RXCHK_BRCM_TAG_MAX.

Fixes bb9051a2b230 ("net: systemport: Add support for WAKE_FILTER")
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -1
index bea2dbc0e469..af7ce5c5488c 100644
@@ -2133,7 +2133,7 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv,
 		return -ENOSPC;
 
 	index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX);
-	if (index > RXCHK_BRCM_TAG_MAX)
+	if (index >= RXCHK_BRCM_TAG_MAX)
 		return -ENOSPC;
 
 	/* Location is the classification ID, and index is the position
Signature · 1 line
2.25.1
maintainer
#1 lore raw

From: Colin King <[email protected]>
Date: Thu, 12 Mar 2020 15:04:30 +0000

Quoted 8 lines

From: Colin Ian King <[email protected]>

Currently the bounds check on index is off by one and can lead to an out of bounds access on array priv->filters_loc when index is RXCHK_BRCM_TAG_MAX.

Fixes bb9051a2b230 ("net: systemport: Add support for WAKE_FILTER")

Applied and queued up for -stable, thanks.