From: Lizhi Hou <lizhi.hou@amd.com>
To: Wentao Liang <vulab@iscas.ac.cn>, <mamin506@gmail.com>,
<ogabbay@kernel.org>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] accel/amdxdna: Fix use-after-free in amdxdna_gem_dmabuf_mmap()
Date: Fri, 26 Jun 2026 09:47:42 -0700 [thread overview]
Message-ID: <cb0d1d74-2be5-8b54-4638-4c9629b15055@amd.com> (raw)
In-Reply-To: <20260625113239.49764-1-vulab@iscas.ac.cn>
On 6/25/26 04:32, Wentao Liang wrote:
> When vm_insert_pages() fails, the error path calls vma->vm_ops->close(vma)
> which internally calls drm_gem_vm_close() → drm_gem_object_put(),
> releasing the GEM object reference acquired at the start of the function.
> However, the close_vma label then falls through to put_obj, which calls
> drm_gem_object_put() a second time on the same object.
>
> If the first put releases the last reference, the object is freed and the
> second put accesses freed memory, causing a use-after-free.
>
> Fix by returning directly from close_vma instead of falling through to
> put_obj, since the close handler already performs all necessary cleanup
> including the object put.
>
> Cc: stable@vger.kernel.org
> Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/accel/amdxdna/amdxdna_gem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index 6e367ddb9e1b..fec9763c518c 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -469,6 +469,7 @@ static int amdxdna_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struc
>
> close_vma:
> vma->vm_ops->close(vma);
> + return ret;
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
> put_obj:
> drm_gem_object_put(gobj);
> return ret;
next prev parent reply other threads:[~2026-06-26 16:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 11:32 Wentao Liang
2026-06-26 16:47 ` Lizhi Hou [this message]
2026-07-02 17:38 ` 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=cb0d1d74-2be5-8b54-4638-4c9629b15055@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mamin506@gmail.com \
--cc=ogabbay@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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