diff mbox series

[net] ethtool: Fix access to uninitialized fields in set RXNFC command

Message ID 20241202164805.1637093-1-gal@nvidia.com (mailing list archive)
State Accepted
Commit 94071909477677fc2a1abf3fb281f203f66cf3ca
Delegated to: Netdev Maintainers
Headers show
Series [net] ethtool: Fix access to uninitialized fields in set RXNFC command | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: habetsm.xilinx@gmail.com; 2 maintainers not CCed: habetsm.xilinx@gmail.com ahmed.zaki@intel.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 304 this patch: 304
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-02--18-00 (tests: 760)

Commit Message

Gal Pressman Dec. 2, 2024, 4:48 p.m. UTC
The check for non-zero ring with RSS is only relevant for
ETHTOOL_SRXCLSRLINS command, in other cases the check tries to access
memory which was not initialized by the userspace tool. Only perform the
check in case of ETHTOOL_SRXCLSRLINS.

Without this patch, filter deletion (for example) could statistically
result in a false error:
  # ethtool --config-ntuple eth3 delete 484
  rmgr: Cannot delete RX class rule: Invalid argument
  Cannot delete classification rule

Fixes: 9e43ad7a1ede ("net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in")
Link: https://lore.kernel.org/netdev/871a9ecf-1e14-40dd-bbd7-e90c92f89d47@nvidia.com/
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 net/ethtool/ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Edward Cree Dec. 2, 2024, 5:28 p.m. UTC | #1
On 02/12/2024 16:48, Gal Pressman wrote:
> The check for non-zero ring with RSS is only relevant for
> ETHTOOL_SRXCLSRLINS command, in other cases the check tries to access
> memory which was not initialized by the userspace tool. Only perform the
> check in case of ETHTOOL_SRXCLSRLINS.
> 
> Without this patch, filter deletion (for example) could statistically
> result in a false error:
>   # ethtool --config-ntuple eth3 delete 484
>   rmgr: Cannot delete RX class rule: Invalid argument
>   Cannot delete classification rule
> 
> Fixes: 9e43ad7a1ede ("net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in")
> Link: https://lore.kernel.org/netdev/871a9ecf-1e14-40dd-bbd7-e90c92f89d47@nvidia.com/
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
> Signed-off-by: Gal Pressman <gal@nvidia.com>

Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
patchwork-bot+netdevbpf@kernel.org Dec. 4, 2024, 3:10 a.m. UTC | #2
Hello:

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

On Mon, 2 Dec 2024 18:48:05 +0200 you wrote:
> The check for non-zero ring with RSS is only relevant for
> ETHTOOL_SRXCLSRLINS command, in other cases the check tries to access
> memory which was not initialized by the userspace tool. Only perform the
> check in case of ETHTOOL_SRXCLSRLINS.
> 
> Without this patch, filter deletion (for example) could statistically
> result in a false error:
>   # ethtool --config-ntuple eth3 delete 484
>   rmgr: Cannot delete RX class rule: Invalid argument
>   Cannot delete classification rule
> 
> [...]

Here is the summary with links:
  - [net] ethtool: Fix access to uninitialized fields in set RXNFC command
    https://git.kernel.org/netdev/net/c/940719094776

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 61df8ce44379..7bb94875a7ec 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -993,7 +993,8 @@  static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
 		return rc;
 
 	/* Nonzero ring with RSS only makes sense if NIC adds them together */
-	if (info.flow_type & FLOW_RSS && !ops->cap_rss_rxnfc_adds &&
+	if (cmd == ETHTOOL_SRXCLSRLINS && info.flow_type & FLOW_RSS &&
+	    !ops->cap_rss_rxnfc_adds &&
 	    ethtool_get_flow_spec_ring(info.fs.ring_cookie))
 		return -EINVAL;