diff options
author | Ioana Radulescu <ruxandra.radulescu@nxp.com> | 2019-05-24 18:15:15 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-26 13:41:33 -0700 |
commit | 5a20a093d965560f632b2ec325f8876918f78165 (patch) | |
tree | ce16c6cf0d67fee47b55a09796769a442f92117e /drivers | |
parent | 334031219a84b9994594015aab85ed7754c80176 (diff) | |
download | linux-stable-5a20a093d965560f632b2ec325f8876918f78165.tar.gz linux-stable-5a20a093d965560f632b2ec325f8876918f78165.tar.bz2 linux-stable-5a20a093d965560f632b2ec325f8876918f78165.zip |
dpaa2-eth: Fix potential spectre issue
Smatch reports a potential spectre vulnerability in the dpaa2-eth
driver, where the value of rxnfc->fs.location (which is provided
from user-space) is used as index in an array.
Add a call to array_index_nospec() to sanitize the access.
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index 76bd8d2872cc..7b182f4b263c 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -4,6 +4,7 @@ */ #include <linux/net_tstamp.h> +#include <linux/nospec.h> #include "dpni.h" /* DPNI_LINK_OPT_* */ #include "dpaa2-eth.h" @@ -648,6 +649,8 @@ static int dpaa2_eth_get_rxnfc(struct net_device *net_dev, case ETHTOOL_GRXCLSRULE: if (rxnfc->fs.location >= max_rules) return -EINVAL; + rxnfc->fs.location = array_index_nospec(rxnfc->fs.location, + max_rules); if (!priv->cls_rules[rxnfc->fs.location].in_use) return -EINVAL; rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs; |