From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796208809; b=bsCNTtxAdlm+sFtgJMXf/Wlfkmv6dE/sCnFkPTSpggvnBK35vflRNJX5Bu+/QPbml1Q7 S/4MP9AGSE5520po5d5NBm1awR1gvRl8+KXPseS2FpOYhV8DD0uMhfyEE1kQXwTcE7Ytu ABx8MeRh652UntZyGxQToPVPad5tVbH+kFgxO6nlEII5zDIS3lJQr0/Ozu6F+xFRmEQez N4exjC2dQwe6xKHDv8ZGfkEsQ/0QBEMhpBsPKbNMs1vtFrXz+Lo1bf+B4oQXkcZG1lji6 kshIZ4xxAvh6CzF74bldYcPhC3RSv131rQvX315qjdi7Wac05U2yAHe47vS1xTvUFfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796208809; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Dg2EAYTF9l6/Qi4Nhr2OYtVc/uZlOrHHhQx2GZq5g/Y=; b=gKiTCx9gU52Yrs7zD68xB0XAOcoqtDmE9jsdawuMj1xatM93FXoeV+BVmKo7aOQ687OO bObHkWODM3aTESqbMcx3IneytHhF2YbLxZz60nz2/6ASqrG/aO0mmQGar4GiVtVouNRXF 7sYKGFWwG5J5hlka25m9Q//A/sP/r6SyDxnF9ApaQ3KaJW5trReJMyGkd7ch9w9sEFugp vzsD6wjo9ukxbqfhP7yJwltELGye/2iMs/qFmCLC8JmnPdKNNlX7TZdjuAxVqCZkxvnQV SXR4fYrGQZ8xbhx7cmmYnVcW8v4jXJmhIDeZgbqnVxHRcQSWUYYows3ESQUQbPx+ZPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=W7bmWoLX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6057606A33F for ; Wed, 2 Dec 2026 10:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=W7bmWoLX Received: by smtp.kernel.org (Postfix) with ESMTPSA id F17241F00A3F; Wed, 2 Dec 2026 10:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796208809; bh=Dg2EAYTF9l6/Qi4Nhr2OYtVc/uZlOrHHhQx2GZq5g/Y=; h=Subject:To:Cc:From:Date; b=W7bmWoLXAKuT2dmlHlQy4MkX49oUdzYi7OYFae6QLddXXRvoaPG4+SPdVypmSGk1D WZpJQ34PTwARx+ds+0Vf7VXDEC5D8SONoej80Qfrjk5bsie08+P/bYwQgPG3tymOPQ ZMFSKYLVC5rHPKTXMB4yuHJrLCsWugP1CQLJyq3o= Subject: FAILED: patch "[PATCH] drm/sched: Ensure stopped entity cannot be re-added to the" failed to apply to 6.6-stable tree To: tvrtko.ursulin@igalia.com,airlied@gmail.com,andrey.grodzovsky@amd.com,christian.koenig@amd.com,dakr@kernel.org,luben.tuikov@amd.com,matthew.brost@intel.com,phasta@kernel.org,simona@ffwll.ch Cc: From: Date: Wed, 02 Dec 2026 11:53:19 +0100 Message-ID: <2026120219-wackiness-tug-1d0d@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-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.6.y git checkout FETCH_HEAD git cherry-pick -x 7e2645d5c05ac03f240685fe76a2c04733d36a1a # git commit -s git send-email --to '' --in-reply-to '2026120219-wackiness-tug-1d0d@gregkh' --subject-prefix 'PATCH 6.6.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 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 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 Cc: Christian König Cc: Andrey Grodzovsky Cc: Matthew Brost Cc: Danilo Krummrich Cc: Philipp Stanner Cc: David Airlie Cc: Simona Vetter Cc: stable@vger.kernel.org # v6.2+ Signed-off-by: Philipp Stanner 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); /*