From: Jakub Kicinski Date: Thu, 25 Mar 2021 01:11:58 +0000 (-0700) Subject: ethtool: fec: sanitize ethtool_fecparam->active_fec X-Git-Tag: v5.15~1236^2~397^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3b37fc805d9ef697451730ebdfc7e35e6c2ace8;p=platform%2Fkernel%2Flinux-starfive.git ethtool: fec: sanitize ethtool_fecparam->active_fec struct ethtool_fecparam::active_fec is a GET-only field, all in-tree drivers correctly ignore it on SET. Clear the field on SET to avoid any confusion. Again, we can't reject non-zero now since ethtool user space does not zero-init the param correctly. Signed-off-by: Jakub Kicinski Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller --- diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 9e2682a..517b68c 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1378,7 +1378,7 @@ struct ethtool_per_queue_op { /** * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * @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, GET only. * @fec: Bitmask of supported/configured FEC modes * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET. */ diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index be35490..237ffe54 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2586,6 +2586,7 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; + fecparam.active_fec = 0; fecparam.reserved = 0; return dev->ethtool_ops->set_fecparam(dev, &fecparam);