dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lizhi Hou" <lizhi.hou@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V1] accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults
Date: Thu, 17 Sep 2026 16:05:32 +0000	[thread overview]
Message-ID: <20260917160532.8FFFF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917154920.1872289-1-lizhi.hou@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] amdxdna: stale VMA permissions cache in hmm_range_fault breaks mprotect()
--

commit bfad63cfebe7db959de532304657044547acec26
Author: Lizhi Hou <lizhi.hou@amd.com>

accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults

This patch updates aie2_populate_range() to check the VMA flags and
set HMM_PFN_REQ_WRITE when the VMA has VM_WRITE. This ensures that
handle_mm_fault() requests write permissions instead of populating CPU
page tables with read-only PTEs.

> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index 5a1a2ee261b76..df8e76b5f38a0 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -429,6 +429,8 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
>  	mapp->range.start = vma->vm_start;
>  	mapp->range.end = vma->vm_end;
>  	mapp->range.default_flags = HMM_PFN_REQ_FAULT;
> +	if (vma->vm_flags & VM_WRITE)
> +		mapp->range.default_flags |= HMM_PFN_REQ_WRITE;

[Severity: High]
Does this statically cache the VMA write permissions during mmap?

If userspace later downgrades permissions via mprotect(PROT_READ) and
submits a job, could hmm_range_fault() fail with -EPERM because it still
demands write access on a read-only VMA? Conversely, if userspace upgrades
to PROT_WRITE via mprotect, it seems the driver would fail to request write
permissions, which might re-introduce the IOMMU faults this patch intended
to fix.

Since the permissions are permanently cached into the HMM range default
flags in amdxdna_hmm_register(), any unprivileged userspace application
mapping a buffer object and modifying its permissions could trigger this.

>  	mapp->abo = abo;
>  	kref_init(&mapp->refcnt);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917154920.1872289-1-lizhi.hou@amd.com?part=1

      reply	other threads:[~2026-09-17 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 15:49 [PATCH V1] accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults Lizhi Hou
2026-09-17 16:05 ` sashiko-bot [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=20260917160532.8FFFF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lizhi.hou@amd.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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