From: sashiko-bot@kernel.org
To: "Lizhi Hou" <lizhi.hou@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V3] accel/amdxdna: Prevent PM resume deadlock in hwctx_sync_debug_bo()
Date: Tue, 16 Jun 2026 21:41:02 +0000 [thread overview]
Message-ID: <20260616214103.184A31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616212429.3620645-1-lizhi.hou@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent destruction of hwctx causes a Use-After-Free because `dev_lock` is temporarily dropped during PM runtime resume without holding the SRCU read lock.
--
commit 3f02e0b8320e3b9382db4505bfac1b4c92265f29
Author: Lizhi Hou <lizhi.hou@amd.com>
accel/amdxdna: Prevent PM resume deadlock in hwctx_sync_debug_bo()
This commit addresses a potential deadlock by calling amdxdna_pm_resume_get()
before acquiring xdna->dev_lock in both amdxdna_hwctx_sync_debug_bo() and
amdxdna_drm_config_hwctx_ioctl().
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index 855da8c79a1cd..67a2abcf173ee 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
> @@ -382,16 +382,25 @@ int amdxdna_drm_config_hwctx_ioctl(struct drm_device *dev, void *data, struct dr
[ ... ]
> + mutex_lock(&xdna->dev_lock);
> hwctx = xa_load(&client->hwctx_xa, args->handle);
> if (!hwctx) {
> XDNA_DBG(xdna, "PID %d failed to get hwctx %d", client->pid, args->handle);
> ret = -EINVAL;
> - goto free_buf;
> + goto unlock;
> }
>
> ret = xdna->dev_info->ops->hwctx_config(hwctx, args->param_type, val, buf, buf_size);
[Severity: High]
This isn't a bug introduced by this patch, but does dropping the lock inside
this callback expose hwctx to a use-after-free?
If hwctx_config() (for example, aie2_hwctx_cu_config()) calls
amdxdna_pm_resume_get_locked(xdna), which temporarily unlocks and re-locks
xdna->dev_lock:
mutex_unlock(&xdna->dev_lock);
ret = amdxdna_pm_resume_get(xdna);
mutex_lock(&xdna->dev_lock);
During this window, could a concurrent amdxdna_drm_destroy_hwctx_ioctl()
acquire dev_lock, erase hwctx from the xarray, and call
amdxdna_hwctx_destroy_rcu()?
Because the SRCU read lock (client->hwctx_srcu) is not held here,
synchronize_srcu() wouldn't block, and hwctx could be freed while still
in use after re-acquiring dev_lock.
It appears a similar issue might also exist in amdxdna_update_heap(), which
iterates over hwctx_xa without the SRCU read lock and drops both mm_lock
and dev_lock inside the loop body via amdxdna_hwctx_expand_heap().
>
> +unlock:
> + mutex_unlock(&xdna->dev_lock);
> + amdxdna_pm_suspend_put(xdna);
> free_buf:
> kfree(buf);
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616212429.3620645-1-lizhi.hou@amd.com?part=1
next prev parent reply other threads:[~2026-06-16 21:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 21:24 [PATCH V3] accel/amdxdna: Prevent PM resume deadlock in hwctx_sync_debug_bo() Lizhi Hou
2026-06-16 21:41 ` sashiko-bot [this message]
2026-07-06 22:34 ` Max Zhen
2026-07-07 5:47 ` Lizhi Hou
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=20260616214103.184A31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lizhi.hou@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.