diff options
author | Keller, Jacob E <jacob.e.keller@intel.com> | 2016-02-09 01:05:04 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-16 21:19:49 +0100 |
commit | 8bf3686204861d39803797ebbd1e264442421907 (patch) | |
tree | 72de52f824495cce07e7c557b5064d4e42b931e7 /net/core | |
parent | ethtool: correctly ensure {GS}CHANNELS doesn't conflict with GS{RXFH} (diff) | |
download | linux-8bf3686204861d39803797ebbd1e264442421907.tar.xz linux-8bf3686204861d39803797ebbd1e264442421907.zip |
ethtool: ensure channel counts are within bounds during SCHANNELS
Add a sanity check to ensure that all requested channel sizes are within
bounds, which should reduce errors in driver implementation.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/ethtool.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 379bdc59b1c8..65f907aea777 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -1274,15 +1274,24 @@ static noinline_for_stack int ethtool_get_channels(struct net_device *dev, static noinline_for_stack int ethtool_set_channels(struct net_device *dev, void __user *useraddr) { - struct ethtool_channels channels; + struct ethtool_channels channels, max; u32 max_rx_in_use = 0; - if (!dev->ethtool_ops->set_channels) + if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels) return -EOPNOTSUPP; if (copy_from_user(&channels, useraddr, sizeof(channels))) return -EFAULT; + dev->ethtool_ops->get_channels(dev, &max); + + /* ensure new counts are within the maximums */ + if ((channels.rx_count > max.max_rx) || + (channels.tx_count > max.max_tx) || + (channels.combined_count > max.max_combined) || + (channels.other_count > max.max_other)) + return -EINVAL; + /* ensure the new Rx count fits within the configured Rx flow * indirection table settings */ if (netif_is_rxfh_configured(dev) && |