From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: andreyknvl@google.com, Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>
Subject: [Patch net 3/3] team: use a larger struct for mac address
Date: Tue, 25 Apr 2017 22:03:23 -0700 [thread overview]
Message-ID: <1493183003-884-4-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1493183003-884-1-git-send-email-xiyou.wangcong@gmail.com>
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.
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
drivers/net/team/team.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 85c0124..88878f1 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -60,10 +60,13 @@ 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 {
+ unsigned short type;
+ unsigned char addr[MAX_ADDR_LEN];
+ } addr;
- memcpy(addr.sa_data, dev_addr, port_dev->addr_len);
- addr.sa_family = port_dev->type;
+ memcpy(addr.addr, dev_addr, port_dev->addr_len);
+ addr.type = port_dev->type;
return dev_set_mac_address(port_dev, &addr);
}
--
2.5.5
next prev parent reply other threads:[~2017-04-26 5:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 5:03 [Patch net 0/3] net: fix a stack out-of-bound access Cong Wang
2017-04-26 5:03 ` [Patch net 1/3] net: check mac address length for dev_set_mac_address() Cong Wang
2017-04-26 5:03 ` [Patch net 2/3] bonding: use a larger struct for mac address Cong Wang
2017-04-26 5:03 ` Cong Wang [this message]
2017-04-26 5:40 ` [Patch net 3/3] team: " Jiri Pirko
2017-04-26 15:55 ` Jarod Wilson
2017-04-26 16:11 ` Cong Wang
2017-04-26 16:46 ` Jarod Wilson
2017-04-26 17:28 ` Cong Wang
2017-04-26 17:59 ` Jarod Wilson
2017-04-26 16:10 ` Cong Wang
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=1493183003-884-4-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=andreyknvl@google.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
/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).