From: Phil Sutter <phil@nwl.cc>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>, Thomas Graf <tgraf@suug.ch>
Subject: [PATCH] net: rtnetlink: be more strict when setting MAC address
Date: Mon, 17 Aug 2015 23:06:47 +0200 [thread overview]
Message-ID: <1439845607-2824-1-git-send-email-phil@nwl.cc> (raw)
Upon evaluation of IFLA_ADDRESS and IFLA_BROADCAST messages, make sure
the passed argument length matches dev->addr_len exactly.
This fixes dubious behaviour of 'ip link set eth0 addr <MAC>' where
'<MAC>' is too long, e.g. '00:11:22:33:44:55:66:77'. Called like this,
'ip' would return successfully and the kernel sets eth0's MAC address to
the leading six octets of the passed argument.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
net/core/rtnetlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 788ceed..1d61cd1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1456,11 +1456,11 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
{
if (dev) {
if (tb[IFLA_ADDRESS] &&
- nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
+ nla_len(tb[IFLA_ADDRESS]) != dev->addr_len)
return -EINVAL;
if (tb[IFLA_BROADCAST] &&
- nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
+ nla_len(tb[IFLA_BROADCAST]) != dev->addr_len)
return -EINVAL;
}
--
2.1.2
next reply other threads:[~2015-08-17 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-17 21:06 Phil Sutter [this message]
2015-08-17 21:09 ` [PATCH] net: rtnetlink: be more strict when setting MAC address David Miller
2015-08-17 23:23 ` Phil Sutter
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=1439845607-2824-1-git-send-email-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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).