From nobody Wed Jun 17 04:15:32 2026 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 9FE853D646C; Tue, 28 Apr 2026 07:26:05 +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=1777361167; cv=none; b=G3OPm7MyzP7zPHCboHjM9Uhnyr1UuXRlz4ADPzt1G2zOU916fL6pasxU5uUiTi71wVh/JrPtSyI4yJIAi4sKq2AyCSil5ejz6PHC++nNXMBAmoJd1KCTEJUc6iHQ0P2QpBrr9/adlTkESwJIg+DdudgsqZhoahfPTJ6Wiq1p4+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777361167; c=relaxed/simple; bh=kLaahxeeGh6iyq0URk2petHQCRinV7obDilUOmQ7d9Y=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ZSB/+DRAwAQsVf3siTptEQYikdZVwD4pyB1PAehZwEzPZrHEDihW+fhheRqung2oHfbjsrqs3hJ128/EmJoKGk4jQNrBKdsMTbz1RIXs0QOu4LWQVcDZNWMAmqImY9y79UM1Mj5HZ/VLgLR4RQP4FpCsXT52ygqxslbs0xMJVJk= 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=GLzampld; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iH9xBpvo; 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="GLzampld"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iH9xBpvo" Date: Tue, 28 Apr 2026 07:26:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777361163; 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=E3IWHtTrJ61EHbaMPytK440BOf9ylqWSwPe0+whj8S0=; b=GLzampldOJM/l/bCkYLM0R3yDTwqJHqgbgTz9tsOf8tb++pDpCzcfaCW7ljPTgrJh0RVVU rSpc2VJlXLecXCr90yDnkGROWq4ctdFld65baNJV0IzORnE3lyJGwKS8eU5UI5rkoyJGE+ oi1zAsAAwXKHB5DqXT2nG8xbBZZYCeuPscf8NncZAVmOnIzuOieJ+e+MCefmHQQYuyQBPg Tzvl9rLoyygXNdahIkAFCffYk7Lvq75EpT2Rw8LGGIDYhj9/dVf2zGk5Tq5/xIo8BYbIYE D6f0NJK3ZP7kPqnhvimyOxpYJvhwNFFkyhEzSEnCeidtH/yvs3f2MjV6KrUmGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777361163; 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=E3IWHtTrJ61EHbaMPytK440BOf9ylqWSwPe0+whj8S0=; b=iH9xBpvoDORiBVlyUIYYrUpDp7lLP6SU1mEycigv6i0D8OMTO1Li3SlrKQ+yNcYqHqSZmX 65Dptyhm8bUOcrCA== From: "tip-bot2 for Zicheng Qu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Clear rel_deadline when initializing forked entities Cc: Zicheng Qu , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260424071113.1199600-1-quzicheng@huawei.com> References: <20260424071113.1199600-1-quzicheng@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177736116206.3521451.17244760261646808954.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/urgent branch of tip: Commit-ID: 3da56dc063cd77b9c0b40add930767fab4e389f3 Gitweb: https://git.kernel.org/tip/3da56dc063cd77b9c0b40add930767fab= 4e389f3 Author: Zicheng Qu AuthorDate: Fri, 24 Apr 2026 07:11:13=20 Committer: Peter Zijlstra CommitterDate: Tue, 28 Apr 2026 09:19:54 +02:00 sched/fair: Clear rel_deadline when initializing forked entities A yield-triggered crash can happen when a newly forked sched_entity enters the fair class with se->rel_deadline unexpectedly set. The failing sequence is: 1. A task is forked while se->rel_deadline is still set. 2. __sched_fork() initializes vruntime, vlag and other sched_entity state, but does not clear rel_deadline. 3. On the first enqueue, enqueue_entity() calls place_entity(). 4. Because se->rel_deadline is set, place_entity() treats se->deadline as a relative deadline and converts it to an absolute deadline by adding the current vruntime. 5. However, the forked entity's deadline is not a valid inherited relative deadline for this new scheduling instance, so the conversion produces an abnormally large deadline. 6. If the task later calls sched_yield(), yield_task_fair() advances se->vruntime to se->deadline. 7. The inflated vruntime is then used by the following enqueue path, where the vruntime-derived key can overflow when multiplied by the entity weight. 8. This corrupts cfs_rq->sum_w_vruntime, breaks EEVDF eligibility calculation, and can eventually make all entities appear ineligible. pick_next_entity() may then return NULL unexpectedly, leading to a later NULL dereference. A captured trace shows the effect clearly. Before yield, the entity's vruntime was around: 9834017729983308 After yield_task_fair() executed: se->vruntime =3D se->deadline the vruntime jumped to: 19668035460670230 and the deadline was later advanced further to: 19668035463470230 This shows that the deadline had already become abnormally large before yield_task_fair() copied it into vruntime. rel_deadline is only meaningful when se->deadline really carries a relative deadline that still needs to be placed against vruntime. A freshly forked sched_entity should not inherit or retain this state. Clear se->rel_deadline in __sched_fork(), together with the other sched_entity runtime state, so that the first enqueue does not interpret the new entity's deadline as a stale relative deadline. Fixes: 82e9d0456e06 ("sched/fair: Avoid re-setting virtual deadline on 'mig= rations'") Analyzed-by: Hui Tang Analyzed-by: Zhang Qiao Signed-off-by: Zicheng Qu Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260424071113.1199600-1-quzicheng@huawei.com --- kernel/sched/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index da20fb6..b887144 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4458,6 +4458,7 @@ static void __sched_fork(u64 clone_flags, struct task= _struct *p) p->se.nr_migrations =3D 0; p->se.vruntime =3D 0; p->se.vlag =3D 0; + p->se.rel_deadline =3D 0; INIT_LIST_HEAD(&p->se.group_node); =20 /* A delayed task cannot be in clone(). */