From: sashiko-bot@kernel.org
To: "Yaohan Li" <shunsheng1218@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH] drm/exynos: queue the IPP cleanup work before waking the caller
Date: Thu, 19 Nov 2026 02:48:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-222346@kernel.org> (raw)
In-Reply-To: <20261119023550.1495565-1-shunsheng1218@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/exynos: early DONE flag in exynos_drm_ipp_task_done() races
with waiter
- [Low] drm/exynos: inaccurate comment and changelog in
exynos_drm_ipp_task_done()
- [Low] drm/exynos: missing Fixes trailer for exynos_drm_ipp_task_done()
UAF fix
--
commit 358647e37f3b75ba1e0c967389989dcad2ba8a0e
Author: Yaohan Li <shunsheng1218@gmail.com>
> drm/exynos: queue the IPP cleanup work before waking the caller
>
> exynos_drm_ipp_task_done() marks the task done, wakes the waiters and only
> then decides whether the task has to be released by the cleanup work. A
> commit ioctl that waits for the task is woken by that wake_up() and frees
> the task itself as soon as it sees the DONE flag, so the task->flags read
> that follows touches memory that may already be gone.
>
> Read the flag while the task is still guaranteed to be alive, together
> with the other task state under ipp->lock, and queue the cleanup work
> before the wakeup. A task that is handed to the work is then always
> queued while it still exists.
>
> Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
[Severity: Low]
Should this bug fix include a Fixes tag?
Fixes: 9913f74fe157 ("drm/exynos: ipp: Add IPP v2 framework")
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> index 43bc4f63bb845..49ae8ce9b95a6 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> @@ -764,6 +764,7 @@ void exynos_drm_ipp_task_done(struct exynos_drm_ipp_task *task, int ret)
> {
> struct exynos_drm_ipp *ipp = task->ipp;
> unsigned long flags;
> + bool async;
>
> DRM_DEV_DEBUG_DRIVER(task->dev, "ipp: %d, task %p done: %d\n",
> ipp->id, task, ret);
> @@ -773,15 +774,22 @@ void exynos_drm_ipp_task_done(struct exynos_drm_ipp_task *task, int ret)
> ipp->task = NULL;
> task->flags |= DRM_EXYNOS_IPP_TASK_DONE;
> task->ret = ret;
> + async = task->flags & DRM_EXYNOS_IPP_TASK_ASYNC;
> spin_unlock_irqrestore(&ipp->lock, flags);
[Severity: High]
Can a synchronous waiter in exynos_drm_ipp_commit_ioctl() observe
DRM_EXYNOS_IPP_TASK_DONE and free task before exynos_drm_ipp_task_done()
finishes writing task->ret and reading DRM_EXYNOS_IPP_TASK_ASYNC?
Neither wait_event_interruptible() nor exynos_drm_ipp_task_cleanup() takes
ipp->lock:
drivers/gpu/drm/exynos/exynos_drm_ipp.c:exynos_drm_ipp_commit_ioctl() {
...
exynos_drm_ipp_schedule_task(ipp, task);
ret = wait_event_interruptible(ipp->done_wq,
task->flags & DRM_EXYNOS_IPP_TASK_DONE);
if (ret)
exynos_drm_ipp_task_abort(ipp, task);
else
ret = exynos_drm_ipp_task_cleanup(task);
...
}
Because wait_event_interruptible() checks task->flags locklessly before
sleeping (or when woken by an earlier task on the shared ipp->done_wq),
setting DRM_EXYNOS_IPP_TASK_DONE first allows the waiter to run
exynos_drm_ipp_task_cleanup() concurrently:
CPU0 CPU1
exynos_drm_ipp_task_done() exynos_drm_ipp_commit_ioctl()
spin_lock_irqsave(&ipp->lock)
task->flags |= ..._TASK_DONE;
wait_event_interruptible()
sees DRM_EXYNOS_IPP_TASK_DONE
exynos_drm_ipp_task_cleanup(task)
ret = task->ret; <-- stale 0
exynos_drm_ipp_task_free()
kfree(task)
task->ret = ret;
async = task->flags & ...; <-- use-after-free
Writing task->ret and reading DRM_EXYNOS_IPP_TASK_ASYNC before setting
DRM_EXYNOS_IPP_TASK_DONE (with release/acquire ordering or under
ipp->lock on the reader side) would avoid this race.
> exynos_drm_ipp_next_task(ipp);
> - wake_up(&ipp->done_wq);
>
> - if (task->flags & DRM_EXYNOS_IPP_TASK_ASYNC) {
> + /*
> + * Hand the task over to the cleanup work before a synchronous caller
> + * is woken up: once wake_up() returns, that caller may have released
> + * the task already.
> + */
> + if (async) {
> INIT_WORK(&task->cleanup_work, exynos_drm_ipp_cleanup_work);
> schedule_work(&task->cleanup_work);
> }
> +
> + wake_up(&ipp->done_wq);
> }
[Severity: Low]
Is this comment (and the corresponding explanation in the commit message)
accurate about why async is checked before wake_up()?
DRM_EXYNOS_IPP_TASK_ASYNC is only set for non-blocking commits (which do
not wait on ipp->done_wq) or in exynos_drm_ipp_task_abort() after
wait_event_interruptible() was already interrupted by a signal and handed
ownership of the running task to cleanup_work. When async is true, no
synchronous caller will free the task upon wake_up(); when a synchronous
caller is waiting to free the task, async is false. What prevents the
use-after-free is reading DRM_EXYNOS_IPP_TASK_ASYNC before the waiter can
observe task completion, rather than queuing cleanup_work before
wake_up().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119023550.1495565-1-shunsheng1218@gmail.com?part=1
next prev parent reply other threads:[~2026-11-19 2:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 2:35 [RFC PATCH] drm/exynos: queue the IPP cleanup work before waking the caller Yaohan Li
2026-11-19 2:48 ` sashiko-bot [this message]
2026-11-19 7:54 ` [RFC PATCH v2] drm/exynos: publish the IPP task completion after the last task access Yaohan Li
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-222346@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shunsheng1218@gmail.com \
/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