ethtool: fec: sanitize ethtool_fecparam->reserved
struct ethtool_fecparam::reserved is never looked at by the core. Make sure it's actually 0. Unfortunately we can't return an error because old ethtool doesn't zero-initialize the structure for SET. On GET we can be more verbose, there are no in tree (ab)users. Fix up the kdoc on the structure. Remove the mention of FEC bypass. Seems like a niche thing to configure in the first place. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
This commit is contained in:
parent
a6e7d19a44
commit
c72d2b916b
|
@ -1378,7 +1378,7 @@ struct ethtool_per_queue_op {
|
||||||
* @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
|
* @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
|
||||||
* @active_fec: FEC mode which is active on the port
|
* @active_fec: FEC mode which is active on the port
|
||||||
* @fec: Bitmask of supported/configured FEC modes
|
* @fec: Bitmask of supported/configured FEC modes
|
||||||
* @rsvd: Reserved for future extensions. i.e FEC bypass feature.
|
* @reserved: Reserved for future extensions, ignore on GET, write 0 for SET.
|
||||||
*/
|
*/
|
||||||
struct ethtool_fecparam {
|
struct ethtool_fecparam {
|
||||||
__u32 cmd;
|
__u32 cmd;
|
||||||
|
|
|
@ -2491,6 +2491,9 @@ static int ethtool_get_fecparam(struct net_device *dev, void __user *useraddr)
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
if (WARN_ON_ONCE(fecparam.reserved))
|
||||||
|
fecparam.reserved = 0;
|
||||||
|
|
||||||
if (copy_to_user(useraddr, &fecparam, sizeof(fecparam)))
|
if (copy_to_user(useraddr, &fecparam, sizeof(fecparam)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2506,6 +2509,8 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
|
||||||
if (copy_from_user(&fecparam, useraddr, sizeof(fecparam)))
|
if (copy_from_user(&fecparam, useraddr, sizeof(fecparam)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
fecparam.reserved = 0;
|
||||||
|
|
||||||
return dev->ethtool_ops->set_fecparam(dev, &fecparam);
|
return dev->ethtool_ops->set_fecparam(dev, &fecparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue