From: "Jonghyuk Kim(MalHyuk)" <malhyuk97@gmail.com>
To: tursulin@ursulin.net, phasta@kernel.org, matthew.brost@intel.com,
dakr@kernel.org
Cc: christian.koenig@amd.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] drm/sched: fix use-after-free of the fence timeline name
Date: Wed, 2 Sep 2026 19:58:06 +0900 [thread overview]
Message-ID: <20260902105808.1541063-1-malhyuk97@gmail.com> (raw)
drm_sched_fence_get_timeline_name() dereferences fence->sched, but a
per-context/per-queue/per-VM scheduler can be freed on an unprivileged
context/fd close while userspace still holds the exported ->finished fence
(sync_file / drm_syncobj). A later SYNC_IOC_FILE_INFO then reads the freed
scheduler:
BUG: KASAN: slab-use-after-free in drm_sched_fence_get_timeline_name
This is the same class as CVE-2025-38703 (drm/xe) and CVE-2025-71302
(drm/panthor), which were fixed per-driver. amdxdna, nouveau and msm
(VM_BIND) are still affected in mainline, so patch 1 fixes it in the core for
any per-context-scheduler driver at once.
Patch 1 caches the scheduler name pointer in the fence at init time and
returns it from get_timeline_name() without touching fence->sched, plus
documents in struct drm_sched_init_args that the name must outlive any
exported fence. Patch 2 is a KUnit reproducer exercising the mock scheduler
under KASAN (no hardware needed).
v1 -> v2:
- Keep caching the name pointer and document the lifetime rule, rather than
kstrdup()-ing per fence, to avoid an allocation on the submit path for a
debug-only value (Tvrtko).
- Reworked the test to query through the public dma_fence_timeline_name()
API and moved it to a new tests_integration.c so tests_basic.c stays
focused on core scheduler behaviour (Tvrtko).
Tested with the patch 2 KUnit test under KASAN (kunit.py --arch=x86_64):
- with patch 1: [PASSED] drm-sched-dma-fence-uaf
- without patch 1: [FAILED] - BUG: KASAN: slab-use-after-free in
drm_sched_fence_get_timeline_name+0x9c/0xb0 (read of the freed scheduler)
As discussed, the cleaner long-term fix is to drop drm_sched_fence's
ops->release so dma_fence detaches ->ops on signal and decouples the name
itself (Philipp); that is a larger sched_fence rework and is left as a
follow-up, with this cached-name fix as the immediate, backportable one.
Jonghyuk Kim(MalHyuk) (2):
drm/sched: cache the timeline name to fix a use-after-free
drm/sched/tests: add a UAF regression test for the timeline name
drivers/gpu/drm/scheduler/sched_fence.c | 16 +++-
drivers/gpu/drm/scheduler/tests/Makefile | 1 +
.../drm/scheduler/tests/tests_integration.c | 83 +++++++++++++++++++
include/drm/gpu_scheduler.h | 18 +++-
4 files changed, 116 insertions(+), 2 deletions(-)
create mode 100644 drivers/gpu/drm/scheduler/tests/tests_integration.c
--
2.43.0
next reply other threads:[~2026-09-02 10:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 10:58 Jonghyuk Kim(MalHyuk) [this message]
2026-09-02 10:58 ` [PATCH v2 1/2] drm/sched: cache the timeline name to fix a use-after-free Jonghyuk Kim(MalHyuk)
2026-09-02 10:58 ` [PATCH v2 2/2] drm/sched/tests: add a UAF regression test for the timeline name Jonghyuk Kim(MalHyuk)
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=20260902105808.1541063-1-malhyuk97@gmail.com \
--to=malhyuk97@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--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®