From: sashiko-bot@kernel.org
To: "Paolo Bonzini" <pbonzini@redhat.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 4/6] kvm: apply VM_READ/VM_WRITE checks to all VMA types
Date: Tue, 04 Aug 2026 12:23:48 +0000 [thread overview]
Message-ID: <20260804122348.AC6E51F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260804120529.1730187-5-pbonzini@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Write faults on write-only `VM_IO | VM_PFNMAP` VMAs are incorrectly rejected, breaking guest writes to write-only device memory.
--
--- Patch [4]: [PATCH v2 4/6] kvm: apply VM_READ/VM_WRITE checks to all VMA types ---
commit 254a4090eb1ddc66d1d90350bb0e3ef36a2ee158
Author: Paolo Bonzini <pbonzini@redhat.com>
kvm: apply VM_READ/VM_WRITE checks to all VMA types
This commit moves the VM_READ and VM_WRITE checks to the beginning of the
fallback VMA lookup block in hva_to_pfn(). This standardizes the error
return codes across remapped and regular VMAs, eliminating inconsistencies
in how RO faults are handled.
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 45e784462ec6e..576bcb21be3a6 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
[ ... ]
> @@ -3008,20 +2997,29 @@ kvm_pfn_t hva_to_pfn(struct kvm_follow_pfn *kfp)
> retry:
> vma = vma_lookup(current->mm, kfp->hva);
>
> - if (vma == NULL)
> + /*
> + * GUP failed. It could be an inaccessible mapping, a pfnmap one,
> + * or the page might be absent.
> + */
> +
> + if (vma == NULL || unlikely(!(vma->vm_flags & VM_READ))) {
[Severity: High]
Does this unconditionally reject write-only mappings?
If a guest performs a memory write to a guest physical address backed by a
write-only host VMA (e.g. VM_IO or VM_PFNMAP mapped with PROT_WRITE but
without PROT_READ), get_user_pages() will fail and fall back to this lookup.
Since the write-only VMA lacks VM_READ, this check will evaluate to true and
return KVM_PFN_ERR_FAULT, skipping the VM_IO | VM_PFNMAP handler. Could this
prevent guests from writing to legitimate write-only device memory, such as
command ring buffers or write-only PCI BARs?
> pfn = KVM_PFN_ERR_FAULT;
> - else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
> + } else if ((kfp->flags & FOLL_WRITE) && unlikely(!(vma->vm_flags & VM_WRITE))) {
> + /*
> + * Exit to userspace for PROT_READ mappings in a writable
> + * memslot, as this is part of the API.
> + */
> + pfn = vma->vm_flags & (VM_IO | VM_PFNMAP) ? KVM_PFN_ERR_RO_FAULT :
> + KVM_PFN_ERR_FAULT;
> + } else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
> r = hva_to_pfn_remapped(vma, kfp, &pfn);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804120529.1730187-1-pbonzini@redhat.com?part=4
next prev parent reply other threads:[~2026-08-04 12:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 12:05 [PATCH v2 0/6] mm, drm: fix interaction of .pfn_mkwrite() with fixup_user_fault() Paolo Bonzini
2026-08-04 12:05 ` [PATCH v2 1/6] mm: export vmf_insert_pfn_prot_mkwrite(), change variants to inline Paolo Bonzini
2026-08-04 12:20 ` sashiko-bot
2026-08-04 12:05 ` [PATCH v2 2/6] drm/shmem_helper: use vmf_insert_pfn_mkwrite() Paolo Bonzini
2026-08-04 12:30 ` sashiko-bot
2026-08-04 14:15 ` Boris Brezillon
2026-08-04 14:18 ` Boris Brezillon
2026-08-04 14:34 ` Paolo Bonzini
2026-08-04 14:42 ` Boris Brezillon
2026-08-05 6:08 ` Paolo Bonzini
2026-08-05 8:34 ` Boris Brezillon
2026-08-04 12:05 ` [PATCH v2 3/6] drm/ttm, drm/vmwgfx: directly create writable PTEs when mkwrite is in use Paolo Bonzini
2026-08-04 12:21 ` sashiko-bot
2026-08-04 12:47 ` Paolo Bonzini
2026-08-06 23:32 ` Peter Xu
2026-08-04 12:05 ` [PATCH v2 4/6] kvm: apply VM_READ/VM_WRITE checks to all VMA types Paolo Bonzini
2026-08-04 12:23 ` sashiko-bot [this message]
2026-08-04 12:44 ` Paolo Bonzini
2026-08-04 21:15 ` Sean Christopherson
2026-08-04 12:05 ` [PATCH v2 5/6] mm: pull writability check to follow_pfnmap_start() Paolo Bonzini
2026-08-04 12:14 ` sashiko-bot
2026-08-04 12:05 ` [PATCH v2 6/6] kvm: return -EFAULT for writes to !VM_WRITE IO mappings Paolo Bonzini
2026-08-04 12:14 ` sashiko-bot
2026-08-04 21:08 ` Sean Christopherson
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=20260804122348.AC6E51F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.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;
as well as URLs for NNTP newsgroup(s).