Commit cda2bc91 authored by WANG Cong's avatar WANG Cong Committed by Greg Kroah-Hartman

rtnetlink: allocate more memory for dev_set_mac_address()


[ Upstream commit 153711f9 ]

virtnet_set_mac_address() interprets mac address as struct
sockaddr, but upper layer only allocates dev->addr_len
which is ETH_ALEN + sizeof(sa_family_t) in this case.

We lack a unified definition for mac address, so just fix
the upper layer, this also allows drivers to interpret it
to struct sockaddr freely.
Reported-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0c47f11b
...@@ -1965,7 +1965,8 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1965,7 +1965,8 @@ static int do_setlink(const struct sk_buff *skb,
struct sockaddr *sa; struct sockaddr *sa;
int len; int len;
len = sizeof(sa_family_t) + dev->addr_len; len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len,
sizeof(*sa));
sa = kmalloc(len, GFP_KERNEL); sa = kmalloc(len, GFP_KERNEL);
if (!sa) { if (!sa) {
err = -ENOMEM; err = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment