From: lyude@redhat.com
To: "Jonghyuk Kim(MalHyuk)" <malhyuk97@gmail.com>,
Danilo Krummrich <dakr@kernel.org>
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] drm/nouveau: RCU-free the scheduler-containing nouveau_sched
Date: Thu, 17 Sep 2026 17:51:44 -0400 [thread overview]
Message-ID: <b020f35ab8adda3907ec2be57057996be40717c5.camel@redhat.com> (raw)
In-Reply-To: <20260902012717.880724-1-malhyuk97@gmail.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Will push to drm-misc-fixes in just a moment
On Wed, 2026-09-02 at 10:27 +0900, Jonghyuk Kim(MalHyuk) wrote:
> struct nouveau_sched embeds a struct drm_gpu_scheduler (base).
> nouveau_sched_destroy() calls nouveau_sched_fini() (which does
> drm_sched_fini(&sched->base)) and then frees the object with plain
> kfree(sched).
>
> drm_sched_fence_get_timeline_name() returns fence->sched->name, and
> the
> scheduler fence keeps a .release callback so it is not ops-detached
> on
> signalling. A finished fence exported to userspace via drm_syncobj /
> sync_file therefore keeps pointing at &sched->base after
> nouveau_sched_destroy(),
> and a later get_timeline_name() -- reachable unprivileged through
> SYNC_IOC_FILE_INFO -- dereferences freed memory (KASAN slab-use-
> after-free
> read).
>
> Per the dma-fence lifetime contract the exporter must keep the data
> backing a
> signalled fence alive for an RCU grace period. Free the scheduler-
> containing
> object with kfree_rcu() instead of kfree().
>
> Fixes: 5f03a507b29e ("drm/nouveau: implement 1:1 scheduler - entity
> relationship")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jonghyuk Kim(MalHyuk) <malhyuk97@gmail.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_sched.c | 2 +-
> drivers/gpu/drm/nouveau/nouveau_sched.h | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.c
> b/drivers/gpu/drm/nouveau/nouveau_sched.c
> index 2cbae003d6de..48dbb851df2f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sched.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_sched.c
> @@ -516,7 +516,7 @@ nouveau_sched_destroy(struct nouveau_sched
> **psched)
> struct nouveau_sched *sched = *psched;
>
> nouveau_sched_fini(sched);
> - kfree(sched);
> + kfree_rcu(sched, rcu);
>
> *psched = NULL;
> }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.h
> b/drivers/gpu/drm/nouveau/nouveau_sched.h
> index 20cd1da8db73..51ce8dcf6285 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sched.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_sched.h
> @@ -98,6 +98,7 @@ void nouveau_job_free(struct nouveau_job *job);
>
> struct nouveau_sched {
> struct drm_gpu_scheduler base;
> + struct rcu_head rcu;
> struct drm_sched_entity entity;
> struct workqueue_struct *wq;
> struct mutex mutex;
prev parent reply other threads:[~2026-09-17 21:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 1:27 Jonghyuk Kim(MalHyuk)
2026-09-17 21:51 ` lyude [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=b020f35ab8adda3907ec2be57057996be40717c5.camel@redhat.com \
--to=lyude@redhat.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=malhyuk97@gmail.com \
--cc=nouveau@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®