]> Git Repo - linux.git/commitdiff
net: dsa: bcm_sf2: fix buffer overflow doing set_rxnfc
authorDan Carpenter <[email protected]>
Tue, 30 Apr 2019 10:44:19 +0000 (13:44 +0300)
committerDavid S. Miller <[email protected]>
Tue, 30 Apr 2019 15:02:37 +0000 (11:02 -0400)
The "fs->location" is a u32 that comes from the user in ethtool_set_rxnfc().
We can't pass unclamped values to test_bit() or it results in an out of
bounds access beyond the end of the bitmap.

Fixes: 7318166cacad ("net: dsa: bcm_sf2: Add support for ethtool::rxnfc")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/dsa/bcm_sf2_cfp.c

index e6234d20978780ea0ae2b3847cf059619b83004d..4212bc4a5f31ad8c284822567a08190ca3ef536e 100644 (file)
@@ -886,6 +886,9 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
             fs->m_ext.data[1]))
                return -EINVAL;
 
+       if (fs->location != RX_CLS_LOC_ANY && fs->location >= CFP_NUM_RULES)
+               return -EINVAL;
+
        if (fs->location != RX_CLS_LOC_ANY &&
            test_bit(fs->location, priv->cfp.used))
                return -EBUSY;
@@ -974,6 +977,9 @@ static int bcm_sf2_cfp_rule_del(struct bcm_sf2_priv *priv, int port, u32 loc)
        struct cfp_rule *rule;
        int ret;
 
+       if (loc >= CFP_NUM_RULES)
+               return -EINVAL;
+
        /* Refuse deleting unused rules, and those that are not unique since
         * that could leave IPv6 rules with one of the chained rule in the
         * table.
This page took 0.057702 seconds and 4 git commands to generate.