From: Philipp Stanner <phasta@mailbox.org>
To: 김종혁 <malhyuk97@gmail.com>,
tursulin@ursulin.net, matthew.brost@intel.com, dakr@kernel.org,
phasta@kernel.org
Cc: christian.koenig@amd.com, ckoenig.leichtzumerken@gmail.com,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH v1 1/2] drm/sched: cache the timeline name to fix a use-after-free
Date: Wed, 02 Sep 2026 12:07:19 +0200 [thread overview]
Message-ID: <b8f98b9e04c9999008bcdec270b14247e3cd18d0.camel@mailbox.org> (raw)
In-Reply-To: <CADQRuqtjBu7wR4kKVDcS42KLKQTr+7SBtRn24mgZ+ApettMr1A@mail.gmail.com>
On Wed, 2026-09-02 at 02:57 -0700, 김종혁 wrote:
> On 02/09/2026 10:46, Tvrtko Ursulin wrote:
> > It is not guaranteed in the documented contract that the name passed to
> > drm_sched_init has to outlive the scheduler.
>
> Right. Caching the bare pointer only works because every in-tree driver
> passes a string literal today - xe's q->name (freed with the exec queue,
> hence 299bc6d50b1b) is the counter-example where v1 would still dangle.
>
> > Hm, that might be overkill.. how about we just keep a copy of the name
> > in the scheduler object?
>
> The catch is the scheduler object is itself freed on context teardown, so
> a copy that lives there dangles for the exported fence just the same. To
> actually stop dereferencing ->sched the copy has to live in the fence -
> kstrdup in drm_sched_fence_init(), freed from the fence release. That's an
> alloc per fence on the submit path though.
>
> If that overhead isn't wanted, the lighter option is to keep the pointer
> and document in gpu_scheduler.h that the drm_sched_init() name must follow
> the dma-fence safe access rules (outlive any exported fence). That matches
> what the already-fixed drivers do and leaves the submit path untouched.
>
> Either one fixes amdxdna/nouveau/msm in the core. I'd lean to the
> documented-pointer version unless you'd rather pay the kstrdup - let me know
> which and I'll respin as a core-only series (fix + the kunit test).
>
> Thanks for the 6bd90e700b42/299bc6d50b1b context, that clears up what the
> half-fix missed.
The issue here IMO is that we are discussing working around an issue
that actually stems from dma_fence not being consistently synchronized,
notably because of the ops->release callback being implemented.
ops->release is de facto deprecated, precisely for reasons like these.
If we could get rid of it for sched_fence, dma_fence would take care of
the decoupling of the name callbacks.
So that appears worth investigating from my POV.
P.
next prev parent reply other threads:[~2026-09-02 10:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 14:57 [PATCH v1 0/2] drm/sched: fix a use-after-free in get_timeline_name() Jonghyuk Kim(MalHyuk)
2026-08-28 14:57 ` [PATCH v1 1/2] drm/sched: cache the timeline name to fix a use-after-free Jonghyuk Kim(MalHyuk)
2026-09-02 9:46 ` Tvrtko Ursulin
[not found] ` <CADQRuqtjBu7wR4kKVDcS42KLKQTr+7SBtRn24mgZ+ApettMr1A@mail.gmail.com>
2026-09-02 10:07 ` Philipp Stanner [this message]
2026-09-02 10:20 ` Tvrtko Ursulin
2026-09-02 11:39 ` Philipp Stanner
2026-09-02 13:38 ` Christian König
2026-08-28 14:57 ` [PATCH v1 2/2] drm/sched/tests: add a UAF regression test for get_timeline_name() Jonghyuk Kim(MalHyuk)
2026-09-02 10:04 ` Tvrtko Ursulin
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=b8f98b9e04c9999008bcdec270b14247e3cd18d0.camel@mailbox.org \
--to=phasta@mailbox.org \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=malhyuk97@gmail.com \
--cc=matthew.brost@intel.com \
--cc=phasta@kernel.org \
--cc=tursulin@ursulin.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 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®