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 D466432BF24; Sat, 30 May 2026 16:59:51 +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=1780160393; cv=none; b=X0eHBSQRlMXLgzDUCAImEGwJ4UCwmduAdXLnpfZpX8mtJDYQgjjaVIYEhSmEtHSFruEEH7++JWMN4B3qXl62TxdCPUD61VlgCnvXJMBEpXQ/kQqCLkuCR5BBram9NeXS5WHDtPc2Zg8JoGJJA22nrH1BUX8/rBRBDwblpk4mEVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780160393; c=relaxed/simple; bh=sqzjNGib9k5QbN9xD6qPeGdIj7NVCjInoWjAf44fOl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s1gGKp6Buwaa1LFvxmRJNZXjdxxYM7SlKlIqkzyDO7bVEocCFjxfZRHZnrGQ5XeeQLIVYFWeqJRMhLtgzIx6uNjtEPAZpsMXu18jDrRdQ1BImUbjWw3mkMBPV4yiTje7pMLxJ39lHeBMWahqBFgeyN3NccBb38rFUifd0qphU28= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CtkJsDg+; 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="CtkJsDg+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4C341F00893; Sat, 30 May 2026 16:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780160391; bh=d4qhpY3la3OIv3hTWkzuCRzd1XPs//LScgN4e/DZFBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CtkJsDg+61PaMn+yV3SG3JmpZipU1gjharfzuKU0YcSRfG30QmsqNrwJy7VMV4ZwD QWLVMYA+bo79ymBll4grwZhWllmk5prRfMg1eWNGn3MEGSGEK37nLNACx2MgvtT0VR 4W+G1uFs1CKXwsB64TZPMB7S2kcjzXKjAAyzT9fI= 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 6.1 325/969] ip6_gre: Use cached t->net in ip6erspan_changelink(). Date: Sat, 30 May 2026 17:57:29 +0200 Message-ID: <20260530160309.367969412@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@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 6.1-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 @@ -2322,10 +2322,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);