Skip to content

Commit

Permalink
rtnetlink: enable IFLA_IF_NETNSID for RTM_NEWLINK
Browse files Browse the repository at this point in the history
- Backwards Compatibility:
  If userspace wants to determine whether RTM_NEWLINK supports the
  IFLA_IF_NETNSID property they should first send an RTM_GETLINK request
  with IFLA_IF_NETNSID on lo. If either EACCESS is returned or the reply
  does not include IFLA_IF_NETNSID userspace should assume that
  IFLA_IF_NETNSID is not supported on this kernel.
  If the reply does contain an IFLA_IF_NETNSID property userspace
  can send an RTM_NEWLINK with a IFLA_IF_NETNSID property. If they receive
  EOPNOTSUPP then the kernel does not support the IFLA_IF_NETNSID property
  with RTM_NEWLINK. Userpace should then fallback to other means.

- Security:
  Callers must have CAP_NET_ADMIN in the owning user namespace of the
  target network namespace.

Signed-off-by: Christian Brauner <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Christian Brauner authored and davem330 committed Jan 31, 2018
1 parent 91e6dd8 commit 5bb8ed0
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2952,14 +2952,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
name_assign_type = NET_NAME_ENUM;
}

dest_net = rtnl_link_get_net(net, tb);
dest_net = rtnl_link_get_net_capable(skb, net, tb, CAP_NET_ADMIN);
if (IS_ERR(dest_net))
return PTR_ERR(dest_net);

err = -EPERM;
if (!netlink_ns_capable(skb, dest_net->user_ns, CAP_NET_ADMIN))
goto out;

if (tb[IFLA_LINK_NETNSID]) {
int id = nla_get_s32(tb[IFLA_LINK_NETNSID]);

Expand Down

0 comments on commit 5bb8ed0

Please sign in to comment.