FAILED: patch "[PATCH] sched_ext: Guard scx_dsq_move() against NULL kit->dsq after" failed to apply to 6.18-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.18-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 <[email protected]>.
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.18.y
git checkout FETCH_HEAD
git cherry-pick -x 4fda9f0e7c950da4fe03cedeb2ac818edf5d03e9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051201-cupping-demotion-047d@gregkh' --subject-prefix 'PATCH 6.18.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 <[email protected]>
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.
kernel/sched/ext.c +11 -1
@@ -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;
Sasha Levin
maintainerPATCH 1/1 sched_ext: Guard scx_dsq_move() against NULL kit->dsq after failed iter_new
From: Tejun Heo <[email protected]>
[ Upstream commit 4fda9f0e7c950da4fe03cedeb2ac818edf5d03e9 ]
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.
--- kernel/sched/ext.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/sched/ext.c +8 -0
@@ -5650,6 +5650,14 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit,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; +if (!scx_kf_allowed_if_unlocked () && !scx_kf_allowed (sch,SCX_KF_DISPATCH ))return false;
Signature · 1 line
2.53.0