From: Parav Pandit <parav@mellanox.com>
To: David Miller <davem@davemloft.net>,
"dan.carpenter@oracle.com" <dan.carpenter@oracle.com>
Cc: Jiri Pirko <jiri@mellanox.com>,
"dsahern@gmail.com" <dsahern@gmail.com>,
Ido Schimmel <idosch@mellanox.com>,
Petr Machata <petrm@mellanox.com>,
"jakub.kicinski@netronome.com" <jakub.kicinski@netronome.com>,
"nikolay@cumulusnetworks.com" <nikolay@cumulusnetworks.com>,
"roopa@cumulusnetworks.com" <roopa@cumulusnetworks.com>,
"johannes.berg@intel.com" <johannes.berg@intel.com>,
"mkubecek@suse.cz" <mkubecek@suse.cz>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH net] net: rtnetlink: prevent underflows in do_setvfinfo()
Date: Fri, 22 Nov 2019 07:21:22 +0000 [thread overview]
Message-ID: <a3f851fb-e148-d386-e9dd-29e7d89c93fa@mellanox.com> (raw)
In-Reply-To: <20191121.144429.649625073638417068.davem@davemloft.net>
On 11/21/2019 4:44 PM, David Miller wrote:
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Date: Wed, 20 Nov 2019 15:34:38 +0300
>
>> The "ivm->vf" variable is a u32, but the problem is that a number of
>> drivers cast it to an int and then forget to check for negatives. An
>> example of this is in the cxgb4 driver.
>>
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> 2890 static int cxgb4_mgmt_get_vf_config(struct net_device *dev,
>> 2891 int vf, struct ifla_vf_info *ivi)
>> ^^^^^^
>> 2892 {
>> 2893 struct port_info *pi = netdev_priv(dev);
>> 2894 struct adapter *adap = pi->adapter;
>> 2895 struct vf_info *vfinfo;
>> 2896
>> 2897 if (vf >= adap->num_vfs)
>> ^^^^^^^^^^^^^^^^^^^
>> 2898 return -EINVAL;
>> 2899 vfinfo = &adap->vfinfo[vf];
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> There are 48 functions affected.
> ...
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> I'm going to apply this and queue it up for -stable.
>
> The u32 conversion should happen in next.
okay.
When Dan reported, I reviewed and wrote the patch for u32, and some more
code consolidation with it.
But hit the block with u32 leading to overflow to 0 which modifies the
first VF incorrectly.
Checking num_vfs of pci dev, without device_lock() is equally buggy as
it stands today.
Creating a lock in each vendor driver(s) doesn't make sense.
Haven't had chance yet after that.
Let me know if someone has a suggestion that I should incorporate.
prev parent reply other threads:[~2019-11-22 7:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 12:34 [PATCH net] net: rtnetlink: prevent underflows in do_setvfinfo() Dan Carpenter
2019-11-20 16:41 ` David Ahern
2019-11-20 18:07 ` Dan Carpenter
2019-11-21 22:44 ` David Miller
2019-11-22 7:21 ` Parav Pandit [this message]
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=a3f851fb-e148-d386-e9dd-29e7d89c93fa@mellanox.com \
--to=parav@mellanox.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@mellanox.com \
--cc=johannes.berg@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=petrm@mellanox.com \
--cc=roopa@cumulusnetworks.com \
/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;
as well as URLs for NNTP newsgroup(s).