From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384139; b=GQDgPmJFQ70ZqLKBGkb1arLeuQv9FMLCpcuFnimVQeP+Kpuv30byikm9RBZqIyHOLGU8 Z5O67w2A3Klk5EllUTTvUaq2xntYtYzGwfAOg7iKZn96iysGR99o822v9CCVhKyMO7Oys EjHslkNruplZ2YamsrA7az8tHAvl6cjG9p1vccFyTKEs9iLP954C1SsV+xIt/8o0fIFrm B3giKYCi3HyrGpswj71jqveyuotn3cyK+I+WcXoyyHECR4nDNpjuf3FodO6Y8YxOxf2Wx nMjKrtgEAmcz0mnHn5AH8tr3DcnjnVsyQeIyIcCjFfhd4OC7at0s/MEj1wbkCIkEh8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384139; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Tz2Yc0n6FEktvB2mXI4qSYrcMEARBejHXLag1rTXNDY=; b=kcDxpY43ywbUsCnni3Yq6xlnbeNdP0Gs4egUzFbyP/VFDuLuxLPrYwN/kY9JlR3u2u70 ZperRR5ape8Lnl8WRTGa1lhWrpCNFPR+6x1BHhXE5hEBSZXZLAy+5dfmjWHcuFlbB/Jpq Bn+Ycf12w07sYZI12l8E6tR1EflwquXFPqBELR1zHDNnvb7WfbpCSuV03MOu5TGA8eFx8 m14yLMHpEYipMeg6M8CZIYz3e+WdyueAz5vdLuxXG+oP49LkIPpZxRQGLFHOWUOYx7NQl mrUgmhTRtsCnIDTC3iQ2K1XjvB9yz6FJZkCa8KFNMtbzewPgEYbOshRMRpCdliSOh6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="UGD8h/dm"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ED39606A322; Fri, 4 Dec 2026 11:35:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=UGD8h/dm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 996CD1F00897; Fri, 4 Dec 2026 11:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384139; bh=Tz2Yc0n6FEktvB2mXI4qSYrcMEARBejHXLag1rTXNDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UGD8h/dmI+mRSmpR1Sg+ScfB+VE2og8gR8OGKcpNG4RxEWj5NqQ1gtoZl4qhg0fXJ AEwa7DaZAJTrRWqt5NFT3db7Qbmep6X9Is4A21To1OggPy0IqvxPaHMGipocDWG3mS 4eMmscHrvKrL1RVKhxGRfd2S41IxpGxJonov4Ot4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Ido Schimmel , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 514/555] ipv6: Prevent rt6_insert_exception() for dying fib6_info. Date: Fri, 4 Dec 2026 19:09:17 +0900 Message-ID: <20261204100628.407526591@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 0346ec2f080b40d95ed05b853bb9226289e75212 ] Before the cited commit, fib6_nh_flush_exceptions() always set from->exception_bucket_flushed = 1 under rt6_exception_lock to prevent rt6_insert_exception() from inserting a new exception for a dying fib6_info. The flag was replaced with the FIB6_EXCEPTION_BUCKET_FLUSHED bit stored in nh->rt6i_exception_bucket. The problem is that now the bit is only set when the bucket is not NULL and fib6_nh_flush_exceptions() is called from fib6_nh_release() after fib6_ref has already reached zero. If rt6_insert_exception() is called while the target fib6_info is being removed via fib6_purge_rt(), a new exception could be created successfully because rt6_flush_exceptions() no longer sets the bit. This creates a reference cycle between the fib6_info and the exception route, leaking the fib6_info, its nexthop device, and all per-CPU routes in fib6_nh->rt6i_pcpu, which stalls netdev unregistration. [ 34.680602] unregister_netdevice: waiting for gre6 to become free. Usage count = 68 [ 44.920675] unregister_netdevice: waiting for gre6 to become free. Usage count = 68 [ 55.176582] unregister_netdevice: waiting for gre6 to become free. Usage count = 68 Let's call fib6_drop_pcpu_from() before rt6_flush_exceptions(), to set fib6_destroying before rt6_exception_lock, and check f6i->fib6_destroying in rt6_insert_exception(). Note that FIB6_EXCEPTION_BUCKET_FLUSHED logic is dead and we can clean it up in net-next. Fixes: cc5c073a693f ("ipv6: Move exception bucket to fib6_nh") Signed-off-by: Kuniyuki Iwashima Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260918082209.2853582-1-kuniyu@google.com Signed-off-by: Jakub Kicinski [ sashal: Kept this tree's fib6_drop_pcpu_from(rt, table) signature while applying the swap with rt6_flush_exceptions(), since the surrounding rt->nh context differs. ] Signed-off-by: Sasha Levin --- net/ipv6/ip6_fib.c | 2 +- net/ipv6/route.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index aab1dddf1f59f..0406488b4327d 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -1073,8 +1073,8 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn, struct fib6_table *table = rt->fib6_table; /* Flush all cached dst in exception table */ - rt6_flush_exceptions(rt); fib6_drop_pcpu_from(rt, table); + rt6_flush_exceptions(rt); if (rt->nh && !list_empty(&rt->nh_list)) list_del_init(&rt->nh_list); diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 3c0c0e1cb82a7..bc7cd0e8940b3 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1741,6 +1741,11 @@ static int rt6_insert_exception(struct rt6_info *nrt, spin_lock_bh(&rt6_exception_lock); + if (f6i->fib6_destroying) { + err = -ENOENT; + goto out; + } + bucket = rcu_dereference_protected(nh->rt6i_exception_bucket, lockdep_is_held(&rt6_exception_lock)); if (!bucket) { -- 2.53.0