From nobody Tue Jun 16 17:04:05 2026 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 6CBA3373BE4 for ; Thu, 30 Apr 2026 10:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777545205; cv=none; b=SDT2Z2aLcc6OOc7pQ2KgYB+czsmJX+AGAKwWCfny6KUGtr/azfbLIqzD2er+Lp8Z5/d0N4poMbHOIjHA8da8ZgxCS1C88aFeFkXl+wJjE3W7/tdYZ40CiXB6Jp9SVvcVPu6heSUHKkM5hAjOJJ5vFTYN31px3wR6pXc9ne7P+TA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777545205; c=relaxed/simple; bh=HmJDuI15pv/V4UFD9ngUIjPrqHL42c/sRO/HoYWBlO0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=S+tMPrCmP1CVa5tfdcYt1iIBtnl/SbpLmj85qtQjd7QfJ2NVkhoWHZFJ6UEY8a8MNQLSyQ+v6oNvERCM3PTbCJjdJ9KpvOOJxzuBFcZ4dJUhDhhcsCrWiTTwBuJMp81Jo1lM91tDNmJ/McWu8GKtocqkaOIMFhD/6t7yDhYRpuA= 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=CwfosyMi; arc=none smtp.client-ip=209.85.216.43 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="CwfosyMi" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-35fc2b18363so765500a91.0 for ; Thu, 30 Apr 2026 03:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777545204; x=1778150004; 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=zlQdc9ZGGOy1nWwQGOqT37EUu8/n7T3oBCrdhsUWNlU=; b=CwfosyMiQX58roqtRTYo8NNy1EBVH+rybYqrkB1n+FpN/maTjzJnD9l3UEh8P6AYTX QCulFfig+79Yu+dt92WKu33J7WJ88dwKrO1yrl0QSTVAxOhdMr+QtA0Ob3KAU5WMGhSE gYULiU5RJLnO8oFjCdgMbS1vacGGuEqFT2VZjhLCvT5nXHBwnoRwG+42/2ksGlYv2s2W ZWZrRE6Ag0dxoR+vdaDfgpbiJG9KMO30dGrmBURSZQakBtn96RVTLyNCLnpnnD6SCypX C9yAMIFWjgOaamfSYVGYgjqIHoDvXSWQ3aw90GxxPu9RjWvkvecxTPJb8hD0hnIwbIwv rU6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777545204; x=1778150004; 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=zlQdc9ZGGOy1nWwQGOqT37EUu8/n7T3oBCrdhsUWNlU=; b=PZtBDrQYjgylvatiLWjmwxO3SGfewlu8u3jOWQIOKwuSO37dKBkm24jJ1gqIAVq8bk 2K7Xo83Du1z8Vy2iC0SRfm/Z5S8Vh4dQ1LFiP38ca84uTuvEi+KP38gA7GdblZBiTqs/ 997qtK0F5/3JbhBaFNHquEY8HUiNMjrDbiwoERuEb9x3oIc+Lwvh/h74rxru56EaYE6W aE5m/6QMM/uT6F3XoN1bfrxwChjwto2TlA7LncpiMahx45sGm4VH+Lr/iVDNvFXN8MZn 2um4N3P/nhZMlDxqT61DOptEFPMgIvNpuVKaXc38MESCXaDgRw1wvaJxryA9PyqtSgdm Wfpg== X-Forwarded-Encrypted: i=1; AFNElJ+V1Ojfc4KL+Pt1aQ9eXqlJsVix+74FdSKFwFH4tMNcgOP7akpcpjA3MgxrcimJUtK798Bl++TLVOE9FRA=@vger.kernel.org X-Gm-Message-State: AOJu0YwlDs988sL9mCuJJgFsIft1o8hGlXfQsfq+LHEZD5DoqEEeOV8Z JQCVL/Wgzd1LbYD0pefOhVcqkk9593JA7RW6n/HJWwYVlfSzC+ZQXY3X X-Gm-Gg: AeBDietC+pubP9Dp0hb0sSSCSGQWVPEjuuXchCDHcl2IRrLeIZIyK12YTtwj5Tsnja5 CNsYCZcZIKmcSOZqsGR9HQfEZIbeC5fCg9ZSM+NdPMMbRinCI+QaZcezPr93OYAt8iNfp7k7U/k qg2FaMZBHL+zQoRFLZ1ZW88+XTwJp7Pvgqi11g77Lgh6OHkKbhnFwJ5jispgqZ9DnU9bJJ0pUDn Aouj+uD+Y4b+8KUJOMUkg9axu1HhehkWKETX2qicyLLhhqczA9IJZpd9vc+LnRmhKIvophjO8Xh Vcm2XmJo2zoETySy5gFCP3NKsX1FnIedKw2cSS+nJz7d2g+w7p+DyG9WLglRiNhGFzcWTaLu1E1 UCz2DLo++aAX+Xw5fOvqnkYN2b0KSiT7H1a7ZYjTJpBwHG4SURb0xsBRtvQluBCRaGVNkL8NwAV aTgU5lF+1xr/fpsg7mAaVWUj+hkm0xCazxSVa57XD2K/eLfbEmNU7QPh4n X-Received: by 2002:a17:90b:57d0:b0:362:eaa6:a3a2 with SMTP id 98e67ed59e1d1-364c309b029mr2403183a91.19.1777545203681; Thu, 30 Apr 2026 03:33:23 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364bdf5312fsm2486218a91.6.2026.04.30.03.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 03:33:23 -0700 (PDT) From: Maoyi Xie X-Google-Original-From: Maoyi Xie To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, dsahern@kernel.org, horms@kernel.org, willemb@google.com, kuniyu@google.com, shaw.leon@gmail.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v2] ip6_gre: Use cached t->net in ip6erspan_changelink(). Date: Thu, 30 Apr 2026 18:33:18 +0800 Message-Id: <20260430103318.3206018-1-maoyi.xie@ntu.edu.sg> 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: quoted-printable Content-Type: text/plain; charset="utf-8" After commit 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_ops"), ip6erspan_newlink() correctly resolves the per-netns ip6gre hash via link_net. ip6erspan_changelink() was not converted in that series and still uses dev_net(dev), which diverges from the device's creation netns after IFLA_NET_NS_FD migration. This re-inserts the tunnel into the wrong per-netns hash. The original netns keeps a stale entry. When that netns is later destroyed, ip6gre_exit_rtnl_net() walks the stale entry, producing a slab-use-after-free reported by KASAN, followed by a kernel BUG at net/core/dev.c (LIST_POISON1) in unregister_netdevice_many_notify(). Reachable from an unprivileged user namespace (unshare --user --map-root-user --net). ip6gre_changelink() earlier in the same file already uses the cached t->net; only ip6erspan_changelink() has the wrong shape. Fixes: 2d665034f239 ("net: ip6_gre: Fix ip6erspan hlen calculation") Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Maoyi Xie Reviewed-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- v2 (this submission, addressing v1 review): - Fixes: changed to 2d665034f239 ("net: ip6_gre: Fix ip6erspan hlen calculation"), the commit that introduced the divergent ip6erspan_changelink() shape (per Xiao Liang). - dropped Reported-by since the SOB is the same person (per Kuniyuki Iwashima). - reverse xmas tree local variable order; reused *t instead of shadowing it (per Kuniyuki Iwashima). - added Reviewed-by Eric Dumazet, Reviewed-by Kuniyuki Iwashima. v1: originally posted as [PATCH net 2/2] of the "ipv6: tunnel changelink: use cached netns pointer" series. The sibling patch ([PATCH net 1/2] vti6_changelink) is being handled in its own thread. net/ipv6/ip6_gre.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index dafcc0dcd..0097d4784 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2261,10 +2261,11 @@ static int ip6erspan_changelink(struct net_device *= dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6gre_net *ign =3D net_generic(dev_net(dev), ip6gre_net_id); + struct ip6_tnl *t =3D netdev_priv(dev); struct __ip6_tnl_parm p; - struct ip6_tnl *t; + struct ip6gre_net *ign; =20 + ign =3D net_generic(t->net, ip6gre_net_id); t =3D ip6gre_changelink_common(dev, tb, data, &p, extack); if (IS_ERR(t)) return PTR_ERR(t); --=20 2.34.1