* [PATCH net 0/3] dpaa2-eth: Fix smatch warnings
@ 2019-05-24 15:15 Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 1/3] dpaa2-eth: Fix potential spectre issue Ioana Radulescu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ioana Radulescu @ 2019-05-24 15:15 UTC (permalink / raw)
To: netdev, davem; +Cc: ioana.ciornei
Fix a couple of warnings reported by smatch.
Ioana Radulescu (3):
dpaa2-eth: Fix potential spectre issue
dpaa2-eth: Use PTR_ERR_OR_ZERO where appropriate
dpaa2-eth: Make constant 64-bit long
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++--
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 +-
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 3 +++
3 files changed, 6 insertions(+), 3 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/3] dpaa2-eth: Fix potential spectre issue
2019-05-24 15:15 [PATCH net 0/3] dpaa2-eth: Fix smatch warnings Ioana Radulescu
@ 2019-05-24 15:15 ` Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 2/3] dpaa2-eth: Use PTR_ERR_OR_ZERO where appropriate Ioana Radulescu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ioana Radulescu @ 2019-05-24 15:15 UTC (permalink / raw)
To: netdev, davem; +Cc: ioana.ciornei
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>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
index 76bd8d2..7b182f4 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;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] dpaa2-eth: Use PTR_ERR_OR_ZERO where appropriate
2019-05-24 15:15 [PATCH net 0/3] dpaa2-eth: Fix smatch warnings Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 1/3] dpaa2-eth: Fix potential spectre issue Ioana Radulescu
@ 2019-05-24 15:15 ` Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 3/3] dpaa2-eth: Make constant 64-bit long Ioana Radulescu
2019-05-26 20:41 ` [PATCH net 0/3] dpaa2-eth: Fix smatch warnings David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Ioana Radulescu @ 2019-05-24 15:15 UTC (permalink / raw)
To: netdev, davem; +Cc: ioana.ciornei
Use PTR_ERR_OR_ZERO instead of PTR_ERR in cases where
zero is a valid input. Reported by smatch.
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 28a6faa..753957e 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1972,7 +1972,7 @@ alloc_channel(struct dpaa2_eth_priv *priv)
channel->dpcon = setup_dpcon(priv);
if (IS_ERR_OR_NULL(channel->dpcon)) {
- err = PTR_ERR(channel->dpcon);
+ err = PTR_ERR_OR_ZERO(channel->dpcon);
goto err_setup;
}
@@ -2028,7 +2028,7 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
/* Try to allocate a channel */
channel = alloc_channel(priv);
if (IS_ERR_OR_NULL(channel)) {
- err = PTR_ERR(channel);
+ err = PTR_ERR_OR_ZERO(channel);
if (err != -EPROBE_DEFER)
dev_info(dev,
"No affine channel for cpu %d and above\n", i);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] dpaa2-eth: Make constant 64-bit long
2019-05-24 15:15 [PATCH net 0/3] dpaa2-eth: Fix smatch warnings Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 1/3] dpaa2-eth: Fix potential spectre issue Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 2/3] dpaa2-eth: Use PTR_ERR_OR_ZERO where appropriate Ioana Radulescu
@ 2019-05-24 15:15 ` Ioana Radulescu
2019-05-26 20:41 ` [PATCH net 0/3] dpaa2-eth: Fix smatch warnings David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Ioana Radulescu @ 2019-05-24 15:15 UTC (permalink / raw)
To: netdev, davem; +Cc: ioana.ciornei
Function dpaa2_eth_cls_key_size() expects a 64bit argument,
but DPAA2_ETH_DIST_ALL is defined as UINT_MAX. Fix this.
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
index 5fb8f5c..e180d5a 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
@@ -467,7 +467,7 @@ enum dpaa2_eth_rx_dist {
#define DPAA2_ETH_DIST_IPPROTO BIT(6)
#define DPAA2_ETH_DIST_L4SRC BIT(7)
#define DPAA2_ETH_DIST_L4DST BIT(8)
-#define DPAA2_ETH_DIST_ALL (~0U)
+#define DPAA2_ETH_DIST_ALL (~0ULL)
static inline
unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] dpaa2-eth: Fix smatch warnings
2019-05-24 15:15 [PATCH net 0/3] dpaa2-eth: Fix smatch warnings Ioana Radulescu
` (2 preceding siblings ...)
2019-05-24 15:15 ` [PATCH net 3/3] dpaa2-eth: Make constant 64-bit long Ioana Radulescu
@ 2019-05-26 20:41 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-05-26 20:41 UTC (permalink / raw)
To: ruxandra.radulescu; +Cc: netdev, ioana.ciornei
From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Date: Fri, 24 May 2019 18:15:14 +0300
> Fix a couple of warnings reported by smatch.
Series applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-26 20:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 15:15 [PATCH net 0/3] dpaa2-eth: Fix smatch warnings Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 1/3] dpaa2-eth: Fix potential spectre issue Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 2/3] dpaa2-eth: Use PTR_ERR_OR_ZERO where appropriate Ioana Radulescu
2019-05-24 15:15 ` [PATCH net 3/3] dpaa2-eth: Make constant 64-bit long Ioana Radulescu
2019-05-26 20:41 ` [PATCH net 0/3] dpaa2-eth: Fix smatch warnings David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.