ethtool: fec: sanitize ethtool_fecparam->fec

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2021-03-24 18:11:59 -07:00 committed by David S. Miller
parent d3b37fc805
commit 42ce127d98
1 changed files with 3 additions and 0 deletions

View File

@ -2586,6 +2586,9 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
if (copy_from_user(&fecparam, useraddr, sizeof(fecparam)))
return -EFAULT;
if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE_BIT)
return -EINVAL;
fecparam.active_fec = 0;
fecparam.reserved = 0;