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 57DB93B1EC2 for ; Tue, 12 May 2026 14:18:33 +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=1778595513; cv=none; b=mScUZpED1BACIeiCcilRvz7CzYwQ5nuWjm0y5k6yA9uzQEsGCcR40RWCtlEth7Mxz8+i7eWzXGvxApN71Du1TwiJmQuvJWqfoGhzO+QmtWlnBfGfr1A4nUmDyJjefOSuIvteOmTGsj15S6qvq5X0Ohq/IHmh0a2GKWVvULIbsvc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778595513; c=relaxed/simple; bh=S+Te0Osk57JDmdncn/1crEQLDhQIi/Y1Hfs9yAWYErs=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=RVF0+DbEZEhK9R67U4lBRxQp4ssdSXWYTf5M+yaiSZz2q2dLoiHVdtu/q+r3VZ6LgVS6f11QtAX52E5ymgI973DHNdotDvTis8oVdoS/dD8UMccozgPVc0pssnxJgDT5HQ8bsWcwKQidExJfQaNEX78bd0uHqrxLy1M6HjwCh+M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BNr30veJ; 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="BNr30veJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8B5C2BCB0; Tue, 12 May 2026 14:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778595513; bh=S+Te0Osk57JDmdncn/1crEQLDhQIi/Y1Hfs9yAWYErs=; h=Subject:To:Cc:From:Date:From; b=BNr30veJvxJPMuZBdMhsaGjUJavxhNquQU+2tMHOS5hDWtvIhgvHGygMBjk2motQd IGUGsJhiTzZzgE45FJ51hkq8ujDvl4Vi/B77wQua9CTS0yuhVjstFfLL02fu9jLFcv ri3Ci6vkZVYJ3oTXER6Vfr6COtHfUBXBGv7nC4tc= Subject: FAILED: patch "[PATCH] sched_ext: Guard scx_dsq_move() against NULL kit->dsq after" failed to apply to 6.12-stable tree To: tj@kernel.org,arighi@nvidia.com,clm@meta.com Cc: From: Date: Tue, 12 May 2026 16:18:01 +0200 Message-ID: <2026051201-visibly-fossil-2e59@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 4fda9f0e7c950da4fe03cedeb2ac818edf5d03e9 # git commit -s git send-email --to '' --in-reply-to '2026051201-visibly-fossil-2e59@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4fda9f0e7c950da4fe03cedeb2ac818edf5d03e9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 24 Apr 2026 14:31:35 -1000 Subject: [PATCH] sched_ext: Guard scx_dsq_move() against NULL kit->dsq after failed iter_new bpf_iter_scx_dsq_new() clears kit->dsq on failure and bpf_iter_scx_dsq_{next,destroy}() guard against that. scx_dsq_move() doesn't - it dereferences kit->dsq immediately, so a BPF program that calls scx_bpf_dsq_move[_vtime]() after a failed iter_new oopses the kernel. Return false if kit->dsq is NULL. Fixes: 4c30f5ce4f7a ("sched_ext: Implement scx_bpf_dispatch[_vtime]_from_dsq()") Cc: stable@vger.kernel.org # v6.12+ Reported-by: Chris Mason Signed-off-by: Tejun Heo Reviewed-by: Andrea Righi diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 7f991ecb1398..68c67113204f 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -8076,12 +8076,22 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit, struct task_struct *p, u64 dsq_id, u64 enq_flags) { struct scx_dispatch_q *src_dsq = kit->dsq, *dst_dsq; - struct scx_sched *sch = src_dsq->sched; + struct scx_sched *sch; struct rq *this_rq, *src_rq, *locked_rq; bool dispatched = false; bool in_balance; unsigned long flags; + /* + * The verifier considers an iterator slot initialized on any + * KF_ITER_NEW return, so a BPF program may legally reach here after + * bpf_iter_scx_dsq_new() failed and left @kit->dsq NULL. + */ + if (unlikely(!src_dsq)) + return false; + + sch = src_dsq->sched; + if (!scx_vet_enq_flags(sch, dsq_id, &enq_flags)) return false;