mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Jhonraushan <raushan.jhon@gmail.com>, Min Ma <mamin506@gmail.com>,
	"Oded Gabbay" <ogabbay@kernel.org>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] accel/amdxdna: Fix double drm_gem_object_put() in dma-buf mmap error path
Date: Thu, 2 Jul 2026 08:47:33 -0700	[thread overview]
Message-ID: <d0fe2a48-d664-97a6-241e-3107c72de40b@amd.com> (raw)
In-Reply-To: <20260702072540.2183601-1-raushan.jhon@gmail.com>

Thanks for providing the patch. There was a same patch posted: 
https://lore.kernel.org/all/20260625113239.49764-1-vulab@iscas.ac.cn/

Lizhi

On 7/2/26 00:25, Jhonraushan wrote:
> amdxdna_gem_dmabuf_mmap() takes a reference with drm_gem_object_get()
> and, on the vm_insert_pages() failure path, jumps to close_vma which
> calls vma->vm_ops->close(). For a shmem GEM object vm_ops is
> drm_gem_shmem_vm_ops, whose .close (drm_gem_shmem_vm_close ->
> drm_gem_vm_close) already drops that reference. Execution then falls
> through to put_obj and drops it a second time.
>
> This underflows the GEM object refcount and frees it prematurely while
> the dma-buf still references it, leading to a use-after-free.
>
> Return directly after vm_ops->close() instead of falling through to the
> extra drm_gem_object_put(), matching the sibling amdxdna_insert_pages()
> error path.
>
> Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jhonraushan <raushan.jhon@gmail.com>
> ---
>   drivers/accel/amdxdna/amdxdna_gem.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index 891112c2cddf..3ac8c345b25b 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -526,7 +526,12 @@ static int amdxdna_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struc
>   	return 0;
>   
>   close_vma:
> +	/* vm_ops->close() drops the reference taken by drm_gem_object_get()
> +	 * above, so return directly instead of falling through to put_obj
> +	 * and dropping it a second time.
> +	 */
>   	vma->vm_ops->close(vma);
> +	return ret;
>   put_obj:
>   	drm_gem_object_put(gobj);
>   	return ret;

      reply	other threads:[~2026-07-02 15:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  7:25 Jhonraushan
2026-07-02 15:47 ` Lizhi Hou [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=d0fe2a48-d664-97a6-241e-3107c72de40b@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=raushan.jhon@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

all inboxes | Powered by JetHome®