dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jonghyuk Kim(MalHyuk)" <malhyuk97@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/2] drm/sched/tests: add a UAF regression test for the timeline name
Date: Wed, 02 Sep 2026 15:04:57 +0000	[thread overview]
Message-ID: <20260902150457.770CF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902144204.1843670-3-malhyuk97@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Test abortion on `KUNIT_ASSERT_TRUE` failure skips manual cleanup, causing Use-After-Free crashes from background tasks.
--

commit a2c80bbffa3f457ad719c5864b695730ec7e1976
Author: Jonghyuk Kim(MalHyuk) <malhyuk97@gmail.com>

drm/sched/tests: add a UAF regression test for the timeline name

This commit adds an integration KUnit test to reproduce a use-after-free
in the drm_sched_fence timeline-name. It exercises the interaction between
the DRM scheduler and the dma-fence API by submitting a job, freeing the
scheduler, and querying the timeline name.

> diff --git a/drivers/gpu/drm/scheduler/tests/tests_integration.c b/drivers/gpu/drm/scheduler/tests/tests_integration.c
> new file mode 100644
> index 0000000000000..5e1ca6c6fa5a2
> --- /dev/null
> +++ b/drivers/gpu/drm/scheduler/tests/tests_integration.c
[ ... ]
> +static void drm_sched_dma_fence_uaf(struct kunit *test)
> +{
[ ... ]
> +	/* Let the job get scheduled (hw fence created), then signal + finish. */
> +	done = drm_mock_sched_job_wait_scheduled(job, HZ);
> +	KUNIT_ASSERT_TRUE(test, done);

[Severity: Medium]
If this assertion fails, the test aborts and skips manual cleanup like
drm_mock_sched_fini(). Because KUnit automatically frees memory allocated with
kunit_kzalloc() upon test abortion, active background tasks such as DRM
scheduler workqueues and job hrtimers will access freed memory.

Does this cause a use-after-free crash if the wait times out and returns false?

> +	drm_mock_sched_advance(sched, 1);
> +	done = drm_mock_sched_job_wait_finished(job, HZ);
> +	KUNIT_ASSERT_TRUE(test, done);

[Severity: Medium]
Similarly, can a failure on this assertion cause a use-after-free by aborting
the test before the cleanup code runs?

> +
> +	/*
> +	 * Free the per-context scheduler while the finished fence is held.
> +	 * kunit_kfree() releases the backing memory immediately (rather than at
> +	 * test teardown) so that fence->sched becomes a dangling pointer now.
> +	 */
> +	drm_mock_sched_entity_free(entity);
> +	drm_mock_sched_fini(sched);
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902144204.1843670-1-malhyuk97@gmail.com?part=2

  reply	other threads:[~2026-09-02 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 14:42 [PATCH v3 0/2] drm/sched: fix use-after-free of the fence timeline name Jonghyuk Kim(MalHyuk)
2026-09-02 14:42 ` [PATCH v3 1/2] " Jonghyuk Kim(MalHyuk)
2026-09-02 14:58   ` sashiko-bot
2026-09-03  8:46   ` Philipp Stanner
2026-09-03 10:02     ` Christian König
2026-09-03 10:22     ` Christian König
2026-09-02 14:42 ` [PATCH v3 2/2] drm/sched/tests: add a UAF regression test for the " Jonghyuk Kim(MalHyuk)
2026-09-02 15:04   ` sashiko-bot [this message]
2026-09-02 16:09 ` [PATCH v3 0/2] drm/sched: fix use-after-free of the fence " Philipp Stanner
2026-09-02 17:25   ` 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=20260902150457.770CF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=malhyuk97@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox