Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 86298
b: refs/heads/master
c: 1840bb1
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Graf authored and David S. Miller committed Feb 24, 2008
1 parent f0cc400 commit 897c5ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 759afc31332aed66bde20743e7e2d1e47b08aaeb
refs/heads/master: 1840bb13c22f5b8fd2e242e36c8d6ea3f312be67
25 changes: 19 additions & 6 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,21 @@ static struct net *get_net_ns_by_pid(pid_t pid)
return net;
}

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)
return -EINVAL;

if (tb[IFLA_BROADCAST] &&
nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
return -EINVAL;
}

return 0;
}

static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
Expand Down Expand Up @@ -894,12 +909,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
goto errout;
}

if (tb[IFLA_ADDRESS] &&
nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
goto errout_dev;

if (tb[IFLA_BROADCAST] &&
nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
if ((err = validate_linkmsg(dev, tb)) < 0)
goto errout_dev;

err = do_setlink(dev, ifm, tb, ifname, 0);
Expand Down Expand Up @@ -1020,6 +1030,9 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
else
dev = NULL;

if ((err = validate_linkmsg(dev, tb)) < 0)
return err;

if (tb[IFLA_LINKINFO]) {
err = nla_parse_nested(linkinfo, IFLA_INFO_MAX,
tb[IFLA_LINKINFO], ifla_info_policy);
Expand Down

0 comments on commit 897c5ef

Please sign in to comment.