Skip to content

Commit d059469

Browse files
congwanggregkh
authored andcommitted
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>
1 parent 31afa8b commit d059469

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

net/core/rtnetlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,8 @@ static int do_setlink(const struct sk_buff *skb,
17421742
struct sockaddr *sa;
17431743
int len;
17441744

1745-
len = sizeof(sa_family_t) + dev->addr_len;
1745+
len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len,
1746+
sizeof(*sa));
17461747
sa = kmalloc(len, GFP_KERNEL);
17471748
if (!sa) {
17481749
err = -ENOMEM;

0 commit comments

Comments
 (0)