From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2973D2D73A6 for ; Thu, 11 Jun 2026 06:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781159302; cv=none; b=YEcDcLSROwWrLLkUBYYtLKH7J7NTRhn+KophIJycHxgDP3SYyanhyPQv2w7fjHqhAylHbJr4fUGe/en32yyJS8fBI+DhSusBsfwUFU1hlgC10FuPt+QhZ6jC3oBZzOKFtPZB+CGRbls3WuBZB3tXQPx3MoGEy7O6OvLn3njzgSk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781159302; c=relaxed/simple; bh=ABoF11LlsjDImEw0o01Srl9sxas+dXW8rwIo0VibxEc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Ykv5Vi04SgfgYm/L25m4ABCTC9n+UQ7/ZmI28GVQ2Z7O07D/uR29JPDJ8w74zAaXhJPHFkaGfwkWz8jghc1sAlas5g5ch7huJEovXohgu2JTQXW2EYFoflqNFkQKEmweAoCSk0lALkih3RW7q6DtPu6Xw/AnWygBQMrxq8EYegQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l3RkNECM; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l3RkNECM" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2c0c2a68d01so50878175ad.1 for ; Wed, 10 Jun 2026 23:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781159299; x=1781764099; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FKHDbTRgcEA8qLlfBQUFErqZeMY2tu7A8JF88+7Bp4w=; b=l3RkNECM5FfUFpqSDDFIUENv3a1Eo2a+uYFO2u9U5X9a/ASFmNjDmfXR3O8RruskIt dkUTgYtzny5JquUyprUQ58nqo6ptMOHQ+ybSQUla1pTeWoy3PVrQ//pcbl7jgo68KpZj QmxIR/5aSScusWaDxczdO21WZMZHKY77aMYWSQ4yKxYKt2uiqmuMiJVtVoeSg5lWmKak W8pfbwlqyZoPa1Sa+cjtws5xaPFDSJRQO3oF9lO7LTb/6mPn/9rwQTb6yLUmpGDaXoO7 0TBAExRREgzy+Tc7rAmLBtgMpOFFIqjdtg+P3Evs6K4klB5/WZMB7IMqdSVyiDHA0ZlX OvOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781159299; x=1781764099; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FKHDbTRgcEA8qLlfBQUFErqZeMY2tu7A8JF88+7Bp4w=; b=ni9z/6FOUY/QCB1rR10IrxZgp5VddtHgcsZKEcw6NyipcxPhf3SC9Co8zTleD7xJzp QojWx/PbUTpFen7w4ypn43eOgHiFkKyRdTPMDm474LLFt+TSmhTVaZwPNwN3I/cqz2sN gFDzC1MrrxqLcF26op6O6fDyqkanH3Nn6oB59ipVuwx12PVdyVfJLB/mPSdTP+wi3zQz +vvsv1PV4BmXCrPFXn0i9QLU9M2B9DLUHLyIqYeE7HPqD/nj0LIGTI/O6uvoCZtQqxSW qGf7RmaBOKPjkIxIKp1k59l5/FjtOq6VRzzwUeVrd1qkK7aJ1gYQ/gjLz2wsn6StIKNy P5TQ== X-Forwarded-Encrypted: i=1; AFNElJ/FBvgp3Hsj+micpSUz4qqIykGl3C0/w91Vfv2ZG59FB3jvMLSnIctDKe9ucgugN5qE5gfgtHMpxtVCJzs=@vger.kernel.org X-Gm-Message-State: AOJu0YwXw2xlQCvkvpheHIAKD1XKUmKfQL3d++jM4MQ9tASWbXOMJI6n JqST2GWrXrN8Yjm8nJQopYHBbIol0m2RnM0zGpR6dt3Cixx7L5Su9XYV X-Gm-Gg: Acq92OHGc5ULvPoSsYXI+/OKS+PBKYof2eh/Tjo84nDVaC3RACDCsemycHsNCmG5mZ9 s6UpUhBMVKaf18S+YQjwrQUDArdjfJS7A2iHzI5vexWRQO7F6DLrKQtbX1Z++guG4K/Yf8EyPyo hznRLzbO22vbzxuxFkPIDL/qS+yCOJXbkVB2lZT+CuAzriJqlwktq08exBB/1J55kUlB+Lx2yHH feTwr54YFDuE8rjKt/Zd729v0lkxZMUdV5LQslkyjOxhlUhA5LPtjNMU4/K8fLBNczXcq2GDky9 /9+Af1dHYzEGKgBo+fo1YKoXCpp4V+LMs9WpPIz17yWY0uu5mbkQEVnhD1DoXSi/0KifJtMKk9m XSEQ+lyawGZbspYdqx8NQoYlQrGwM78RHPC8xFkxG7xfta/Wzgs8H00ugfU/FjsbeuCneBRIR0C HbXT1zud8juM2RWfD2oMJ4MeNUjYH91GbIl8uhMFY2yRRKkMGE0IRl3Iv/x+Y= X-Received: by 2002:a17:902:e88f:b0:2b0:b016:773f with SMTP id d9443c01a7336-2c2f10174dfmr15989465ad.11.1781159299332; Wed, 10 Jun 2026 23:28:19 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f6d2bbsm282891565ad.1.2026.06.10.23.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 23:28:18 -0700 (PDT) From: Maoyi Xie To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Kuniyuki Iwashima , Xiao Liang , Steffen Klassert , Herbert Xu , Simon Horman , 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 Message-Id: <20260611062814.2528793-1-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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