Skip to content

Commit a5838cf

Browse files
q2venPaolo Abeni
authored andcommitted
rtnetlink: Call validate_linkmsg() in do_setlink().
There are 3 paths that finally call do_setlink(), and validate_linkmsg() is called in each path. 1. RTM_NEWLINK 1-1. dev is found in __rtnl_newlink() 1-2. dev isn't found, but IFLA_GROUP is specified in rtnl_group_changelink() 2. RTM_SETLINK The next patch factorises 1-1 to a separate function. As a preparation, let's move validate_linkmsg() calls to do_setlink(). Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent fa8ef25 commit a5838cf

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

net/core/rtnetlink.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,10 @@ static int do_setlink(const struct sk_buff *skb,
28552855
char ifname[IFNAMSIZ];
28562856
int err;
28572857

2858+
err = validate_linkmsg(dev, tb, extack);
2859+
if (err < 0)
2860+
goto errout;
2861+
28582862
if (tb[IFLA_IFNAME])
28592863
nla_strscpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
28602864
else
@@ -3269,10 +3273,6 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
32693273
goto errout;
32703274
}
32713275

3272-
err = validate_linkmsg(dev, tb, extack);
3273-
if (err < 0)
3274-
goto errout;
3275-
32763276
err = do_setlink(skb, dev, ifm, extack, tb, 0);
32773277
errout:
32783278
return err;
@@ -3516,9 +3516,6 @@ static int rtnl_group_changelink(const struct sk_buff *skb,
35163516

35173517
for_each_netdev_safe(net, dev, aux) {
35183518
if (dev->group == group) {
3519-
err = validate_linkmsg(dev, tb, extack);
3520-
if (err < 0)
3521-
return err;
35223519
err = do_setlink(skb, dev, ifm, extack, tb, 0);
35233520
if (err < 0)
35243521
return err;
@@ -3744,10 +3741,6 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
37443741
if (nlh->nlmsg_flags & NLM_F_REPLACE)
37453742
return -EOPNOTSUPP;
37463743

3747-
err = validate_linkmsg(dev, tb, extack);
3748-
if (err < 0)
3749-
return err;
3750-
37513744
if (linkinfo[IFLA_INFO_DATA]) {
37523745
if (!ops || ops != dev->rtnl_link_ops ||
37533746
!ops->changelink)

0 commit comments

Comments
 (0)