From: sashiko-bot@kernel.org
To: "Philipp Stanner" <phasta@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/sched: Extend locking in drm_sched_entity_select_rq()
Date: Tue, 17 Nov 2026 09:46:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-218518@kernel.org> (raw)
In-Reply-To: <20261117093708.647488-2-phasta@kernel.org>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/sched: out-of-bounds array read in
drm_sched_entity_select_rq() [1]
--
commit fd8a3dbada3c5189d04991dce47c3b6554b565d5
Author: Philipp Stanner <phasta@kernel.org>
drm/sched: Extend locking in drm_sched_entity_select_rq()
This commit moves spin_lock(&entity->lock) to the start of
drm_sched_entity_select_rq() so that entity->sched_list and
spsc_queue_count(&entity->job_queue) are evaluated under lock protection.
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 03e68b4102d50..3856d5e507d7f 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -577,22 +577,21 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
> struct drm_gpu_scheduler *sched;
> struct drm_sched_rq *rq;
>
> + spin_lock(&entity->lock);
> +
> /* single possible engine and already selected */
> if (!entity->sched_list)
> - return;
> + goto unlock;
>
> /* queue non-empty, stay on the same engine */
> if (spsc_queue_count(&entity->job_queue))
> - return;
> + goto unlock;
>
> - spin_lock(&entity->lock);
> fence = entity->last_scheduled;
>
> /* stay on the same engine if the previous job hasn't finished */
> - if (fence && !dma_fence_is_signaled(fence)) {
> - spin_unlock(&entity->lock);
> - return;
> - }
> + if (fence && !dma_fence_is_signaled(fence))
> + goto unlock;
>
> sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
> rq = sched ? sched->sched_rq[entity->rq_priority] : NULL;
[Severity: Critical]
This problem wasn't introduced by this patch, but can
sched->sched_rq[entity->rq_priority] read out of bounds here [1]?
drivers/gpu/drm/scheduler/sched_entity.c:drm_sched_entity_init() {
...
if (!sched_list[0]->sched_rq) {
...
pr_warn("%s: called with uninitialized scheduler\n", __func__);
} else if (priority >= sched_list[0]->num_user_rqs) {
...
priority = max_t(s32,
(s32)sched_list[0]->num_user_rqs - 1,
(s32)DRM_SCHED_PRIORITY_KERNEL);
}
entity->priority = priority;
entity->rq_priority = drm_sched_policy == DRM_SCHED_POLICY_FAIR ?
DRM_SCHED_PRIORITY_KERNEL : priority;
...
}
When drm_sched_entity_init() is called with an uninitialized scheduler
(!sched_list[0]->sched_rq), it warns and skips clamping priority against
num_user_rqs, storing the unvalidated value into entity->priority and
entity->rq_priority. Later, drm_sched_entity_select_rq() indexes
sched->sched_rq[entity->rq_priority] and drm_sched_entity_update_vruntime()
indexes vruntime_shift[entity->priority] out of bounds, which can crash the
kernel.
[1] https://sashiko.dev/#/bug/linux-588f726e-4d3a-4204-b39b-8ff2cd63a19c
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117093708.647488-2-phasta@kernel.org?part=1
prev parent reply other threads:[~2026-11-17 9:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:37 [PATCH] drm/sched: Extend locking in drm_sched_entity_select_rq() Philipp Stanner
2026-11-17 9:46 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-218518@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=phasta@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.