]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.117/net-dsa-bcm_sf2-fix-buffer-overflow-doing-set_rxnfc.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.117 / net-dsa-bcm_sf2-fix-buffer-overflow-doing-set_rxnfc.patch
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
5
6 From: Dan Carpenter <dan.carpenter@oracle.com>
7
8 [ Upstream commit f949a12fd697479f68d99dc65e9bbab68ee49043 ]
9
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.
13
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>
18 ---
19 drivers/net/dsa/bcm_sf2_cfp.c | 6 ++++++
20 1 file changed, 6 insertions(+)
21
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]))
26 return -EINVAL;
27
28 + if (fs->location != RX_CLS_LOC_ANY && fs->location >= CFP_NUM_RULES)
29 + return -EINVAL;
30 +
31 if (fs->location != RX_CLS_LOC_ANY &&
32 test_bit(fs->location, priv->cfp.used))
33 return -EBUSY;
34 @@ -330,6 +333,9 @@ static int bcm_sf2_cfp_rule_del(struct b
35 int ret;
36 u32 reg;
37
38 + if (loc >= CFP_NUM_RULES)
39 + return -EINVAL;
40 +
41 /* Refuse deletion of unused rules, and the default reserved rule */
42 if (!test_bit(loc, priv->cfp.used) || loc == 0)
43 return -EINVAL;