From: Max Zhen <max.zhen@amd.com>
To: Lizhi Hou <lizhi.hou@amd.com>, <ogabbay@kernel.org>,
<quic_jhugo@quicinc.com>, <dri-devel@lists.freedesktop.org>,
<mario.limonciello@amd.com>, <karol.wachowski@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <sonal.santan@amd.com>
Subject: Re: [PATCH V1] accel/amdxdna: Fix use-after-free of mm_struct in job scheduler
Date: Thu, 16 Jul 2026 08:27:09 -0700 [thread overview]
Message-ID: <e2d84f97-ab96-46ae-8639-54aeabc822ad@amd.com> (raw)
In-Reply-To: <20260716151305.1595780-1-lizhi.hou@amd.com>
On 7/16/2026 Thu 08:13, Lizhi Hou wrote:
> amdxdna_cmd_submit() stores current->mm in job->mm without holding any
> reference. aie2_sched_job_run() later access job->mm from the DRM
> scheduler worker thread. With only a raw pointer and no structural
> reference, the mm_struct can be freed before the scheduler runs the job.
>
> Fix this by calling mmgrab() to hold a structural mm_count reference for
> the lifetime of the job, paired with mmdrop() in every cleanup path.
>
> Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
> drivers/accel/amdxdna/amdxdna_ctx.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index bdbd3db12a6c..31a414c3f0d9 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
> @@ -577,6 +577,7 @@ void amdxdna_sched_job_cleanup(struct amdxdna_sched_job *job)
> amdxdna_arg_bos_put(job);
> amdxdna_gem_put_obj(job->cmd_bo);
> dma_fence_put(job->fence);
> + mmdrop(job->mm);
> }
>
> int amdxdna_cmd_submit(struct amdxdna_client *client,
> @@ -642,6 +643,7 @@ int amdxdna_cmd_submit(struct amdxdna_client *client,
>
> job->hwctx = hwctx;
> job->mm = current->mm;
> + mmgrab(job->mm);
>
> job->fence = amdxdna_fence_create(hwctx);
> if (!job->fence) {
> @@ -676,6 +678,8 @@ int amdxdna_cmd_submit(struct amdxdna_client *client,
> cmd_put:
> amdxdna_gem_put_obj(job->cmd_bo);
> free_job:
> + if (job->mm)
> + mmdrop(job->mm);
> kfree(job);
> return ret;
> }
prev parent reply other threads:[~2026-07-16 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 15:13 Lizhi Hou
2026-07-16 15:27 ` Max Zhen [this message]
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=e2d84f97-ab96-46ae-8639-54aeabc822ad@amd.com \
--to=max.zhen@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karol.wachowski@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=mario.limonciello@amd.com \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.com \
--cc=sonal.santan@amd.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
all inboxes | Powered by JetHome®