From: sashiko-bot@kernel.org
To: "Stanislav Kinsburskii" <skinsburskii@gmail.com>
Cc: linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v11 7/8] accel/amdxdna: Use hmm_range_fault_unlocked_timeout() for range population
Date: Thu, 23 Jul 2026 17:53:22 +0000 [thread overview]
Message-ID: <20260723175322.AC61D1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260723-hmm-v10-v11-7-c55b003a4b61@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Dereferencing `mapp->vma` without holding `mmap_lock` or a VMA lock leads to potential Use-After-Free.
--
--- Patch [7]: [PATCH v11 7/8] accel/amdxdna: Use hmm_range_fault_unlocked_timeout() for range population ---
commit 49a458a983bff0bc836f15feb7b3aa4763d7eb91
Author: Stanislav Kinsburskii <skinsburskii@gmail.com>
accel/amdxdna: Use hmm_range_fault_unlocked_timeout() for range population
This patch updates aie2_populate_range() to use the new
hmm_range_fault_unlocked_timeout() helper. The helper manages the mmap lock
and retry sequences internally. The driver now scopes the HMM retry timeout to
the helper while maintaining its outer invalidation loop.
> diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
> index 54486960cbf5e..b5b4ca263002d 100644
> --- a/drivers/accel/amdxdna/aie2_ctx.c
> +++ b/drivers/accel/amdxdna/aie2_ctx.c
[ ... ]
> @@ -1061,24 +1061,9 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo)
[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential
use-after-free with the VMA just before this block in aie2_populate_range():
XDNA_DBG(xdna, "populate memory range %lx %lx",
mapp->vma->vm_start, mapp->vma->vm_end);
mm = mapp->notifier.mm;
if (!mmget_not_zero(mm)) {
Is it safe to dereference mapp->vma here?
Since aie2_populate_range() only holds the xdna->notifier_lock at this point,
it doesn't appear to be tied to the VMA's lifetime. If a concurrent munmap
from another thread triggers an invalidation and frees the VMA entirely, could
the logging statement access a freed VMA structure when reading vm_start and
vm_end?
> return -EFAULT;
> }
>
> - mapp->range.notifier_seq = mmu_interval_read_begin(&mapp->notifier);
> - mmap_read_lock(mm);
> - ret = hmm_range_fault(&mapp->range);
> - mmap_read_unlock(mm);
> - if (ret) {
> - if (time_after(jiffies, timeout)) {
> - ret = -ETIME;
> - goto put_mm;
> - }
> -
> - if (ret == -EBUSY) {
> - amdxdna_umap_put(mapp);
> - mmput(mm);
> - goto again;
> - }
> -
> + ret = hmm_range_fault_unlocked_timeout(&mapp->range, timeout);
> + if (ret)
> goto put_mm;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723-hmm-v10-v11-0-c55b003a4b61@gmail.com?part=7
next prev parent reply other threads:[~2026-07-23 17:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 17:36 [PATCH v11 0/8] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 1/8] mm/hmm: move page fault handling out of walk callbacks Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 2/8] mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support Stanislav Kinsburskii
2026-07-23 17:50 ` sashiko-bot
2026-07-23 17:36 ` [PATCH v11 3/8] selftests/mm: add HMM test for mmap lock-dropping faults Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 4/8] mshv: Use hmm_range_fault_unlocked_timeout() for region faults Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 5/8] drm/nouveau: Use hmm_range_fault_unlocked_timeout() for SVM faults Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 6/8] RDMA/umem: Use hmm_range_fault_unlocked_timeout() for ODP faults Stanislav Kinsburskii
2026-07-23 17:36 ` [PATCH v11 7/8] accel/amdxdna: Use hmm_range_fault_unlocked_timeout() for range population Stanislav Kinsburskii
2026-07-23 17:53 ` sashiko-bot [this message]
2026-07-23 17:36 ` [PATCH v11 8/8] drm/gpusvm: Use hmm_range_fault_unlocked_timeout() for range faults Stanislav Kinsburskii
2026-07-23 17:54 ` sashiko-bot
2026-07-23 21:22 ` [PATCH v11 0/8] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings Andrew Morton
2026-07-23 22:22 ` Stanislav Kinsburskii
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=20260723175322.AC61D1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=skinsburskii@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