From: David Ahern <dsahern@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: out-of-bounds access with virtio-net
Date: Wed, 19 Jul 2017 12:33:34 -0600 [thread overview]
Message-ID: <79f22f18-893e-58f6-ec16-e5ebdde8ed62@gmail.com> (raw)
In-Reply-To: <CAM_iQpUUPhGRkac5eJb7PwG-EGGjf9fpcdfJO1L3QMhiMMUBtg@mail.gmail.com>
On 7/19/17 12:23 PM, Cong Wang wrote:
> On Wed, Jul 19, 2017 at 9:59 AM, David Ahern <dsahern@gmail.com> wrote:
>> Changing the mac address on a virtio-net based nic is triggering an
>> out-of-bounds access. Nothing fancy with the command:
>>
>> ip li set dev eth2 addr 01:02:34:56:78:9a
>>
>> virtnet_set_mac_address is calling kmemdup for sizeof sockaddr, yet only
>> ETH_ALEN + sizeof(sa_family_t) bytes were malloc'ed.
>
> Previously we have a dev->addr_len longer than sizeof sockaddr,
> now we a shorter one... This mac addr thing is really a mess currently.
>
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index d1ba90980be1..d13bebdf6465 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2031,7 +2031,7 @@ static int do_setlink(const struct sk_buff *skb,
> struct sockaddr *sa;
> int len;
>
> - len = sizeof(sa_family_t) + dev->addr_len;
> + len = sizeof(sa_family_t) + max(dev->addr_len, sizeof(*sa));
> sa = kmalloc(len, GFP_KERNEL);
> if (!sa) {
> err = -ENOMEM;
>
seems reasonable. I am heading to the mountains in a few hours; won't
have time to test until Friday. Please submit formally; no need to wait
for me.
prev parent reply other threads:[~2017-07-19 18:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-19 16:59 out-of-bounds access with virtio-net David Ahern
2017-07-19 18:23 ` Cong Wang
2017-07-19 18:33 ` David Ahern [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=79f22f18-893e-58f6-ec16-e5ebdde8ed62@gmail.com \
--to=dsahern@gmail.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.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).