Skip to content

Commit 7195f0e

Browse files
kuba-moodavem330
authored andcommitted
ethtool: fix setting key and resetting indir at once
The indirection table and the key follow struct ethtool_rxfh in user memory. To reset the indirection table user space calls SET_RXFH with table of size 0 (OTOH to say "no change" it should use -1 / ~0). The logic for calculating the offset where they key sits is incorrect in this case, as kernel would still offset by the full table length, while for the reset there is no indir table and key is immediately after the struct. $ ethtool -X eth0 default hkey 01:02:03... $ ethtool -x eth0 [...] RSS hash key: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 [...] Fixes: 3de0b59 ("ethtool: Support for configurable RSS hash key") Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9dbad38 commit 7195f0e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ethtool/ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,13 +1331,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
13311331
u32 rss_cfg_offset = offsetof(struct ethtool_rxfh, rss_config[0]);
13321332
const struct ethtool_ops *ops = dev->ethtool_ops;
13331333
u32 dev_indir_size = 0, dev_key_size = 0, i;
1334+
u32 user_indir_len = 0, indir_bytes = 0;
13341335
struct ethtool_rxfh_param rxfh_dev = {};
13351336
struct ethtool_rxfh_context *ctx = NULL;
13361337
struct netlink_ext_ack *extack = NULL;
13371338
struct ethtool_rxnfc rx_rings;
13381339
struct ethtool_rxfh rxfh;
13391340
bool locked = false; /* dev->ethtool->rss_lock taken */
1340-
u32 indir_bytes = 0;
13411341
bool create = false;
13421342
u8 *rss_config;
13431343
int ret;
@@ -1400,6 +1400,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
14001400
*/
14011401
if (rxfh.indir_size &&
14021402
rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
1403+
user_indir_len = indir_bytes;
14031404
rxfh_dev.indir = (u32 *)rss_config;
14041405
rxfh_dev.indir_size = dev_indir_size;
14051406
ret = ethtool_copy_validate_indir(rxfh_dev.indir,
@@ -1426,7 +1427,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
14261427
rxfh_dev.key_size = dev_key_size;
14271428
rxfh_dev.key = rss_config + indir_bytes;
14281429
if (copy_from_user(rxfh_dev.key,
1429-
useraddr + rss_cfg_offset + indir_bytes,
1430+
useraddr + rss_cfg_offset + user_indir_len,
14301431
rxfh.key_size)) {
14311432
ret = -EFAULT;
14321433
goto out;

0 commit comments

Comments
 (0)