diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2017-07-27 00:22:07 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-07-29 20:25:05 +0200 |
commit | 996f6e12cfb33ff6c3e39b4511bb3b8bc564b342 (patch) | |
tree | f497109f548a6bbf976af1d0cada00b06387cd73 /drivers/net/team | |
parent | net: check dev->addr_len for dev_set_mac_address() (diff) | |
download | linux-996f6e12cfb33ff6c3e39b4511bb3b8bc564b342.tar.xz linux-996f6e12cfb33ff6c3e39b4511bb3b8bc564b342.zip |
team: use a larger struct for mac address
IPv6 tunnels use sizeof(struct in6_addr) as dev->addr_len,
but in many places especially bonding, we use struct sockaddr
to copy and set mac addr, this could lead to stack out-of-bounds
access.
Fix it by using a larger address storage like bonding.
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/team')
-rw-r--r-- | drivers/net/team/team.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 464570409796..ae53e899259f 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -60,11 +60,11 @@ static struct team_port *team_port_get_rtnl(const struct net_device *dev) static int __set_port_dev_addr(struct net_device *port_dev, const unsigned char *dev_addr) { - struct sockaddr addr; + struct sockaddr_storage addr; - memcpy(addr.sa_data, dev_addr, port_dev->addr_len); - addr.sa_family = port_dev->type; - return dev_set_mac_address(port_dev, &addr); + memcpy(addr.__data, dev_addr, port_dev->addr_len); + addr.ss_family = port_dev->type; + return dev_set_mac_address(port_dev, (struct sockaddr *)&addr); } static int team_port_set_orig_dev_addr(struct team_port *port) |