Skip to contentSkip to conversation

dpaa2-eth: prevent array underflow in update_cls_rule()

PATCH Applied Dan Carpenter 2 participants 2 messages May 8, 2020 – May 9, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dpaa2-eth: prevent array underflow in update_cls_rule()

The "location" is controlled by the user via the ethtool_set_rxnfc() function. This update_cls_rule() function checks for array overflows but it doesn't check if the value is negative. I have changed the type to unsigned to prevent array underflows.

Fixes afb90dbb5f78 ("dpaa2-eth: Add ethtool support for flow classification")
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +1 -1
index bd13ee48d6230..049afd1d6252d 100644
@@ -635,7 +635,7 @@ static int num_rules(struct dpaa2_eth_priv *priv)
 
 static int update_cls_rule(struct net_device *net_dev,
 			   struct ethtool_rx_flow_spec *new_fs,
-			   int location)
+			   unsigned int location)
 {
 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 	struct dpaa2_eth_cls_rule *rule;
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 7 lines · On Fri, 8 May 2020 17:37:20 +0300 Dan Carpenter wrote:

The "location" is controlled by the user via the ethtool_set_rxnfc() function. This update_cls_rule() function checks for array overflows but it doesn't check if the value is negative. I have changed the type to unsigned to prevent array underflows.

Fixes afb90dbb5f78 ("dpaa2-eth: Add ethtool support for flow classification")

Applied, thank you!