1 From foo@baz Sat 04 May 2019 11:25:56 AM CEST
2 From: Dan Carpenter <dan.carpenter@oracle.com>
3 Date: Tue, 30 Apr 2019 13:44:19 +0300
4 Subject: net: dsa: bcm_sf2: fix buffer overflow doing set_rxnfc
6 From: Dan Carpenter <dan.carpenter@oracle.com>
8 [ Upstream commit f949a12fd697479f68d99dc65e9bbab68ee49043 ]
10 The "fs->location" is a u32 that comes from the user in ethtool_set_rxnfc().
11 We can't pass unclamped values to test_bit() or it results in an out of
12 bounds access beyond the end of the bitmap.
14 Fixes: 7318166cacad ("net: dsa: bcm_sf2: Add support for ethtool::rxnfc")
15 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 drivers/net/dsa/bcm_sf2_cfp.c | 6 ++++++
20 1 file changed, 6 insertions(+)
22 --- a/drivers/net/dsa/bcm_sf2_cfp.c
23 +++ b/drivers/net/dsa/bcm_sf2_cfp.c
24 @@ -130,6 +130,9 @@ static int bcm_sf2_cfp_rule_set(struct d
25 (fs->m_ext.vlan_etype || fs->m_ext.data[1]))
28 + if (fs->location != RX_CLS_LOC_ANY && fs->location >= CFP_NUM_RULES)
31 if (fs->location != RX_CLS_LOC_ANY &&
32 test_bit(fs->location, priv->cfp.used))
34 @@ -330,6 +333,9 @@ static int bcm_sf2_cfp_rule_del(struct b
38 + if (loc >= CFP_NUM_RULES)
41 /* Refuse deletion of unused rules, and the default reserved rule */
42 if (!test_bit(loc, priv->cfp.used) || loc == 0)