Skip to content

net: require CAP_NET_ADMIN in the device netns for tunnel changelink

Maoyi Xie lkml netdev stable 5 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest7 patches 0 repliesApplied 7/7
  2. v57 patches 7 repliesSuperseded
  3. v47 patches 1 replySuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v31 patch1 replySuperseded
v21 patch3 repliesSuperseded

Patches in v6 All 7 applied

#Subject and filesSizeRepliesApplied
1/7net: ip_gre: require CAP_NET_ADMIN in the device netns for changelinkinclude/net/rtnetlink.h net/core/rtnetlink.c net/ipv4/ip_gre.c+16 -00 repliesApplied
2/7net: ipip: require CAP_NET_ADMIN in the device netns for changelinknet/ipv4/ipip.c+3 -00 repliesApplied
3/7net: ip_vti: require CAP_NET_ADMIN in the device netns for changelinknet/ipv4/ip_vti.c+3 -00 repliesApplied
4/7net: ip6_tunnel: require CAP_NET_ADMIN in the device netns for changelinknet/ipv6/ip6_tunnel.c+3 -00 repliesApplied
5/7net: ip6_gre: require CAP_NET_ADMIN in the device netns for changelinknet/ipv6/ip6_gre.c+6 -00 repliesApplied
6/7net: ip6_vti: require CAP_NET_ADMIN in the device netns for changelinknet/ipv6/ip6_vti.c+3 -00 repliesApplied
7/7xfrm: xfrm_interface: require CAP_NET_ADMIN in the device netns for changelinknet/xfrm/xfrm_interface_core.c+3 -00 repliesApplied

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchKuniyuki Iwashima
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH net v6 0/7] net: require CAP_NET_ADMIN in the device netns for tunnel changelink

A tunnel changelink() operates on at most two netns, dev_net(dev) and the tunnel link netns t->net. They differ once the device is created in or moved to a netns other than the one the request runs in. The rtnl changelink path checks CAP_NET_ADMIN only against dev_net(dev), so a caller privileged there but not in the link netns can rewrite a tunnel that lives in the link netns. Commit 8b484efd5cb4 ("ip6: vti: Use ip6_tnl.net in vti6_siocdevprivate().") added the same check on the ioctl path. This series adds it on the RTM_NEWLINK path.

Each changelink is gated at the top of the op, before any attribute is parsed, because the per-type parsers can update live tunnel fields first (for example ipgre_netlink_parms() sets t->collect_md). The check is skipped when the link netns is dev_net(dev), where the rtnl path already checked the cap.

The check goes through a new helper, rtnl_dev_link_net_capable(), added in patch 1 next to rtnl_get_net_ns_capable() in net/core/rtnetlink.c.

Tested on net/main. For every tunnel type in the series a migrated fake-root changelink is rejected with EPERM. For vti6 SIOCGETTUNNEL confirms the link netns hash is left unchanged. Legit non-migrated changelinks still succeed.

v5 -> v6, addressing Kuniyuki Iwashima's review:
- Correct the Fixes: tags to the commits that first added x-netns support / namespace changing for each tunnel type, where the cap gap has existed, instead of the later "fix namespaces move" commits.
- Add Kuniyuki Iwashima's Reviewed-by to all patches.

v5: https://lore.kernel.org/netdev/[email protected]/
v4: https://lore.kernel.org/netdev/[email protected]/
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/

Maoyi Xie (7):
net: ip_gre: require CAP_NET_ADMIN in the device netns for changelink
net: ipip: require CAP_NET_ADMIN in the device netns for changelink
net: ip_vti: require CAP_NET_ADMIN in the device netns for changelink
net: ip6_tunnel: require CAP_NET_ADMIN in the device netns for
changelink
net: ip6_gre: require CAP_NET_ADMIN in the device netns for changelink
net: ip6_vti: require CAP_NET_ADMIN in the device netns for changelink
xfrm: xfrm_interface: require CAP_NET_ADMIN in the device netns for
changelink

 include/net/rtnetlink.h        | 2 ++
 net/core/rtnetlink.c           | 8 ++++++++
 net/ipv4/ip_gre.c              | 6 ++++++
 net/ipv4/ip_vti.c              | 3 +++
 net/ipv4/ipip.c                | 3 +++
 net/ipv6/ip6_gre.c             | 6 ++++++
 net/ipv6/ip6_tunnel.c          | 3 +++
 net/ipv6/ip6_vti.c             | 3 +++
 net/xfrm/xfrm_interface_core.c | 3 +++
 9 files changed, 37 insertions(+)

base-commit: 512db8267b73a220a64180d95ab5eebe7c4964a8

Signature · 1 line
2.34.1