netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor
@ 2023-12-21 18:42 Ahmed Zaki
  2023-12-21 18:42 ` [PATCH net-next 1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh Ahmed Zaki
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ahmed Zaki @ 2023-12-21 18:42 UTC (permalink / raw)
  To: netdev
  Cc: corbet, jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Ahmed Zaki

A couple of fixes for the symmetric-xor recently merged in net-next [1].

The first patch copies the xfrm value back to user-space when ethtool is
built with --disable-netlink. The second allows ethtool to change other
RSS attributes while not changing the xfrm values.

Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/ [1]

Ahmed Zaki (2):
  net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh
  net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm

 include/uapi/linux/ethtool.h |  1 +
 net/ethtool/ioctl.c          | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh
  2023-12-21 18:42 [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor Ahmed Zaki
@ 2023-12-21 18:42 ` Ahmed Zaki
  2023-12-21 18:42 ` [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm Ahmed Zaki
  2024-01-03  0:10 ` [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: Ahmed Zaki @ 2023-12-21 18:42 UTC (permalink / raw)
  To: netdev
  Cc: corbet, jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Ahmed Zaki, Jacob Keller

The ioctl path of ethtool's get channels is missing the final step of
copying the new input_xfrm field to user-space. This should have been
part of [1].

Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/ [1]
Fixes: 13e59344fb9d ("net: ethtool: add support for symmetric-xor RSS hash")
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
---
 net/ethtool/ioctl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 86d47425038b..9adc240b8f0e 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1251,6 +1251,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
 	if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, hfunc),
 			 &rxfh_dev.hfunc, sizeof(rxfh.hfunc))) {
 		ret = -EFAULT;
+	} else if (copy_to_user(useraddr +
+				offsetof(struct ethtool_rxfh, input_xfrm),
+				&rxfh_dev.input_xfrm,
+				sizeof(rxfh.input_xfrm))) {
+		ret = -EFAULT;
 	} else if (copy_to_user(useraddr +
 			      offsetof(struct ethtool_rxfh, rss_config[0]),
 			      rss_config, total_size)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm
  2023-12-21 18:42 [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor Ahmed Zaki
  2023-12-21 18:42 ` [PATCH net-next 1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh Ahmed Zaki
@ 2023-12-21 18:42 ` Ahmed Zaki
  2024-01-03  0:05   ` Jakub Kicinski
  2024-01-03  0:10 ` [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Ahmed Zaki @ 2023-12-21 18:42 UTC (permalink / raw)
  To: netdev
  Cc: corbet, jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Ahmed Zaki, Jacob Keller

Add a NO_CHANGE uAPI value for the new RXFH/RSS input_xfrm uAPI field.
This needed so that user-space can set other RSS values (hkey or indir
table) without affecting input_xfrm.

Should have been part of [1].

Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/ [1]
Fixes: 13e59344fb9d ("net: ethtool: add support for symmetric-xor RSS hash")
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
---
 include/uapi/linux/ethtool.h | 1 +
 net/ethtool/ioctl.c          | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm
  2023-12-21 18:42 ` [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm Ahmed Zaki
@ 2024-01-03  0:05   ` Jakub Kicinski
  2024-01-03 15:40     ` Ahmed Zaki
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2024-01-03  0:05 UTC (permalink / raw)
  To: Ahmed Zaki
  Cc: netdev, corbet, jesse.brandeburg, anthony.l.nguyen, davem,
	edumazet, pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Jacob Keller

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?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor
  2023-12-21 18:42 [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor Ahmed Zaki
  2023-12-21 18:42 ` [PATCH net-next 1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh Ahmed Zaki
  2023-12-21 18:42 ` [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm Ahmed Zaki
@ 2024-01-03  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-03  0:10 UTC (permalink / raw)
  To: Ahmed Zaki
  Cc: netdev, corbet, jesse.brandeburg, anthony.l.nguyen, davem,
	edumazet, kuba, pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 21 Dec 2023 11:42:33 -0700 you wrote:
> A couple of fixes for the symmetric-xor recently merged in net-next [1].
> 
> The first patch copies the xfrm value back to user-space when ethtool is
> built with --disable-netlink. The second allows ethtool to change other
> RSS attributes while not changing the xfrm values.
> 
> Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/ [1]
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh
    https://git.kernel.org/netdev/net-next/c/7c402f77e8cb
  - [net-next,2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm
    https://git.kernel.org/netdev/net-next/c/0dd415d15505

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm
  2024-01-03  0:05   ` Jakub Kicinski
@ 2024-01-03 15:40     ` Ahmed Zaki
  2024-01-03 22:16       ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: Ahmed Zaki @ 2024-01-03 15:40 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, corbet, jesse.brandeburg, anthony.l.nguyen, davem,
	edumazet, pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Jacob Keller



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).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm
  2024-01-03 15:40     ` Ahmed Zaki
@ 2024-01-03 22:16       ` Jakub Kicinski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2024-01-03 22:16 UTC (permalink / raw)
  To: Ahmed Zaki
  Cc: netdev, corbet, jesse.brandeburg, anthony.l.nguyen, davem,
	edumazet, pabeni, vladimir.oltean, andrew, horms, mkubecek,
	willemdebruijn.kernel, gal, alexander.duyck, ecree.xilinx,
	Jacob Keller

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-01-03 22:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21 18:42 [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor Ahmed Zaki
2023-12-21 18:42 ` [PATCH net-next 1/2] net: ethtool: copy input_xfrm to user-space in ethtool_get_rxfh Ahmed Zaki
2023-12-21 18:42 ` [PATCH net-next 2/2] net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm Ahmed Zaki
2024-01-03  0:05   ` Jakub Kicinski
2024-01-03 15:40     ` Ahmed Zaki
2024-01-03 22:16       ` Jakub Kicinski
2024-01-03  0:10 ` [PATCH net-next 0/2] Bug fixes for RSS symmetric-xor patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).