From: Tariq Toukan <tariqt@mellanox.com>
To: Jakub Kicinski <kubakici@wp.pl>, Tariq Toukan <tariqt@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Eran Ben Elisha <eranbe@mellanox.com>,
Eugenia Emantayev <eugenia@mellanox.com>
Subject: Re: [PATCH net-next 1/3] ethtool: Ensure new ring parameters are within bounds during SRINGPARAM
Date: Tue, 9 Jan 2018 09:30:05 +0200 [thread overview]
Message-ID: <d87fd32a-474f-fccf-fecc-29301e592869@mellanox.com> (raw)
In-Reply-To: <20180108182342.084c5d60@cakuba.netronome.com>
On 09/01/2018 4:23 AM, Jakub Kicinski wrote:
> On Mon, 8 Jan 2018 16:00:24 +0200, Tariq Toukan wrote:
>> From: Eugenia Emantayev <eugenia@mellanox.com>
>>
>> Add a sanity check to ensure that all requested ring parameters
>> are within bounds, which should reduce errors in driver implementation.
>
> (y)
>
>> Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>> ---
>> net/core/ethtool.c | 13 +++++++++++--
>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
>> index 50a79203043b..9ea7cd52fde0 100644
>> --- a/net/core/ethtool.c
>> +++ b/net/core/ethtool.c
>> @@ -1704,14 +1704,23 @@ static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
>>
>> static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
>> {
>> - struct ethtool_ringparam ringparam;
>> + struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM };
>>
>> - if (!dev->ethtool_ops->set_ringparam)
>> + if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam)
>> return -EOPNOTSUPP;
>>
>> if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
>> return -EFAULT;
>>
>> + dev->ethtool_ops->get_ringparam(dev, &max);
>
> Perhaps check the return value here? It's pretty unlikely but
> get_ringparam may fail.
>
get_ringparam NDO returns void.
>> + /* ensure new ring parameters are within the maximums */
>> + if (ringparam.rx_pending > max.rx_max_pending ||
>> + ringparam.rx_mini_pending > max.rx_mini_max_pending ||
>> + ringparam.rx_jumbo_pending > max.rx_jumbo_max_pending ||
>> + ringparam.tx_pending > max.tx_max_pending)
>> + return -EINVAL;
>> +
>> return dev->ethtool_ops->set_ringparam(dev, &ringparam);
>> }
>>
next prev parent reply other threads:[~2018-01-09 7:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 14:00 [PATCH net-next 0/3] ethtool ringparam upper bound Tariq Toukan
2018-01-08 14:00 ` [PATCH net-next 1/3] ethtool: Ensure new ring parameters are within bounds during SRINGPARAM Tariq Toukan
2018-01-09 2:23 ` Jakub Kicinski
2018-01-09 7:30 ` Tariq Toukan [this message]
2018-01-09 7:35 ` Jakub Kicinski
2018-01-08 14:00 ` [PATCH net-next 2/3] net/mlx4_en: Align behavior of set ring size flow via ethtool Tariq Toukan
2018-01-08 14:00 ` [PATCH net-next 3/3] net/mlx5e: Remove redundant checks in set_ringparam Tariq Toukan
2018-01-09 16:55 ` [PATCH net-next 0/3] ethtool ringparam upper bound David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d87fd32a-474f-fccf-fecc-29301e592869@mellanox.com \
--to=tariqt@mellanox.com \
--cc=davem@davemloft.net \
--cc=eranbe@mellanox.com \
--cc=eugenia@mellanox.com \
--cc=kubakici@wp.pl \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox