From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E89D93E717C; Tue, 30 Jun 2026 09:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810244; cv=none; b=umYybSCY8b2TnTVW8muA09tapFZFJW5lr621tZTTFfDQ3W03PiN+7WsVEHbhj91f9/iwBStqrURInSoA+s25Qh3mKXvZ6L2MqnFeqr7LKEUlg0e+sYQmnUU+vwjynRF99Fr63fpjAajeVHig936nx1MsnSUKBaS4hF4g8bR4me0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810244; c=relaxed/simple; bh=yR73N1scv/UhNbi2Mvt/mbpvR2uxqUipLHMoP0a73bc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=IpVoe29wrTNpLNPpBeo+9veu613SGSqVi73Qg/mdiY9j36xOUGg1lIVYU4nKdLR5AAA3F13s/5vWAwMdLIVbPM49+m5RIwNWDKBRnDkx0C9r8r2rImHsPfxlBm+XfVF15qBsTdxw2ceeccxHJKIRDIh3P2vw+dmuo9Ra5Uq6S/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rt6PESPf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZXe8LSHr; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rt6PESPf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZXe8LSHr" Date: Tue, 30 Jun 2026 09:03:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782810239; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3tJOnFFkNMcE4emzSZmmCd6ru7oZiky53k6QVfLHwo=; b=rt6PESPf56zfSALxQb4NH+QpNHDNNqnmDrTG4/XqcNrDpDFKznmTmltbPDXVO7cmwWxMnQ iYMlcndGVapW/3BzRJw4BiOtojJT7CaA+bhFn4YuRzZj8+I7U1Js7rWvAoysXIODUt8Fvc wwTgXqy1bsGFiDdk9sgXpMRrjZofp32ygHZ+Sr8hBnV/rm/kYIlCgqny/E6oddlZF0wbKS 1s3vHH4uV34lphl15TSfsELTm+FPnsf1ehcjkc0B4ee3kiva6fEbU2dj2klbSgMCphmq8t rVTNM/HH/B3Ge2ohRrU0XzNxit2NN/vJ3q+Uosdg3bD/wtlZTnY7gsVvS9rrPg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782810239; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3tJOnFFkNMcE4emzSZmmCd6ru7oZiky53k6QVfLHwo=; b=ZXe8LSHrlrGT5L4vxKjQwk5B7JO7SmbXk5QinO+gYtIjC1EQiOMSFCRN/TFJMZQtyYd+WG q4fWbXwvBOPu6IAQ== From: "tip-bot2 for Chen, Yu C" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Fix overflow in update_tg_cfs_runnable() Cc: Chen Yu , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178281023832.3843924.4432301815037597300.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 4f166adb5cb0525d9e32d45729fd8f28c80acbee Gitweb: https://git.kernel.org/tip/4f166adb5cb0525d9e32d45729fd8f28c80= acbee Author: Chen, Yu C AuthorDate: Sat, 20 Jun 2026 11:54:22 +08:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Jun 2026 10:56:51 +02:00 sched/fair: Fix overflow in update_tg_cfs_runnable() A divide-by-zero crash is observed when running hackbench: [14697.488452] CPU: 112 UID: 0 PID: 124791 Comm: hackbench Not tainted 7.1= .0-rc2+ [14697.492627] RIP: 0010:propagate_entity_load_avg+0x35f/0x3e0 [14697.506799] [14697.507411] __dequeue_task+0x2b4/0xc70 [14697.508677] dequeue_task_fair+0x36/0x370 [14697.509047] dequeue_task+0x101/0x2f0 [14697.509426] __schedule+0x1b1/0x1a00 [14697.510868] anon_pipe_read+0x3da/0x450 [14697.511400] vfs_read+0x361/0x390 [14697.512053] __x64_sys_read+0x19/0x30 The divide-by-zero happens here: if (scale_load_down(gcfs_rq->load.weight)) { load_sum =3D div_u64(gcfs_rq->avg.load_sum, scale_load_down(gcfs_rq->load.weight)); } gcfs_rq->load.weight is an insane large value and is truncated to the lower 32 bits by div_u64, which happen to be 0. Using AI for investigation, the cause is a u32 overflow in update_tg_cfs_runnable(), and flat pickup became a victim when using tg_tasks(): u32 new_sum, divider; ... new_sum =3D se->avg.runnable_avg * divider; <-- boom The following sequence shows how this triggers the crash: propagate_entity_load_avg() update_tg_cfs_runnable() # u32 overflow corrupts runnable_sum __update_load_avg_cfs_rq() ___update_load_avg() # computes insane runnable_avg update_tg_load_avg() # propagates to tg->runnable_avg update_cfs_group() calc_concur_shares() tg_tasks() # long-to-int truncation, negative nr reweight_entity() # corrupted se->load.weight update_load_add() # corrupted cfs_rq->load.weight propagate_entity_load_avg() update_tg_cfs_load() div_u64() # divide-by-zero Fix by widening new_sum from u32 to u64 (no need to force tg_tasks() to return unsigned long after this fix) Fixes: 95246d1ec80b ("sched/pelt: Relax the sync of runnable_sum with runnabl= e_avg") Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Chen Yu Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/a22eea2b-4c4a-4623-9a44-d7b18c0c91c8@intel.com --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a384f16..e89edbd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5174,7 +5174,8 @@ static inline void update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struc= t cfs_rq *gcfs_rq) { long delta_sum, delta_avg =3D gcfs_rq->avg.runnable_avg - se->avg.runnable_= avg; - u32 new_sum, divider; + u64 new_sum; + u32 divider; =20 /* Nothing to update */ if (!delta_avg) @@ -5188,7 +5189,7 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sc= hed_entity *se, struct cf =20 /* Set new sched_entity's runnable */ se->avg.runnable_avg =3D gcfs_rq->avg.runnable_avg; - new_sum =3D se->avg.runnable_avg * divider; + new_sum =3D (u64)se->avg.runnable_avg * divider; delta_sum =3D (long)new_sum - (long)se->avg.runnable_sum; se->avg.runnable_sum =3D new_sum; =20