From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 09076803F6 for ; Tue, 10 Nov 2026 16:33:05 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AAGVq0K016253; Tue, 10 Nov 2026 19:31:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AAGVq0K016253 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1794328315; bh=AGLAHRUl80t9OE5nChTlYJNl9hXhiayLIfyAO1CYB5E=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=MGMSaUi+AHApniBE3jTz3ckX8Pgz3iK9UVZtmL8WiD6ThiCM4/F+ns6Ejzo66v2KN VN4ReY9WtiwN5BTCCanDD4jKE7IjY9hYOFMzFnOSOiFTO453E9fsoCmsEMTa2yx5Ra hALf+TdgDkCpAPsCIbIQXjSMH1PfQPT19ZG0jWQYAvjM8AriKsrXt0GauS51jjJR0t 6qA787S8K+FRBjCdF/N9gtsong9xiVIbeaVKOx59lRJxzNVLHVHxccv1xtE43At6KM CeNloaEbefkbiG7NdBTm1DD75jGDTHXQXG0xJqrky/gR9NOR3x5cQ2LdDIuYtIvcFz A0P5g+uLAqyeQ== Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AAGVbKY016216 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 10 Nov 2026 19:31:37 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AAGVbKY016216 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="nDc9cxSp" Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a77c1cbd15so17017625e9.0 for ; Tue, 10 Nov 2026 08:31:37 -0800 (PST) X-Gm-Message-State: APuU4Z+lKYSWkIo5qTSNqx3zq/Lo5ssMUFxA5SSzkaMCt23u9NV19Xie rluA5Apv7m/z5VZgGlDaP5cTclmfMulczNlqeVuovOsudUdXLBHRXSbEVFLYVfkMyAyneRsHKcW ceZdsgdsjkbHOqBBzpnGoVOpEeoHz4jEDxM1/IOiZ9n81QZY6s4cjjA== X-Gm-Gg: AYBFou11bx994oD6noBlN0zAEqze2fAuxgMvG8tBeGdjqlBClnM+05sNYN8BuAv5wDF 3kZUCNFXdYtZOAKuTOHJQlj5svsXfndZ7ZCYmOigJ70gzo8ENEhxr5XwdW+wmXBOdivtdVL5NaM 2jbeZgKzkDzYgyigyR03OrtYGaHqErzljQwdTdT9bVlBbcc/343rwLAsKGPfL/NenEIs/+Sq9Je 5Ere8YqasFbC/LMMBMDSKuSoMycvzglJv20fNSCLw+AjQ70OX0OaQFsw7MSCI48oox2fMah8Mxv y1kcrEE2hQ== X-Received: by 2002:a05:600c:3b98:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ba02351506mr64753355e9.32.1794328297110; Tue, 10 Nov 2026 08:31:37 -0800 (PST) X-Received: by 2002:a05:600c:3b98:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ba02351506mr64752925e9.32.1794328296699; Tue, 10 Nov 2026 08:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794328296; cv=none; d=google.com; s=arc-20260327; b=BlQBMSW1iKT34Z3zt/oS5+zSwbyL0Evk9694CLwegz/A5HfmZb1Cmj8Z3iRmpOibov oJCXq+6+VkXECkV3yERbSftrfuA09TJQ3F0+bCaxL6BsIjw0ojvet6wKvMH7w+FcacBX 8qqDGVaZCGf9hBBo/yJucu8uMWv0akTD59xCL1PGRM+tQ498WvjW/FTvETX3c3ty5boo 6pMEbON23DHPLUwjlQf83vZUp7+DdK18kWMImAJOdQukOybu7bxvNlDbkM+7pVl3A1ut jeE5MNxN0K5KshpVpDum/5ROMUhBJ1rPTlO5A//SA5/O9zSsAJWLiW5cPJhLRPvaB0zJ s11w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=SX18+u7QWmK8DzTam0pvRd9GIXZAagySRyNHkyk4MdY=; fh=ozrYJQ1t3QIP6s65KBq5xgJxiFM2qf+5wwn3ABTusyU=; b=ezn8j4+VAUwuqqomqw3cY3FdKi7Dfm1AqADlLavPWl5Ck2Ds+R0OqLnjbB7Zbv5ElW JSMB+Y8av9tOo9GDX+YzA5bzI6Qm5JCcSY1qb9S0Hy44LidiWFfFLJBA9wdEdb72iHFT iECewb6jic4l8KPqC7wWA4Ju8iJtAihmXJBvum7odqlDpMnqA9OH5kV2Gab6FnJBIzXQ E2nWQ3ArXRiN3IUhFzBqBIcmHnbs+2euUtuX6OonhOrjM4wey8lNj5w6yhj+mUBWke6C atOkEF/mv6lbIEzQPJGMnzLJeKTQzq9DohjzvJ1KsR4RyLeZWNgYUX0mvCYvu65M+XAQ ljzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=nDc9cxSp; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4ba01fc06ecsor7409725e9.2.2026.11.10.08.31.36 for (Google Transport Security); Tue, 10 Nov 2026 08:31:36 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) client-ip=2a06:5b06:b600:300:4f78:6441:d0f1:22af; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=nDc9cxSp; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1794328296; x=1794933096; darn=openvz.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SX18+u7QWmK8DzTam0pvRd9GIXZAagySRyNHkyk4MdY=; b=nDc9cxSpi8Bcwoh3qM9tks6sDe62y085jqsB9oe9Zb4MtY9x2g5DQrc4VddKwWXFr1 i4OyQ6Ch6zLFpeLSi52II61O+F2DolFPMpdY/aZeHfZZNuwAT5Yn35S3lBIP67p10X9M aTayTBOesRWRioWg0YNXhqV6E82CCbLIH9xngBIXPCEihVjHiNwMmNR/fRxJd2kHEHOM +vg9x/ZRavL4RHT1RVMKn/7naiVLbcAtWJZJ4oDjgDSyxeJLOeZiO+SgTYNhru/1BcWO PK3v0XxpYpR2fzhwofXjO+W/h9wxSusvvkh72hQYNHbStpsaYOWyViOM1Ra628UdwKYX hvtQ== X-Received: by 2002:a05:600c:6089:b0:49f:e8bf:8f9b with SMTP id 5b1f17b1804b1-4ba02302e83mr52789895e9.4.1794328296151; Tue, 10 Nov 2026 08:31:36 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:4f78:6441:d0f1:22af]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ba01fdac9csm108580235e9.0.2026.11.10.08.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 08:31:35 -0800 (PST) From: "Denis V. Lunev" To: khorenko@virtuozzo.com Date: Tue, 10 Nov 2026 17:31:28 +0100 Message-ID: <20261110163130.2776687-5-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261110163130.2776687-1-den@openvz.org> References: <20261110163130.2776687-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 4/6] ms/ip6: vti: Use ip6_tnl.net in vti6_siocdevprivate(). X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Maoyi Xie After patch 1/2 in this series, vti6_update() unlinks and relinks the tunnel through t->net. vti6_siocdevprivate() still uses dev_net(dev) for the collision lookup. For a tunnel moved through IFLA_NET_NS_FD, dev_net(dev) is the new netns, not t->net. SIOCCHGTUNNEL on a migrated tunnel then runs: net = dev_net(dev) /* migrated netns */ t = vti6_locate(net, &p1, false) /* misses target in t->net */ ... t = netdev_priv(dev) vti6_update(t, &p1, false) /* mutates t->net's hash */ A caller in the migrated netns picks params that match a tunnel in the creation netns. The lookup in dev_net(dev) finds nothing. vti6_update() prepends the migrated tunnel at the head of the creation netns hash bucket for those params. Later lookups in the creation netns resolve to the migrated device. xfrm receive delivers the matched packets through a device the caller controls. Reachable from an unprivileged user namespace (unshare --user --map-root-user --net). Cross tenant scope on container hosts. Switch the SIOCCHGTUNNEL path on a non fallback device to use t->net for the lookup. The lookup now matches the netns vti6_update() operates on. Also add ns_capable(self->net->user_ns, CAP_NET_ADMIN) before the lookup. The check at the top of the case is against dev_net(dev)->user_ns, which after migration is the attacker's netns. A caller there can pick params absent from self->net, the lookup returns NULL, t becomes self, and vti6_update() inserts the device into the creation netns hash. The new check requires CAP_NET_ADMIN in the creation netns user_ns too. SIOCADDTUNNEL and SIOCCHGTUNNEL on the fallback device keep dev_net(dev), which equals init_net there. Fixes: 61220ab34948 ("vti6: Enable namespace changing") Suggested-by: Jakub Kicinski Suggested-by: Xiao Liang Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Maoyi Xie Link: https://patch.msgid.link/20260521130555.3421684-3-maoyixie.tju@gmail.com Signed-off-by: Paolo Abeni (cherry picked from commit 8b484efd5cb4eeef9021a661e198edc5349dacf6) https://virtuozzo.atlassian.net/browse/VSTOR-154348 Feature: fix ms/net Signed-off-by: Denis V. Lunev --- net/ipv6/ip6_vti.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index 6cf5d8f01c31..06fa55ddddca 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c @@ -841,17 +841,24 @@ vti6_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __user *data if (p.proto != IPPROTO_IPV6 && p.proto != 0) break; vti6_parm_from_user(&p1, &p); - t = vti6_locate(net, &p1, cmd == SIOCADDTUNNEL); if (dev != ip6n->fb_tnl_dev && cmd == SIOCCHGTUNNEL) { + struct ip6_tnl *self = netdev_priv(dev); + + err = -EPERM; + if (!ns_capable(self->net->user_ns, CAP_NET_ADMIN)) + break; + t = vti6_locate(self->net, &p1, false); if (t) { if (t->dev != dev) { err = -EEXIST; break; } } else - t = netdev_priv(dev); + t = self; err = vti6_update(t, &p1, false); + } else { + t = vti6_locate(net, &p1, cmd == SIOCADDTUNNEL); } if (t) { err = 0; -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel