diff mbox series

[net,2/4] ethtool: ntuple: fix rss + ring_cookie check

Message ID 20250201013040.725123-3-kuba@kernel.org (mailing list archive)
State Accepted
Commit 2b91cc1214b165c25ac9b0885db89a0d3224028a
Delegated to: Netdev Maintainers
Headers show
Series ethtool: rss: minor fixes for recent RSS changes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
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 fail Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: habetsm.xilinx@gmail.com; 1 maintainers not CCed: habetsm.xilinx@gmail.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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

Commit Message

Jakub Kicinski Feb. 1, 2025, 1:30 a.m. UTC
The info.flow_type is for RXFH commands, ntuple flow_type is inside
the flow spec. The check currently does nothing, as info.flow_type
is 0 for ETHTOOL_SRXCLSRLINS.

Fixes: 9e43ad7a1ede ("net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ethtool/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gal Pressman Feb. 3, 2025, 3:06 p.m. UTC | #1
On 01/02/2025 3:30, Jakub Kicinski wrote:
> The info.flow_type is for RXFH commands, ntuple flow_type is inside
> the flow spec. The check currently does nothing, as info.flow_type
> is 0 for ETHTOOL_SRXCLSRLINS.

Is it zero or garbage?

> 
> Fixes: 9e43ad7a1ede ("net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Gal Pressman <gal@nvidia.com>
Joe Damato Feb. 3, 2025, 9:16 p.m. UTC | #2
On Fri, Jan 31, 2025 at 05:30:38PM -0800, Jakub Kicinski wrote:
> The info.flow_type is for RXFH commands, ntuple flow_type is inside
> the flow spec. The check currently does nothing, as info.flow_type
> is 0 for ETHTOOL_SRXCLSRLINS.

Agree with Gal; I think ethtool's stack allocated ethtool_rxnfc
could result in some garbage value being passed in for
info.flow_type.

But I don't think it's worth respinning for such a minor nit in the
commit message.

> Fixes: 9e43ad7a1ede ("net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  net/ethtool/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Joe Damato <jdamato@fastly.com>
Jakub Kicinski Feb. 3, 2025, 9:25 p.m. UTC | #3
On Mon, 3 Feb 2025 13:16:46 -0800 Joe Damato wrote:
> On Fri, Jan 31, 2025 at 05:30:38PM -0800, Jakub Kicinski wrote:
> > The info.flow_type is for RXFH commands, ntuple flow_type is inside
> > the flow spec. The check currently does nothing, as info.flow_type
> > is 0 for ETHTOOL_SRXCLSRLINS.  
> 
> Agree with Gal; I think ethtool's stack allocated ethtool_rxnfc
> could result in some garbage value being passed in for
> info.flow_type.

I admit I haven't dug into the user space side, but in the kernel
my reading is that the entire struct ethtool_rxnfc, which includes
_both_ flow_type fields gets copied in. IOW struct ethtool_rxnfc
has two flow_type fields, one directly in the struct and one inside 
the fs member.
Joe Damato Feb. 3, 2025, 9:30 p.m. UTC | #4
On Mon, Feb 03, 2025 at 01:25:19PM -0800, Jakub Kicinski wrote:
> On Mon, 3 Feb 2025 13:16:46 -0800 Joe Damato wrote:
> > On Fri, Jan 31, 2025 at 05:30:38PM -0800, Jakub Kicinski wrote:
> > > The info.flow_type is for RXFH commands, ntuple flow_type is inside
> > > the flow spec. The check currently does nothing, as info.flow_type
> > > is 0 for ETHTOOL_SRXCLSRLINS.  
> > 
> > Agree with Gal; I think ethtool's stack allocated ethtool_rxnfc
> > could result in some garbage value being passed in for
> > info.flow_type.
> 
> I admit I haven't dug into the user space side, but in the kernel
> my reading is that the entire struct ethtool_rxnfc, which includes
> _both_ flow_type fields gets copied in. IOW struct ethtool_rxnfc
> has two flow_type fields, one directly in the struct and one inside 
> the fs member.

Agree with you there; there are two fields and I think your change
is correct. I think the nit is just the wording of the commit
message as ethtool's user space stack might have some junk where
info.flow_type is (instead of 0). I only very briefly skimmed the
ethtool side, so perhaps I missed something.

In any case: IMHO, I don't think it's worth resending just for a
minor commit message tweak.
Jakub Kicinski Feb. 3, 2025, 9:39 p.m. UTC | #5
On Mon, 3 Feb 2025 13:30:17 -0800 Joe Damato wrote:
> > I admit I haven't dug into the user space side, but in the kernel
> > my reading is that the entire struct ethtool_rxnfc, which includes
> > _both_ flow_type fields gets copied in. IOW struct ethtool_rxnfc
> > has two flow_type fields, one directly in the struct and one inside 
> > the fs member.  
> 
> Agree with you there; there are two fields and I think your change
> is correct. I think the nit is just the wording of the commit
> message as ethtool's user space stack might have some junk where
> info.flow_type is (instead of 0). I only very briefly skimmed the
> ethtool side, so perhaps I missed something.

Oh, I thought you meant kernel doesn't init it.
Fair point, user space may pass garbage.
Gal Pressman Feb. 4, 2025, 6:42 a.m. UTC | #6
On 03/02/2025 23:30, Joe Damato wrote:
> On Mon, Feb 03, 2025 at 01:25:19PM -0800, Jakub Kicinski wrote:
>> On Mon, 3 Feb 2025 13:16:46 -0800 Joe Damato wrote:
>>> On Fri, Jan 31, 2025 at 05:30:38PM -0800, Jakub Kicinski wrote:
>>>> The info.flow_type is for RXFH commands, ntuple flow_type is inside
>>>> the flow spec. The check currently does nothing, as info.flow_type
>>>> is 0 for ETHTOOL_SRXCLSRLINS.  
>>>
>>> Agree with Gal; I think ethtool's stack allocated ethtool_rxnfc
>>> could result in some garbage value being passed in for
>>> info.flow_type.
>>
>> I admit I haven't dug into the user space side, but in the kernel
>> my reading is that the entire struct ethtool_rxnfc, which includes
>> _both_ flow_type fields gets copied in. IOW struct ethtool_rxnfc
>> has two flow_type fields, one directly in the struct and one inside 
>> the fs member.
> 
> Agree with you there; there are two fields and I think your change
> is correct. I think the nit is just the wording of the commit
> message as ethtool's user space stack might have some junk where
> info.flow_type is (instead of 0).

Exactly, zero vs. garbage will determine whether the check does nothing
(as written in the commit message), or have an undefined behavior.
diff mbox series

Patch

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 34bee42e1247..7609ce2b2c5e 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -993,7 +993,7 @@  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 (cmd == ETHTOOL_SRXCLSRLINS && info.flow_type & FLOW_RSS &&
+	if (cmd == ETHTOOL_SRXCLSRLINS && info.fs.flow_type & FLOW_RSS &&
 	    !ops->cap_rss_rxnfc_adds &&
 	    ethtool_get_flow_spec_ring(info.fs.ring_cookie))
 		return -EINVAL;