aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2017-07-20 11:27:57 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-08-11 08:33:56 -0700
commit747635d31fcc740eb4f32412bb66a821584ba699 (patch)
tree8822e6795e78eb4f6e83a25c107d032a01394f60 /net
parentfff61731243f6bb04005352b5723c0c74bb4fa9d (diff)
downloadlinux-yocto-4.12-747635d31fcc740eb4f32412bb66a821584ba699.tar.gz
linux-yocto-4.12-747635d31fcc740eb4f32412bb66a821584ba699.tar.bz2
linux-yocto-4.12-747635d31fcc740eb4f32412bb66a821584ba699.zip
rtnetlink: allocate more memory for dev_set_mac_address()
[ Upstream commit 153711f9421be5dbc973dc57a4109dc9d54c89b1 ] 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: David Ahern <dsahern@gmail.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/core/rtnetlink.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 099eca1524c0..52bfeb60c886 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1977,7 +1977,8 @@ 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_t(size_t, dev->addr_len,
+ sizeof(*sa));
sa = kmalloc(len, GFP_KERNEL);
if (!sa) {
err = -ENOMEM;