* FAILED: patch "[PATCH] drm/sched: Ensure stopped entity cannot be re-added to the" failed to apply to 6.12-stable tree
@ 2026-12-02 10:53 gregkh
0 siblings, 0 replies; only message in thread
From: gregkh @ 2026-12-02 10:53 UTC (permalink / raw)
To: tvrtko.ursulin, airlied, andrey.grodzovsky, christian.koenig,
dakr, luben.tuikov, matthew.brost, phasta, simona
Cc: stable
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 <stable@vger.kernel.org>.
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 7e2645d5c05ac03f240685fe76a2c04733d36a1a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120219-mulled-sheep-f77e@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7e2645d5c05ac03f240685fe76a2c04733d36a1a Mon Sep 17 00:00:00 2001
From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Date: Mon, 9 Nov 2026 16:07:43 +0000
Subject: [PATCH] drm/sched: Ensure stopped entity cannot be re-added to the
run-queue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When entities are torn down in drm_sched_entity_kill() a multi-step
process is undertaken to synchronize with a drm_sched_run_job_work()
consuming jobs from the same entity.
First the entity is marked as stopped and removed from the run-queue,
with both the entity and run-queue lock correctly taken. The process then
waits for the entity idle via the completion after which point it assumes
it is the only accessor to the entity in question.
What can happen however in drm_sched_run_job_work() if there are at least
two outstanding runnable jobs on an entity, is that
drm_sched_entity_pop_job() can re-add it to the run-queue due the
unconditial add to the rbtree via drm_sched_rq_update_fifo_locked().
What is required is that the teardown starts after the run job has
selected the entity and that it gets to it's completion waiting stage
before the run job goes to dequeue a job, and for the run job to be able
to de-queue a job before teardown has consumed too many.
Run job will then see there is another job pending (after the one about
to be de-queued) and it will re-add the entity to the run-queue. Run job
will then signal the completion and entity teardown will proceed
incorrectly thinking it's removal of the entity was final.
End result is a pointer to an entity about to be freed dangling forever in
the rbtree.
drm_sched_run_job_work() drm_sched_entity_kill()
drm_sched_select_entity
stops and removes entity
wait_for_completion
drm_sched_entity_pop_job
-> re-adds to run-queue due more jobs
complete_all
drm_sched_entity_queue_pop
... fini entity ...
drm_sched_run_job_queue
drm_sched_select_entity - UAF
This race existed ever since the FIFO policy was first added.
Lets mirror the guard from drm_sched_rq_add_entity() in
drm_sched_rq_pop_entity() and close this gap.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
References: https://sashiko.dev/#/patchset/20261020154123.33631-1-tvrtko.ursulin@igalia.com?part=7
Fixes: 08fb97de03aa ("drm/sched: Add FIFO sched policy to run queue")
Cc: Luben Tuikov <luben.tuikov@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20261109160743.17020-1-tvrtko.ursulin@igalia.com
diff --git a/drivers/gpu/drm/scheduler/sched_rq.c b/drivers/gpu/drm/scheduler/sched_rq.c
index 23f46ec610e7..6f67a146d99c 100644
--- a/drivers/gpu/drm/scheduler/sched_rq.c
+++ b/drivers/gpu/drm/scheduler/sched_rq.c
@@ -345,6 +345,13 @@ void drm_sched_rq_pop_entity(struct drm_sched_entity *entity)
lockdep_assert_held(&entity->lock);
+ /*
+ * If entity is getting torn down via drm_sched_entity_kill() we need
+ * to ensure it does not get re-added to the tree behind it's back.
+ */
+ if (entity->stopped)
+ return;
+
spin_lock(&rq->lock);
/*
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 10:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 10:53 FAILED: patch "[PATCH] drm/sched: Ensure stopped entity cannot be re-added to the" failed to apply to 6.12-stable tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox