All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Philipp Stanner" <phasta@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/3] drm/sched: Lock drm_sched_rq_pop_entity() externally
Date: Thu, 10 Sep 2026 08:08:54 +0000	[thread overview]
Message-ID: <20260910080854.C603E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910075942.2000338-3-phasta@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Pre-existing NULL pointer dereference in `drm_sched_job_arm()` if all schedulers in the entity's list are not ready.
--

commit 7804887bbadf221d2ccaad830fc83a57f0e74d93
Author: Philipp Stanner <phasta@kernel.org>

drm/sched: Lock drm_sched_rq_pop_entity() externally

As a preparational step for protecting entity->last_scheduled with a
spinlock, this commit modifies drm_sched_entity_pop_job() to lock
drm_sched_rq_pop_entity() externally.

> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index bf97508a45b9a..274d7a7022987 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -565,7 +565,9 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)
>  
>  	spsc_queue_pop(&entity->job_queue);
>  
> +	spin_lock(&entity->lock);
>  	drm_sched_rq_pop_entity(entity);
> +	spin_unlock(&entity->lock);

[Severity: High]
This isn't a bug introduced by this patch, but this series leaves a
pre-existing NULL pointer dereference unresolved in the entity runqueue
selection path.

If all schedulers in the entity's list have sched->ready == false (e.g.,
during a GPU hang or reset, as documented in the drm_sched_job_init
comments), drm_sched_pick_best() returns NULL. This causes
drm_sched_entity_select_rq() to assign NULL to entity->rq:

drivers/gpu/drm/scheduler/sched_entity.c:drm_sched_entity_select_rq() {
    ...
    sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
    rq = sched ? sched->sched_rq[entity->rq_priority] : NULL;
    if (rq != entity->rq) {
        drm_sched_rq_remove_entity(entity->rq, entity);
        entity->rq = rq;
    }
    ...
}

Upon returning to drm_sched_job_arm(), the code unconditionally dereferences
the NULL entity->rq:

drivers/gpu/drm/scheduler/sched_main.c:drm_sched_job_arm() {
    ...
    drm_sched_entity_select_rq(entity);
    sched = entity->rq->sched;
    ...
}

Can this lead to a kernel panic (NULL pointer dereference) if userspace
continues to submit jobs via ioctl after a hardware fault?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910075942.2000338-2-phasta@kernel.org?part=1

  reply	other threads:[~2026-09-10  8:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  7:59 [PATCH v3 0/3] drm/sched: Introduce more locking to entity Philipp Stanner
2026-09-10  7:59 ` [PATCH v3 1/3] drm/sched: Lock drm_sched_rq_pop_entity() externally Philipp Stanner
2026-09-10  8:08   ` sashiko-bot [this message]
2026-09-10  7:59 ` [PATCH v3 2/3] drm/sched: Lock spsc_queue_pop() in drm_sched_entity_pop_job() Philipp Stanner
2026-09-10  7:59 ` [PATCH v3 3/3] drm/sched: Protect entity->last_scheduled with spinlock Philipp Stanner
2026-09-11  8:17   ` Tvrtko Ursulin
2026-09-11  8:19 ` [PATCH v3 0/3] drm/sched: Introduce more locking to entity Tvrtko Ursulin
2026-09-11 10:34   ` Philipp Stanner

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=20260910080854.C603E1F000FF@smtp.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.