From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>,
netdev@vger.kernel.org, joe@perches.com, kubakici@wp.pl,
f.fainelli@gmail.com, davem@davemloft.net
Subject: Re: [PATCH v4 net-next 04/10] net/ncsi: Ethtool operation to get NCSI topology
Date: Thu, 4 May 2017 16:15:59 +1000 [thread overview]
Message-ID: <20170504061559.GA2162@gwshan> (raw)
In-Reply-To: <20170503221944.1dd0d576@xeon-e3>
On Wed, May 03, 2017 at 10:19:44PM -0700, Stephen Hemminger wrote:
>On Wed, 3 May 2017 14:44:35 +1000
>Gavin Shan <gwshan@linux.vnet.ibm.com> wrote:
>
>> +static int ethtool_get_ncsi_channels(struct net_device *dev,
>> + void __user *useraddr)
>
>Please don't use an opaque type for this. See how other ethtool
>operations take a struct.
>
After checking output from below command, all other ethtool operations
uses "void __user *" or "char __user *".
git grep static.*useraddr net/core/ethtool.c
>> +{
>> + struct ethtool_ncsi_channels *enc;
>> + short nr_channels;
>Should be __u16 or unsigned not short.
>
Nope, It's for signed number. User expects to get number of available
channels when negative number is passed in. When it's positive, it's
going to get the channels' information.
>> + ssize_t size = 0;
>> + int ret;
>> +
>> + if (!dev->ethtool_ops->get_ncsi_channels)
>> + return -EOPNOTSUPP;
>> +
>> + if (copy_from_user(&nr_channels, useraddr + sizeof(enc->cmd),
>> + sizeof(nr_channels)))
>> + return -EFAULT;
>> +
>> + size = sizeof(*enc);
>> + if (nr_channels > 0)
>> + size += nr_channels * sizeof(enc->id[0]);
>
>You have no upper bound on number of channels, and therefore an incorrectly
>application could grab an excessive amount of kernel memory.
>
Yeah, I'll limit it to 256 in next respin. 256 is the maximal number
of channels for one particular net device.
Cheers,
Gavin
next prev parent reply other threads:[~2017-05-04 6:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 4:44 [PATCH v4 net-next 00/10] net/ncsi: Add debugging functionality Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 01/10] net/ncsi: Disable HWA mode when no channels are found Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 02/10] net/ncsi: Properly track channel monitor timer state Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 03/10] net/ncsi: Enforce failover on link monitor timeout Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 04/10] net/ncsi: Ethtool operation to get NCSI topology Gavin Shan
2017-05-04 0:49 ` Andrew Lunn
2017-05-04 1:36 ` Gavin Shan
2017-05-04 5:19 ` Stephen Hemminger
2017-05-04 6:15 ` Gavin Shan [this message]
2017-05-04 9:31 ` David Laight
2017-05-08 0:19 ` Gavin Shan
2017-05-08 12:40 ` David Laight
2017-05-04 5:21 ` Stephen Hemminger
2017-05-04 6:17 ` Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 05/10] net/ncsi: Ethtool operation to get NCSI channel info Gavin Shan
2017-05-03 20:53 ` kbuild test robot
2017-05-03 4:44 ` [PATCH v4 net-next 06/10] net/ncsi: Ethtool operation to get NCSI hw statistics Gavin Shan
2017-05-03 12:47 ` Andrew Lunn
2017-05-03 13:18 ` David Miller
2017-05-04 0:05 ` Gavin Shan
2017-05-04 0:16 ` David Miller
2017-05-04 0:38 ` Gavin Shan
2017-05-04 0:34 ` Andrew Lunn
2017-05-04 0:55 ` Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 07/10] net/ncsi: Ethtool operation to get NCSI sw statistics Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 08/10] net/ncsi: Support NCSI packet generation Gavin Shan
2017-05-03 12:52 ` Andrew Lunn
2017-05-04 6:31 ` Gavin Shan
2017-05-04 12:00 ` Andrew Lunn
2017-05-08 0:25 ` Gavin Shan
2017-05-08 0:56 ` Andrew Lunn
2017-05-08 6:27 ` Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 09/10] net/ncsi: No error report on DP response to non-existing package Gavin Shan
2017-05-03 4:44 ` [PATCH v4 net-next 10/10] net/ncsi: Fix length of GVI response packet Gavin Shan
2017-05-03 5:25 ` [PATCH v4 net-next 00/10] net/ncsi: Add debugging functionality David Miller
2017-05-04 0:06 ` Gavin Shan
2017-05-03 12:58 ` Andrew Lunn
2017-05-04 0:09 ` Gavin Shan
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=20170504061559.GA2162@gwshan \
--to=gwshan@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=joe@perches.com \
--cc=kubakici@wp.pl \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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