From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF5DA261B9E; Sat, 30 May 2026 17:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163613; cv=none; b=kaHXRMxssWsMCTKbcbKv4/AebYii8/TDfyqSYohpg5/AlRpTxYHAFyIBVQ2HUCPVZ8EhN9fjG8RVIdiTVcyRw+9NL8z/UtQWV+vmltpRHcwroz1Y1ecKvA91vB+oFX6JXz2WiSYAU19V52leBxVhsRL3Uth7OemDapnKo2zLgpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163613; c=relaxed/simple; bh=zCmUv7w6+ll8NVkbKudBFEOcOO4GBiywqImLFedrqZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sqHV/BK2WjG2a7a7fERJtYTxyX4jNQDOvrfw6pgUEuHlAidmlCUukl1ECPulVt2Q3PD7JetC8evVhskerIHB1jnkSY+DJvmjTlIUukpKuXA5NVMgyjmM3aHOGHHNQFgUjPNyQZa/+p7yByzUMHN3tVUkGD+eO9m4L5Rq45CRnGY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uJuqQmeB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uJuqQmeB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF9301F00893; Sat, 30 May 2026 17:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780163612; bh=PaL0s4+QmjxCNh7e9bKcP6YzGdO3ywg7jnIE/YMe7aU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uJuqQmeBjspqZqmVvK6bqxU81FNrAGxboikzVS5GtdT6x2Y16wLxhpbBdGT+GRZ6+ 5mJToKUI/dg9XIfqZRxlVHqph7oygqT8m1Qh9iOxeYqGiIaCn/moetuLePj+x46ne/ sfQ/71HbovKqeJhqJuA0VqRPRcBfQWhMKZECucCU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maoyi Xie , Eric Dumazet , Kuniyuki Iwashima , Jakub Kicinski Subject: [PATCH 5.15 311/776] ip6_gre: Use cached t->net in ip6erspan_changelink(). Date: Sat, 30 May 2026 18:00:25 +0200 Message-ID: <20260530160248.605008009@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maoyi Xie commit 1d324c2f43f70c965f25c58cc3611c779adbe47e upstream. 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 Link: https://patch.msgid.link/20260430103318.3206018-1-maoyi.xie@ntu.edu.sg Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_gre.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2301,10 +2301,11 @@ static int ip6erspan_changelink(struct n struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct ip6_tnl *t = netdev_priv(dev); struct __ip6_tnl_parm p; - struct ip6_tnl *t; + struct ip6gre_net *ign; + ign = net_generic(t->net, ip6gre_net_id); t = ip6gre_changelink_common(dev, tb, data, &p, extack); if (IS_ERR(t)) return PTR_ERR(t);