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