All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tomeu Vizoso" <tomeu@tomeuvizoso.net>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/rocket: Fix up sched array handling on open and close
Date: Wed, 18 Nov 2026 10:25:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-220687@kernel.org> (raw)
In-Reply-To: <20261118101901.253550-1-tomeu@tomeuvizoso.net>

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] accel/rocket: use-after-free of DRM scheduler in
  rocket_remove() [1]
--

commit 60150dc55a394b4ae585de44cc1ea51f813c0a96
Author: Tomeu Vizoso <tomeu@tomeuvizoso.net>

accel/rocket: Fix up sched array handling on open and close

This commit drops the WARN_ON() when drm_sched_entity_init() fails in
rocket_job_open(), and reorders rocket_job_close() to destroy the scheduler
entity before freeing the scheduler array.

Link: https://lore.kernel.org/all/20260826113538.42111-1-sidong.yang@furiosa.ai/
Link: https://lore.kernel.org/all/20260826113538.42111-2-sidong.yang@furiosa.ai/

> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 7b798a90bc492..454d465a39e37 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -572,7 +572,7 @@ int rocket_job_open(struct rocket_file_priv *rocket_priv)
>  				    DRM_SCHED_PRIORITY_NORMAL,
>  				    scheds,
>  				    rdev->num_cores, NULL);
> -	if (WARN_ON(ret))
> +	if (ret)
>  		kfree(scheds);
>  	else
>  		rocket_priv->scheds = scheds;

[Severity: Critical]
This problem wasn't introduced by this patch, but can unbinding a Rocket NPU
core while a file descriptor is open cause a use-after-free of the DRM
scheduler [1]?

rocket_job_open() initializes rocket_priv->sched_entity with pointers to
rdev->cores[core].sched.  If a core is unbound while the file descriptor
remains open, rocket_remove() calls rocket_core_fini() -> drm_sched_fini()
without synchronizing against open file descriptors or active entities.  A
subsequent job submission then dereferences the torn-down scheduler in
drm_sched_job_arm():

CPU0                                CPU1
rocket_job_open()
  scheds[i] = &rdev->cores[i].sched
  drm_sched_entity_init(..., scheds, ...)

rocket_remove()
  rocket_core_fini()
    drm_sched_fini()
                                    rocket_ioctl_submit()
                                      ...
                                        drm_sched_job_arm()
                                          drm_sched_entity_select_rq()
                                          sched = entity->rq->sched  <-- use-after-free

[1] https://sashiko.dev/#/bug/linux-57e50ba5-1b02-4d94-b63e-d7208e41bab0

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118101901.253550-1-tomeu@tomeuvizoso.net?part=1

  reply	other threads:[~2026-11-18 10:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:18 [PATCH] accel/rocket: Fix up sched array handling on open and close Tomeu Vizoso
2026-11-18 10:25 ` sashiko-bot [this message]
2026-11-18 10:51 ` Heiko Stübner

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-220687@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tomeu@tomeuvizoso.net \
    /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.