[PATCH net 0/3] ethtool fix

STALE3502d

5 messages, 2 authors, 2017-01-18 · open the first message on its own page

[PATCH net 0/3] ethtool fix

From: Tariq Toukan <hidden>
Date: 2017-01-17 17:19:57

Hi Dave,

This patchset from Eran contains a fix to ethtool set_channels, where the call
to get_channels with an uninitialized parameter might result in garbage fields.
It also contains two followup changes in our mlx4/mlx5 Eth drivers.

Series generated against net commit:
0faa9cb5b383 net sched actions: fix refcnt when GETing of action after bind

Thanks,
Tariq.

Eran Ben Elisha (3):
  net: ethtool: Initialize buffer when querying device channel settings
  net/mlx4_en: Remove unnecessary checks when setting num channels
  net/mlx5e: Remove unnecessary checks when setting num channels

 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c      |  7 +------
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 10 ----------
 net/core/ethtool.c                                   |  2 +-
 3 files changed, 2 insertions(+), 17 deletions(-)

-- 
1.8.3.1

[PATCH net 1/3] net: ethtool: Initialize buffer when querying device channel settings

From: Tariq Toukan <hidden>
Date: 2017-01-17 17:19:56

From: Eran Ben Elisha <redacted>

Ethtool channels respond struct was uninitialized when querying device
channel boundaries settings. As a result, unreported fields by the driver
hold garbage.  This may cause sending unsupported params to driver.

Fixes: 8bf368620486 ('ethtool: ensure channel counts are within bounds ...')
Signed-off-by: Eran Ben Elisha <redacted>
Signed-off-by: Tariq Toukan <redacted>
CC: John W. Linville <redacted>
---
 net/core/ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e23766c7e3ba..236a21e3c878 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1712,7 +1712,7 @@ static noinline_for_stack int ethtool_get_channels(struct net_device *dev,
 static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
 						   void __user *useraddr)
 {
-	struct ethtool_channels channels, max;
+	struct ethtool_channels channels, max = { .cmd = ETHTOOL_GCHANNELS };
 	u32 max_rx_in_use = 0;
 
 	if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels)
-- 
1.8.3.1

[PATCH net 2/3] net/mlx4_en: Remove unnecessary checks when setting num channels

From: Tariq Toukan <hidden>
Date: 2017-01-17 17:26:44

From: Eran Ben Elisha <redacted>

Boundaries checks for the number of RX, TX, other and combined channels
should be checked by the caller and not in the driver.

In addition, remove wrong memset on get channels as it overrides the cmd
field in the requester struct.

Signed-off-by: Eran Ben Elisha <redacted>
Signed-off-by: Tariq Toukan <redacted>
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index d9c9f86a30df..d5a9372ed84d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -1732,8 +1732,6 @@ static void mlx4_en_get_channels(struct net_device *dev,
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
 
-	memset(channel, 0, sizeof(*channel));
-
 	channel->max_rx = MAX_RX_RINGS;
 	channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP;
 
@@ -1752,10 +1750,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
 	int xdp_count;
 	int err = 0;
 
-	if (channel->other_count || channel->combined_count ||
-	    channel->tx_count > MLX4_EN_MAX_TX_RING_P_UP ||
-	    channel->rx_count > MAX_RX_RINGS ||
-	    !channel->tx_count || !channel->rx_count)
+	if (!channel->tx_count || !channel->rx_count)
 		return -EINVAL;
 
 	tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
-- 
1.8.3.1

[PATCH net 3/3] net/mlx5e: Remove unnecessary checks when setting num channels

From: Tariq Toukan <hidden>
Date: 2017-01-17 17:26:44

From: Eran Ben Elisha <redacted>

Boundaries checks for the number of RX and TX should be checked by the
caller and not in the driver.

Signed-off-by: Eran Ben Elisha <redacted>
Signed-off-by: Tariq Toukan <redacted>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 10 ----------
 1 file changed, 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 33a399a8b5d5..b1b9eb6ee135 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -554,16 +554,6 @@ static int mlx5e_set_channels(struct net_device *dev,
 			    __func__);
 		return -EINVAL;
 	}
-	if (ch->rx_count || ch->tx_count) {
-		netdev_info(dev, "%s: separate rx/tx count not supported\n",
-			    __func__);
-		return -EINVAL;
-	}
-	if (count > ncv) {
-		netdev_info(dev, "%s: count (%d) > max (%d)\n",
-			    __func__, count, ncv);
-		return -EINVAL;
-	}
 
 	if (priv->params.num_channels == count)
 		return 0;
-- 
1.8.3.1

Re: [PATCH net 0/3] ethtool fix

From: David Miller <davem@davemloft.net>
Date: 2017-01-18 19:58:46

From: Tariq Toukan <redacted>
Date: Tue, 17 Jan 2017 19:19:16 +0200
This patchset from Eran contains a fix to ethtool set_channels, where the call
to get_channels with an uninitialized parameter might result in garbage fields.
It also contains two followup changes in our mlx4/mlx5 Eth drivers.

Series generated against net commit:
0faa9cb5b383 net sched actions: fix refcnt when GETing of action after bind
Looks good, series applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help