From nobody Tue Feb 10 01:59:08 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 329CB39900A; Thu, 5 Feb 2026 15:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770304149; cv=none; b=VI2SbKunvB9C8tr/vpWULB3jD0Yn0gtXJYGfQJQ8B+PgH/S8L1+uH+ZwZ4i8TxAoDu/4QBreKWqTkEJahYyc1dNykDluF8lrbdU/ldcaTi9UnkhNpJUaHbAR/qlPFlxoec1yMhk8bqHpiExVxBdL+2JU5RlwsCbMd1u3f/XL9Z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770304149; c=relaxed/simple; bh=K2EVgGdoi4y2PT+Y9ctngywJVj8QdCcBShw16+ochMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3TJyu7quooDvUIOiVWaqIclBGcMDV5OSBtxX0hUpQd6+yQcw7R9siNUQ1Rf0emkgY/EjflnjIwFRrroYhKYretUZHUWUi9d4472ZT6P9Ce1YoCgW97ptWtc8arOq+sSYOBIxv3lHphQ7/XOgCzTFYG3fJpl+MqgjQHCJm2OQ+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3A5491516; Thu, 5 Feb 2026 07:09:02 -0800 (PST) Received: from e135073.arm.com (unknown [10.57.8.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 27F0B3F778; Thu, 5 Feb 2026 07:09:04 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Christian Loehle , Pierre Gondois , stable@vger.kernel.org, Vincent Guittot , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Rik van Riel Subject: [PATCH 1/2] sched/fair: Fix integer underflow Date: Thu, 5 Feb 2026 16:08:44 +0100 Message-ID: <20260205150846.1242134-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260205150846.1242134-1-pierre.gondois@arm.com> References: <20260205150846.1242134-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" (struct sg_lb_stats).idle_cpus is of type 'unsigned int'. (local->idle_cpus - busiest->idle_cpus) can underflow to UINT_MAX for instance, and max_t(long, 0, UINT_MAX) will output UINT_MAX. Use lsub_positive() instead of max_t(). Fixes: 16b0a7a1a0af ("sched/fair: Ensure tasks spreading in LLC during LB") cc: stable@vger.kernel.org Signed-off-by: Pierre Gondois Reviewed-by: Vincent Guittot Reviewed-by: K Prateek Nayak --- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index da46c31645378..aa14a9982b9f1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11249,8 +11249,8 @@ static inline void calculate_imbalance(struct lb_en= v *env, struct sd_lb_stats *s * idle CPUs. */ env->migration_type =3D migrate_task; - env->imbalance =3D max_t(long, 0, - (local->idle_cpus - busiest->idle_cpus)); + env->imbalance =3D local->idle_cpus; + lsub_positive(&env->imbalance, busiest->idle_cpus); } =20 #ifdef CONFIG_NUMA --=20 2.43.0