Message ID | 20210326020727.246828-6-kuba@kernel.org (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ethtool: clarify the ethtool FEC interface | expand |
Context | Check | Description |
---|---|---|
netdev/apply | success | Patch already applied to net-next |
netdev/tree_selection | success | Clearly marked for net-next |
On Thu, Mar 25, 2021 at 07:07:26PM -0700, Jakub Kicinski wrote: > Reject NONE on set, this mode means device does not support > FEC so it's a little out of place in the set interface. > > This should be safe to do - user space ethtool does not allow > the use of NONE on set. A few drivers treat it the same as OFF, > but none use it instead of OFF. > > Similarly reject an empty FEC mask. The common user space tool > will not send such requests and most drivers correctly reject > it already. > > v2: - use mask not bit pos > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 237ffe5440ef..26b3e7086075 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2582,14 +2582,17 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (!dev->ethtool_ops->set_fecparam) return -EOPNOTSUPP; if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; + if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE) + return -EINVAL; + fecparam.active_fec = 0; fecparam.reserved = 0; return dev->ethtool_ops->set_fecparam(dev, &fecparam); } /* The main entry point in this file. Called from net/core/dev_ioctl.c */
Reject NONE on set, this mode means device does not support FEC so it's a little out of place in the set interface. This should be safe to do - user space ethtool does not allow the use of NONE on set. A few drivers treat it the same as OFF, but none use it instead of OFF. Similarly reject an empty FEC mask. The common user space tool will not send such requests and most drivers correctly reject it already. v2: - use mask not bit pos Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- net/ethtool/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)