rtnl_newlink() lacks a CAP_NET_ADMIN capability check on the peer network namespace when creating paired devices (veth, vxcan, netkit). This allows an unprivileged user with a user namespace to create interfaces in arbitrary network namespaces, including init_net. Add a netlink_ns_capable() check for CAP_NET_ADMIN in the peer namespace before allowing device creation to proceed. Fixes: 48327566769a ("rtnetlink: fix double call of rtnl_link_get_net_ifla()") Reported-by: Nikolaos Gkarlis Signed-off-by: Nikolaos Gkarlis --- net/core/rtnetlink.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 576d5ec3bb36..f3a7d6dbd713 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4030,8 +4030,15 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, ret = PTR_ERR(peer_net); goto put_ops; } - if (peer_net) + if (peer_net) { + if (!netlink_ns_capable(skb, peer_net->user_ns, + CAP_NET_ADMIN)) { + put_net(peer_net); + ret = -EPERM; + goto put_ops; + } rtnl_nets_add(&rtnl_nets, peer_net); + } } } -- 2.34.1