mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 potential amdxdna_umap lifetime race
Date: Tue, 7 Jul 2026 08:35:45 -0700	[thread overview]
Message-ID: <1b123fd9-12e5-4ca0-9328-97144af00f66@amd.com> (raw)
In-Reply-To: <20260706221228.434099-1-lizhi.hou@amd.com>



On 7/6/2026 Mon 15:12, Lizhi Hou wrote:
> amdxdna_umap_release() calls the blocking mmu_interval_notifier_remove()
> before removing the object from abo->mem.umap_list. If
> aie2_populate_range() runs concurrently, it may obtain a reference to an
> amdxdna_umap that is being released, leading to a potential use-after-free.
> 
> Use refcount_inc_not_zero() in aie2_populate_range() when acquiring a
> reference. If the reference count has already dropped to zero, release
> is in progress and the entry is skipped.
> 
> Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>

The patch description mentioned refcount_inc_not_zero(), but the real 
fix calls kref_get_unless_zero() which is a wrapper of 
refcount_inc_not_zero(). It might be better to fix the description to 
match the fix in the code.

Thanks,
Max
> ---
>   drivers/accel/amdxdna/aie2_ctx.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
> index 408ff7e2a272..7bf635634e64 100644
> --- a/drivers/accel/amdxdna/aie2_ctx.c
> +++ b/drivers/accel/amdxdna/aie2_ctx.c
> @@ -1039,7 +1039,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo)
>   	found = false;
>   	down_write(&xdna->notifier_lock);
>   	list_for_each_entry(mapp, &abo->mem.umap_list, node) {
> -		if (mapp->invalid) {
> +		if (mapp->invalid && kref_get_unless_zero(&mapp->refcnt)) {
>   			found = true;
>   			break;
>   		}
> @@ -1050,7 +1050,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo)
>   		up_write(&xdna->notifier_lock);
>   		return 0;
>   	}
> -	kref_get(&mapp->refcnt);
> +
>   	up_write(&xdna->notifier_lock);
>   
>   	mm = mapp->notifier.mm;


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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 22:12 Lizhi Hou
2026-07-07 15:35 ` Max Zhen [this message]
2026-07-07 17:13   ` 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=1b123fd9-12e5-4ca0-9328-97144af00f66@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®