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 94CFB811BB for ; Wed, 4 Nov 2026 20:29:28 +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 6A4KSD1X026751; Wed, 4 Nov 2026 23:28:13 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4KSD1X026751 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793824095; bh=p2eMGzx8utQZw4TByttTA1OMtTYM15kpksawV/5gJt0=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=tEJOnzLlLQ1F3BBam+yIy8U87Ut7leIDZ7fRQVhCh6koD7nqzQYJeCGI8/axVFKTC u0CkuheaY7UpxzccB7A0USfdU65mjNihcml10UXfHJfWGCcOWgdAeFbheCEb6rULQp ivDwbVO32cNcl6yvUVAPSYqqDt6vTtGnKfC4HAx+aAi32P03w99u6Q/4wcDwZDrlbw c96jbPoVLlEcurECqSSfgWbQw4pG5evIqjLvMw5FmHdyv83MO9+M+vVeiLY16yfXWl 5zqbQz3Lg8A/ATxEqn1CF7bPKETc6k+FRDSLbsfrwtBQ39kzJhtO2jqA+X4mOyB0OE Z46r7eb2YGOZQ== Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A4KSBrD026747 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 4 Nov 2026 23:28:11 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4KSBrD026747 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="ooZj+Pxk" Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5bfe13ad5f4so757343e87.2 for ; Wed, 04 Nov 2026 12:28:11 -0800 (PST) X-Gm-Message-State: APuU4Z+phwvhvDHQN5J1p7QrP+/Vhbs3ais73Grw6M5RkC2/bWBj0Lrs Ka5V/uaRCZPQTJsuXpJ1WxD+e87kFBEnp08zeuUFbGSl3bWemRXnRgcKl+FrY0rU9edD7BYT12B zvuqY+cf0/Tv7uvOz5QN4IGxoNh/Tk7YtTCM2/BkIFCw6A1VUcKbh3g== X-Gm-Gg: AYBFou0/5jiXiSJlGZMKLX1sVvhHZm1PyUE2oWeN56QDjLopuOhWxazmw01g79f4o8H k8cAHO1JCiActX6KqYRh/tGUZol8z4nF2F4aVPCy424AfHJpLzye3ORk0v/foB9b77Wmp8wtP4p ye0C/EKeQSE8tFyX8uU93I6qFpaSZArq27Y1j1uNlpwokHb2Safu09jstkWW9H2DKJWBCrkEtSd 3QDISF11nzTrbyneTFGuncvaOjqFcde0Mo7MeV+gncIs+xNdzClQbboQKfxeJa+ZquNtRDLCaRh de0GVLNVmg== X-Received: by 2002:a05:600c:8b85:b0:49f:e8bf:8f9b with SMTP id 5b1f17b1804b1-4ac14fbdcf7mr353093415e9.4.1793822878952; Wed, 04 Nov 2026 12:07:58 -0800 (PST) X-Received: by 2002:a05:600c:8b85:b0:49f:e8bf:8f9b with SMTP id 5b1f17b1804b1-4ac14fbdcf7mr353093205e9.4.1793822878531; Wed, 04 Nov 2026 12:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793822878; cv=none; d=google.com; s=arc-20260327; b=MQ/qRjG76zi6mn8t8Y1fWSz0JEbDjdrhVs07O1qS87MuBrtjW9gsMARhUgrovOQdkx +LaAZ+Xb3pkzaMJpoBajVvZQeuOtkwnI2n/867wTaSOuIpl/rfhnXJUBD2aGCOt/OsaV 2cFjGcWwxUaMrP+0dCfCmg7bUTKoXzZdDsrNH+ci4GbtCT4xknseaQjrOvOFtEgTgXFd 0vHuwCDE4nzV3bn19FMnn7hMEDnJlcDd6LRvsb8CXOf63dIYNy8XILF5JX4MvHh7z1Zd Bw6H1KR1xRcLzvOvaKUKOVMN4rh4EqBY2M585Ik0bixTCkRQZ1kCGccIy6Di5su+49it fLcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=/XPlogmRKp2uw2A6OXx0SKEkE8+O1ZrBosY+/hv+1Ls=; fh=ozrYJQ1t3QIP6s65KBq5xgJxiFM2qf+5wwn3ABTusyU=; b=KXB/uPxy9ey7WX3z5CkFmLv72jOYm6RgPr6sY0RIw+72/oElZSXb4kW7TGoxxEvzgN lFQK+UWK0Z4BwQgEM/3fdprzPEYmT6WnZFxaPFq9j3NtXEA0k3zfa78avm47IMfXGG3y q4T3NWUDSWXC90dxbN0bmpl4ZhUYvNxpF4Op3LGUE57W1qzoLmC1KB4ZqTIH6mEIjIaX X9Ukf8sOHI3j0mrhgb0jYrmMdNVv4Fbivh3CswnjDScwVc50AF1kgBpNrZxtmn+v9xce Z30oOY5O5P6ITABwateGePtua7x0MyQ/wqJt3RZQepCY8RNY6DI/YPL/kbO5WRjcepPt 6wdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=ooZj+Pxk; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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-4b43d6b62bcsor6447175e9.8.2026.11.04.12.07.58 for (Google Transport Security); Wed, 04 Nov 2026 12:07:58 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 as permitted sender) client-ip=2a06:5b06:b600:300:162e:5a6e:fd46:18b7; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=ooZj+Pxk; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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=1793822878; x=1794427678; darn=openvz.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=/XPlogmRKp2uw2A6OXx0SKEkE8+O1ZrBosY+/hv+1Ls=; b=ooZj+PxkZdU5EJbdxTy5jsW/Iw33widpfBd/drd0uBUhMkbd9vrsUEoqtCAKrcsmAq A1p30sZC0zlloEfXMQm9Zd5CShoIkygipjha8uDb6Is3be+5Prorsz7FFbQaa+VSkdRf 1JUbZcaGiaHiWFtDpPRyzOVHlJbLpAK2nM5dzRbflJ6vmEwzTyYsrrXAvX6+x9pXnPhC aU//fYFh8py9kphFl5sfuRnqH91MwKfPRZ8MOC9lhUbMBA5sdD+xcwTD3CTPFvLRoNAi kulSmELQsxQbvc8F3kbwrRw1DSKnmrFnibfeWkUrV/aLd1azibrRM2cmHBdTSHY5vg8p zZIA== X-Received: by 2002:a05:600c:840e:b0:4a1:813f:2a60 with SMTP id 5b1f17b1804b1-4ac17d168b1mr425433035e9.11.1793822878001; Wed, 04 Nov 2026 12:07:58 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:162e:5a6e:fd46:18b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b5725061e1sm8387925e9.7.2026.11.04.12.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 12:07:57 -0800 (PST) From: "Denis V. Lunev" To: khorenko@virtuozzo.com Date: Wed, 4 Nov 2026 21:07:55 +0100 Message-ID: <20261104200755.1956316-1-den@openvz.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1] net/ip6_gre: fix a host panic adding ip6gre in a CT without ipgre 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: Denis V. Lunev ip6gre_init_net() frees the ip6gre_net of a netns whose VE lacks VE_FEATURE_IPGRE, and ip6gre_newlink_common() refuses such a netns with -EACCES. ip6gre_newlink() and ip6erspan_newlink() reach the NULL ip6gre_net first, through ip6gre_tunnel_find() or collect_md_tun, so "ip link add type ip6gre" by root in an ordinary container panics the node once ip6_gre is loaded: BUG: kernel NULL pointer dereference, address: 0000000000000320 RIP: 0010:ip6gre_tunnel_find+0x46/0xd0 [ip6_gre] ip6gre_newlink+0x9b/0x120 [ip6_gre] The check went into ip6gre_newlink_common(), which ran the tunnel lookup until upstream commit b80d0b93b991 ("net: ip6_gre: fix tunnel metadata device sharing.") moved the lookup into the newlink handlers. Move the check to the top of both handlers. They are the only callers of ip6gre_newlink_common() and serve as newlink for all three link types (ip6gre, ip6gretap and ip6erspan), and nothing else in the helper uses ip6gre_net. Fixes: 46c13c45f25a ("net/gre: Consider VE_FEATURE_IPGRE on new net creation") https://virtuozzo.atlassian.net/browse/VSTOR-149645 Feature: ve: per-CT features management Signed-off-by: Denis V. Lunev --- net/ipv6/ip6_gre.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 9060cb17bf25..4a0fc86d9a10 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2003,15 +2003,6 @@ static int ip6gre_newlink_common(struct net *src_net, struct net_device *dev, struct ip6_tnl *nt; struct ip_tunnel_encap ipencap; int err; -#ifdef CONFIG_VE - struct net *net = dev_net(dev); - struct ip6gre_net *ign; - - ign = net_generic(net, ip6gre_net_id); - - if (!ign) /* no VE_FEATURE_IPGRE */ - return -EACCES; -#endif nt = netdev_priv(dev); @@ -2048,8 +2039,13 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev, struct ip6gre_net *ign; int err; - ip6gre_netlink_parms(data, &nt->parms); ign = net_generic(net, ip6gre_net_id); +#ifdef CONFIG_VE + if (!ign) /* no VE_FEATURE_IPGRE */ + return -EACCES; +#endif + + ip6gre_netlink_parms(data, &nt->parms); if (nt->parms.collect_md) { if (rtnl_dereference(ign->collect_md_tun)) @@ -2284,9 +2280,14 @@ static int ip6erspan_newlink(struct net *src_net, struct net_device *dev, struct ip6gre_net *ign; int err; + ign = net_generic(net, ip6gre_net_id); +#ifdef CONFIG_VE + if (!ign) /* no VE_FEATURE_IPGRE */ + return -EACCES; +#endif + ip6gre_netlink_parms(data, &nt->parms); ip6erspan_set_version(data, &nt->parms); - ign = net_generic(net, ip6gre_net_id); if (nt->parms.collect_md) { if (rtnl_dereference(ign->collect_md_tun_erspan)) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel