From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3CE662F7449; Tue, 12 Aug 2025 17:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755021376; cv=none; b=WUcX8pMxwVTRAFT/yBEYc8upLoZTge2MvW20IclB0LFmsKkwAE237vNr4n5moLgBmuyq6srYedvfkSO0jvUBLJUql58z2vha+mJ/LGyfq53QBwJv5NA4lhx/QM/AdYWirM+h+G5H/Y+SkzHcJQdANOPiFocWMhgEGKKe0JCzz5s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755021376; c=relaxed/simple; bh=lXjllhNP1DKn5dJQPpxADpyOxs8EM0c9Ejy49MJqXVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hRxA55am0o77LDRczCIPCKjx6RIT6WCJzWlg2A4V2szhKl4gKU297JB0LcbBVqUa841cM7bjjgRZ6h8mUBdOsLRiWnWzXIYJhP+4gw0Rb4AFE3ekpBDfs/z7zbd/XNJdgPAZCtNw1QvV+PtrxzJLV76SBSdROKYJaWFMpUGNh4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qaRzlOLD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qaRzlOLD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C20CC4CEF1; Tue, 12 Aug 2025 17:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755021376; bh=lXjllhNP1DKn5dJQPpxADpyOxs8EM0c9Ejy49MJqXVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qaRzlOLDtzdDFcM/sS+lBEklOIP07W2AD3ECMBcGNEjUyJI5QzjgPRY9w7WRQcgQE lMsv1wj0aATEQB85J+VCX88FNdB75QYdUyHRt/UcaFx7ZvQKuhn7Z/l87VpJ5TBBbh if4cRR3cT+ahFiTUdw06hCEF0/ZQIckNphay/7wA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 104/262] ipv6: fix possible infinite loop in fib6_info_uses_dev() Date: Tue, 12 Aug 2025 19:28:12 +0200 Message-ID: <20250812172957.519239924@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812172952.959106058@linuxfoundation.org> References: <20250812172952.959106058@linuxfoundation.org> User-Agent: quilt/0.68 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit f8d8ce1b515a0a6af72b30502670a406cfb75073 ] fib6_info_uses_dev() seems to rely on RCU without an explicit protection. Like the prior fix in rt6_nlmsg_size(), we need to make sure fib6_del_route() or fib6_add_rt2node() have not removed the anchor from the list, or we risk an infinite loop. Fixes: d9ccb18f83ea ("ipv6: Fix soft lockups in fib6_select_path under high next hop churn") Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20250725140725.3626540-4-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/route.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 41d358dd58c0..f180b7bc9f57 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5865,16 +5865,21 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i, if (f6i->fib6_nh->fib_nh_dev == dev) return true; - if (f6i->fib6_nsiblings) { - struct fib6_info *sibling, *next_sibling; + if (READ_ONCE(f6i->fib6_nsiblings)) { + const struct fib6_info *sibling; - list_for_each_entry_safe(sibling, next_sibling, - &f6i->fib6_siblings, fib6_siblings) { - if (sibling->fib6_nh->fib_nh_dev == dev) + rcu_read_lock(); + list_for_each_entry_rcu(sibling, &f6i->fib6_siblings, + fib6_siblings) { + if (sibling->fib6_nh->fib_nh_dev == dev) { + rcu_read_unlock(); return true; + } + if (!READ_ONCE(f6i->fib6_nsiblings)) + break; } + rcu_read_unlock(); } - return false; } -- 2.39.5