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=1796384158; b=red1UGi/tOFkaWY/uRh6+73M5nOATTVTpMt+4/oJGJB3SYAlR7goTq6FrX/1rKYgq2Y2 POHCYl1hKyl5N8EIzS66NTj0Y/9ZGgHXgEVlRzntXPy8rpGrtbWv/8EE2rSyZFuOkW7c5 vYF5IWv3ZCnXuG1MGwty47iPy8nb63S0CKfKBNX/kUk8SL50vRCgBix/l3yiqIlpWTSx4 HJ4z51tMtwo164noueHhrvk3GEqAt+7YZKTPKZ/s+By0fV/soaBsMATMlCJ25nB9X2jLK vI/iC4w99zs1C9mAnhnz2vD9lOxh+EkerNfs2IRA/wArYFt3gx3UZmSp/t/NsD2b9zw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384158; 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=CPbBRKk+QeV55rQKy3USoO2i+7QhpmHfn5WrAi8Ew9c=; b=jPJJX5ncvFRvWIG9Uv4qFcLnpERn3+V3hNhw8Vql4LJi5PYf5UActXuHfwIo1UXR1iZd FvWdZjuSXlEM9L4m/i5ntGkS69kmbMcrtKJJ9mraAFAIq9NPjNVK1snZsiWh6D7WtSxI7 JeQiFLRlsPDyg/d4Hl+QM7tw17dw+L5WWqwN5b4EzPuqygitcLSzCWG1QptI+FRwLH01N eMZ+Bb/Dx9Gb5WWzyIAIyJvtcmbmzzPFEBVjlZ6uuwM6CU0Klx41F1ACuCbxdKAVz8P2L OxGTggmQ68KwwdTt2TQHEL7lDzP0wOdorBR2fXzenn02qPVrYjKUt9dxUdVvRDCycOg== 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=x3ITtXM+; 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 A288C606A32C; Fri, 4 Dec 2026 11:35:58 +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=x3ITtXM+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 176A51F000CE; Fri, 4 Dec 2026 11:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384158; bh=CPbBRKk+QeV55rQKy3USoO2i+7QhpmHfn5WrAi8Ew9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x3ITtXM+3KUfQnoDE1P1DBnzF62Mzic6nc9N6nXoKpV/wER/fw12eW4CPqm5urVVx xEKLbFT8BIXZ5KX+giWxkI6sGfbMK0+ySu1ugbtZuqtfBr2LB3JezydNMJ/c9rRGoi 86paT31dKdajj8R5tFVEJEpNxrfi6ATYUeu45q4Y= 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 521/555] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED. Date: Fri, 4 Dec 2026 19:09:24 +0900 Message-ID: <20261204100628.606783167@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 c66d93e68728cfb5f40b40d0f24129d7768faf43 ] The FIB6_EXCEPTION_BUCKET_FLUSHED logic has been dead since added. Commit 0346ec2f080b ("ipv6: Prevent rt6_insert_exception() for dying fib6_info.") restored the original race protection in rt6_insert_exception() by reusing fib6_info.fib6_destroying. The flag now prevents two races for per-cpu and exception routes. Let's remove FIB6_EXCEPTION_BUCKET_FLUSHED and set fib6_destroying in fib6_purge_rt(). Signed-off-by: Kuniyuki Iwashima Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260926033355.3295550-1-kuniyu@google.com Signed-off-by: Jakub Kicinski [ sashal: adapted the fib6_purge_rt() call to fib6_drop_pcpu_from(rt, table) to match the existing two-argument signature in this tree. ] Signed-off-by: Sasha Levin --- net/ipv6/ip6_fib.c | 14 +++++++------- net/ipv6/route.c | 45 --------------------------------------------- 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 0406488b4327d..257318e8c4a40 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -1045,12 +1045,6 @@ static int fib6_nh_drop_pcpu_from(struct fib6_nh *nh, void *_arg) static void fib6_drop_pcpu_from(struct fib6_info *f6i, const struct fib6_table *table) { - /* Make sure rt6_make_pcpu_route() wont add other percpu routes - * while we are cleaning them here. - */ - f6i->fib6_destroying = 1; - mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */ - if (f6i->nh) { struct fib6_nh_pcpu_arg arg = { .from = f6i, @@ -1072,7 +1066,13 @@ 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 */ + /* Make sure rt6_make_pcpu_route() / rt6_insert_exception() + * will not add other percpu / exception routes after cleaning + * them up in __fib6_drop_pcpu_from() / rt6_flush_exceptions(). + */ + rt->fib6_destroying = 1; + mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */ + fib6_drop_pcpu_from(rt, table); rt6_flush_exceptions(rt); diff --git a/net/ipv6/route.c b/net/ipv6/route.c index bc7cd0e8940b3..25a055763bd1b 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1674,13 +1674,6 @@ static unsigned int fib6_mtu(const struct fib6_result *res) return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu); } -#define FIB6_EXCEPTION_BUCKET_FLUSHED 0x1UL - -/* used when the flushed bit is not relevant, only access to the bucket - * (ie., all bucket users except rt6_insert_exception); - * - * called under rcu lock; sometimes called with rt6_exception_lock held - */ static struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh, spinlock_t *lock) @@ -1693,40 +1686,9 @@ struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh, else bucket = rcu_dereference(nh->rt6i_exception_bucket); - /* remove bucket flushed bit if set */ - if (bucket) { - unsigned long p = (unsigned long)bucket; - - p &= ~FIB6_EXCEPTION_BUCKET_FLUSHED; - bucket = (struct rt6_exception_bucket *)p; - } - return bucket; } -static bool fib6_nh_excptn_bucket_flushed(struct rt6_exception_bucket *bucket) -{ - unsigned long p = (unsigned long)bucket; - - return !!(p & FIB6_EXCEPTION_BUCKET_FLUSHED); -} - -/* called with rt6_exception_lock held */ -static void fib6_nh_excptn_bucket_set_flushed(struct fib6_nh *nh, - spinlock_t *lock) -{ - struct rt6_exception_bucket *bucket; - unsigned long p; - - bucket = rcu_dereference_protected(nh->rt6i_exception_bucket, - lockdep_is_held(lock)); - - p = (unsigned long)bucket; - p |= FIB6_EXCEPTION_BUCKET_FLUSHED; - bucket = (struct rt6_exception_bucket *)p; - rcu_assign_pointer(nh->rt6i_exception_bucket, bucket); -} - static int rt6_insert_exception(struct rt6_info *nrt, const struct fib6_result *res) { @@ -1756,9 +1718,6 @@ static int rt6_insert_exception(struct rt6_info *nrt, goto out; } rcu_assign_pointer(nh->rt6i_exception_bucket, bucket); - } else if (fib6_nh_excptn_bucket_flushed(bucket)) { - err = -EINVAL; - goto out; } #ifdef CONFIG_IPV6_SUBTREES @@ -1829,10 +1788,6 @@ static void fib6_nh_flush_exceptions(struct fib6_nh *nh, struct fib6_info *from) if (!bucket) goto out; - /* Prevent rt6_insert_exception() to recreate the bucket list */ - if (!from) - fib6_nh_excptn_bucket_set_flushed(nh, &rt6_exception_lock); - for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) { hlist_for_each_entry_safe(rt6_ex, tmp, &bucket->chain, hlist) { if (!from || -- 2.53.0