Message ID | 20231221184235.9192-3-ahmed.zaki@intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 0dd415d155050f5c1cf360b97f905d42d44f33ed |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Bug fixes for RSS symmetric-xor | expand |
On Thu, 21 Dec 2023 11:42:35 -0700 Ahmed Zaki wrote: > + rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE && > + rxfh.input_xfrm == RXH_XFRM_NO_CHANGE)) This looks fine, but we also need a check to make sure input_xfrm doesn't have bits other than RXH_XFRM_SYM_XOR set, right?
On 2024-01-02 17:05, Jakub Kicinski wrote: > On Thu, 21 Dec 2023 11:42:35 -0700 Ahmed Zaki wrote: >> + rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE && >> + rxfh.input_xfrm == RXH_XFRM_NO_CHANGE)) > > This looks fine, but we also need a check to make sure input_xfrm > doesn't have bits other than RXH_XFRM_SYM_XOR set, right? I wrote the xfrm as a bitmap/flags assuming we can have multiple transformations set. Not sure what future transformations will look like (other than RSS-sort,... and discussed before). Else, we can do the check you mentioned or may be better to have it as enum (which would give us 256, not 8, allowable transformations).
On Wed, 3 Jan 2024 08:40:47 -0700 Ahmed Zaki wrote: > On 2024-01-02 17:05, Jakub Kicinski wrote: > > On Thu, 21 Dec 2023 11:42:35 -0700 Ahmed Zaki wrote: > >> + rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE && > >> + rxfh.input_xfrm == RXH_XFRM_NO_CHANGE)) > > > > This looks fine, but we also need a check to make sure input_xfrm > > doesn't have bits other than RXH_XFRM_SYM_XOR set, right? > > I wrote the xfrm as a bitmap/flags assuming we can have multiple > transformations set. Not sure what future transformations will look like > (other than RSS-sort,... and discussed before). Ack, but right now the only valid inputs for the kernel are 0 (disable all), RXH_XFRM_NO_CHANGE and RXH_XFRM_SYM_XOR. We need to reject all other inputs. If we accept random inputs without validation we won't be able to use them later. Refer to many LWN articles about how some syscall didn't check that unused flags are 0 and now they can't allocate bits. Because some user space was passing in garbage. > Else, we can do the check you mentioned or may be better to have it as > enum (which would give us 256, not 8, allowable transformations). Given that RXH_XFRM_SYM_XOR is 1 we can change the exact semantics later. All that matters is that we reject unsupported for now.
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 0787d561ace0..361c96653632 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -2002,6 +2002,7 @@ static inline int ethtool_validate_duplex(__u8 duplex) * be exploited to reduce the RSS queue spread. */ #define RXH_XFRM_SYM_XOR (1 << 0) +#define RXH_XFRM_NO_CHANGE 0xff /* L2-L4 network traffic flow types */ #define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 9adc240b8f0e..4c4f46dfc251 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1304,14 +1304,16 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, return -EOPNOTSUPP; /* If either indir, hash key or function is valid, proceed further. - * Must request at least one change: indir size, hash key or function. + * Must request at least one change: indir size, hash key, function + * or input transformation. */ if ((rxfh.indir_size && rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE && rxfh.indir_size != dev_indir_size) || (rxfh.key_size && (rxfh.key_size != dev_key_size)) || (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE && - rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE)) + rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE && + rxfh.input_xfrm == RXH_XFRM_NO_CHANGE)) return -EINVAL; if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)