Message ID | 20210326020727.246828-6-kuba@kernel.org |
---|---|
State | New |
Headers | show |
Series | ethtool: clarify the ethtool FEC interface | expand |
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(+)