From 42ce127d98641f2cb19cd499b5b3beb472c7eff1 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Wed, 24 Mar 2021 18:11:59 -0700 Subject: 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 Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: David S. Miller --- net/ethtool/ioctl.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'net/ethtool') diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 237ffe5440ef..8797533ddc4b 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -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; -- cgit v1.2.3