From: Maoyi Xie <maoyixie.tju@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: David Ahern <dsahern@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Xiao Liang <shaw.leon@gmail.com>,
Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH net v5 0/7] net: require CAP_NET_ADMIN in the device netns for tunnel changelink
Date: Thu, 11 Jun 2026 14:28:07 +0800 [thread overview]
Message-ID: <20260611062814.2528793-1-maoyixie.tju@gmail.com> (raw)
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.
v4 -> v5, addressing Kuniyuki Iwashima's review:
- Move the helper to net/core/rtnetlink.c next to
rtnl_get_net_ns_capable(), rename it to
rtnl_dev_link_net_capable(dev, link_net), and drop the kdoc.
- Reword each commit message to state that changelink() operates on at
most two netns, dev_net(dev) and the link netns.
v4: https://lore.kernel.org/netdev/20260609163110.1717419-1-maoyixie.tju@gmail.com/
v3: https://lore.kernel.org/netdev/20260604125055.3254652-1-maoyixie.tju@gmail.com/
v2: https://lore.kernel.org/netdev/20260601034148.1272080-1-maoyixie.tju@gmail.com/
v1: https://lore.kernel.org/netdev/20260527070824.2677331-1-maoyixie.tju@gmail.com/
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
--
2.34.1
next reply other threads:[~2026-06-11 6:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 6:28 Maoyi Xie [this message]
2026-06-11 6:28 ` [PATCH net v5 1/7] net: ip_gre: require CAP_NET_ADMIN in the device netns for changelink Maoyi Xie
2026-06-12 6:41 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 2/7] net: ipip: " Maoyi Xie
2026-06-12 6:45 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 3/7] net: ip_vti: " Maoyi Xie
2026-06-12 6:48 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 4/7] net: ip6_tunnel: " Maoyi Xie
2026-06-12 6:55 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 5/7] net: ip6_gre: " Maoyi Xie
2026-06-12 6:55 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 6/7] net: ip6_vti: " Maoyi Xie
2026-06-12 7:00 ` Kuniyuki Iwashima
2026-06-11 6:28 ` [PATCH net v5 7/7] xfrm: xfrm_interface: " Maoyi Xie
2026-06-12 7:01 ` Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260611062814.2528793-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaw.leon@gmail.com \
--cc=stable@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®