]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vxlan: require CAP_NET_ADMIN in the device netns for changelink
authorDoruk Tan Ozturk <doruk@0sec.ai>
Thu, 16 Jul 2026 20:34:59 +0000 (22:34 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Jul 2026 15:17:08 +0000 (08:17 -0700)
A tunnel changelink() operates on at most two netns, dev_net(dev) and
the sticky underlay netns vxlan->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 vxlan->net can rewrite a vxlan
device whose underlay lives in vxlan->net.

vxlan_changelink() validates and applies the new configuration against
vxlan->net (vxlan_config_validate(vxlan->net, ...)) and can reopen the
underlay socket in that netns, so the same reasoning as the tunnel
changelink series applies here.

Gate vxlan_changelink() with rtnl_dev_link_net_capable(), at the top of
the op before any attribute is parsed, matching ipgre_changelink() and
the rest of the "require CAP_NET_ADMIN in the device netns for
changelink" series.

Found by 0sec automated security-research tooling (https://0sec.ai).

Fixes: 8bcdc4f3a20b ("vxlan: add changelink support")
Cc: stable@vger.kernel.org
Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Link: https://patch.msgid.link/20260716203500.70573-2-doruk@0sec.ai
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vxlan/vxlan_core.c

index 67c367cc566233e809b0f70e0d939dd1c1ac0d9f..d834a4865aecc7f39fc01cde779a5acd5d0ddc1c 100644 (file)
@@ -4421,6 +4421,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
        struct vxlan_rdst *dst;
        int err;
 
+       if (!rtnl_dev_link_net_capable(dev, vxlan->net))
+               return -EPERM;
+
        dst = &vxlan->default_dst;
        err = vxlan_nl2conf(tb, data, dev, &conf, true, extack);
        if (err)