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=1793211972; b=pHwvJqIXDdl5j/UnYvfAtAz9Tp69nNxhWL49hBSFSo3TWMvDDmGFQy8vdamJ/6IrHxni d/dMspwDaF8z54c4sg3gcl0nykhsrB8rkB1aKJTo5CbzheAKcws+DnLLOuzAyJAr6VgZk RWGy7zQnOk6a/RWZv5upo1jlkLAnVgMR4y0WJx13sSTFaH9UUegELmt9XPfP939OkS9nq D3xekAqe5z11EAPABLd1GtaI5JlqzBcEC6zHQTmltLrKCKA2xbo8RbzundGlKGl+GjT6a tMKdcfUtKCHDcJS77crKqy4eXy/9XtSjvYylnvZnC1Q9mq0PrxsyySTyR8csjMFxjoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793211972; 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=xJBb8b8mlaAiSqg4z2zsG8z03yKy/JfQU/H5qr6rq0M=; b=Igkvt3y8PmBumyTdQ+aJUIpGTbUC1W9XsMIzJ7dZrB5uY6Z6lz9DrGcjSCSHxtbpf0+z KRa8EgHFnA8W7ZbinF0H16HdP0QASLRgvxDoXqrM/NNGKS37B4dny8/ZqbXIF5GWGYrxl b1peNu8+YIenQoELwG+9NoSkFZk/C94iRG9/Hr800/2HnSo2gki5VqjQEEDtFqfaEuLxl Dnc9brWy8WJkOBUuImEyeMnHz+u78cTFCx/OcG2r/xIZNL04XJyK+zInaBqRF0bd8oWo/ H+bRy+aVCrCSf+wMK/wT8jR0eu4tQ2pxsZu5wWuzmWH+xVkTktwz1PhKE67GwW5p4aA== 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=SKITmACQ; 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 EF355606A31A; Wed, 28 Oct 2026 18:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SKITmACQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10E8D1F01825; Wed, 28 Oct 2026 18:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793211971; bh=xJBb8b8mlaAiSqg4z2zsG8z03yKy/JfQU/H5qr6rq0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SKITmACQ/abLlLq6n31fJ9On4fWFF1RQ8Wxbqkf9OwZbYrUzQdAJYPdzp6PciCxal /5WxNAWZ9FXlGh6ICH0c/WsiIQfzobnJ3Gf629F1+eZ8wK3S57P2kVHZk0XtTsUXaY 6hCKNi5cfeI8tzxKAwr5gs0vgmgeFjumdH+cTuy8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Zihan Xi , Eric Dumazet , Ido Schimmel , Jakub Kicinski Subject: [PATCH 5.15 520/571] ipv4: avoid divide by zero in fib_rebalance Date: Wed, 28 Oct 2026 18:01:07 +0100 Message-ID: <20261028170020.368650186@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zihan Xi commit 5046d2880fec7d49ebed2fd2866747ee1d06ad71 upstream. fib_rebalance() computes the total eligible nexthop weight in one pass and programs upper bounds in a second pass. A concurrent change to ignore_routes_with_linkdown can make the first pass return zero while the second pass sees an eligible nexthop, resulting in division by zero. If the first pass reports a zero total, set each nexthop upper bound to -1 and skip the division. This matches the IPv6 fix in commit d2c26c2911dd ("ipv6: avoid divide by zero in rt6_multipath_rebalance") and preserves the lock-free rebalance path. Fixes: 0e884c78ee19 ("ipv4: L3 hash-based multipath") Cc: stable@vger.kernel.org Reported-by: Vega Signed-off-by: Zihan Xi Reviewed-by: Eric Dumazet Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260827182514.4667-2-zihanx@nebusec.ai Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -855,7 +855,7 @@ static void fib_rebalance(struct fib_inf change_nexthops(fi) { int upper_bound; - if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD) { + if (!total || nexthop_nh->fib_nh_flags & RTNH_F_DEAD) { upper_bound = -1; } else if (ip_ignore_linkdown(nexthop_nh->fib_nh_dev) && nexthop_nh->fib_nh_flags & RTNH_F_LINKDOWN) {