Skip to content

Commit

Permalink
net: bcmasp: Sanity check is off by one
Browse files Browse the repository at this point in the history
[ Upstream commit f120e62 ]

A sanity check for OOB write is off by one leading to a false positive
when the array is full.

Fixes: 9b90aca ("net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()")
Signed-off-by: Justin Chen <justin.chen@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ryceancurry authored and gregkh committed Mar 1, 2024
1 parent ae24a16 commit 7bcb0a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/broadcom/asp2/bcmasp.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,6 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
int j = 0, i;

for (i = 0; i < NUM_NET_FILTERS; i++) {
if (j == *rule_cnt)
return -EMSGSIZE;

if (!priv->net_filters[i].claimed ||
priv->net_filters[i].port != intf->port)
continue;
Expand All @@ -547,6 +544,9 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
priv->net_filters[i - 1].wake_filter)
continue;

if (j == *rule_cnt)
return -EMSGSIZE;

rule_locs[j++] = priv->net_filters[i].fs.location;
}

Expand Down

0 comments on commit 7bcb0a2

Please sign in to comment.