OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1] net/ip6_gre: fix a host panic deleting ip6gre moved into a CT without ipgre
Date: Thu,  5 Nov 2026 15:17:26 +0100	[thread overview]
Message-ID: <20261105141726.2594661-1-den@openvz.org> (raw)

From: Denis V. Lunev <den@openvz.org>

ip6gre_init_net() frees the ip6gre_net of a netns whose VE lacks
VE_FEATURE_IPGRE. Only the fallback ip6gre0 is netns_immutable, so the
host can move any other ip6gre tunnel into such a container with
"ip link set t6 netns <CT>". ip6gre_dellink() looks ign up in
dev_net(dev) and reads ign->fb_tunnel_dev, so the node panics when
container root deletes the tunnel or when the container stops and
cleanup_net() deletes it:

  BUG: kernel NULL pointer dereference, address: 0000000000000410
  RIP: 0010:ip6gre_dellink+0x37/0x60 [ip6_gre]
   default_device_exit_batch+0x8e/0x110
   cleanup_net+0x27a/0x490

Take ign from t->net, the netns the tunnel was created in and is hashed
in, as changelink, uninit and the ioctl path already do and as upstream
does since commit b7c0d393e108 ("ip6_gre: Unlink ip6gre_tunnel_unlink()
from ->dellink()."). The fallback device cannot leave its netns, so the
fb_tunnel_dev comparison keeps its meaning. ip6gretap and ip6erspan have
no ->dellink and are not affected.

Fixes: 46c13c45f25a ("net/gre: Consider VE_FEATURE_IPGRE on new net creation")

https://virtuozzo.atlassian.net/browse/VSTOR-153615
Feature: ve: per-CT features management
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 net/ipv6/ip6_gre.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 9060cb17bf25..19682f976c39 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -2124,8 +2124,8 @@ static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
 
 static void ip6gre_dellink(struct net_device *dev, struct list_head *head)
 {
-	struct net *net = dev_net(dev);
-	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
+	struct ip6_tnl *t = netdev_priv(dev);
+	struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
 
 	if (dev != ign->fb_tunnel_dev)
 		unregister_netdevice_queue(dev, head);
-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

             reply	other threads:[~2026-11-05 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 14:17 Denis V. Lunev [this message]
2026-11-05 14:43 ` no-reply

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=20261105141726.2594661-1-den@openvz.org \
    --to=den@openvz.org \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.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