All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Steven Price" <steven.price@arm.com>,
	kvm@vger.kernel.org, kvmarm@lists.linux.dev
Cc: "Oliver Upton" <oupton@kernel.org>, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v2 02/12] KVM: arm64: guest_memfd: Check mmap support when preparing memslot
Date: Wed, 11 Nov 2026 16:30:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-209288@kernel.org> (raw)
In-Reply-To: <20261111145758.217946-3-steven.price@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: arm64: mmap check bypassed in
  kvm_arch_prepare_memory_region()
--

commit 30a76d4c8b8b8454f9d59879df7f0b5de9a2cdbb
Author: Steven Price <steven.price@arm.com>

KVM: arm64: guest_memfd: Check mmap support when preparing memslot

This commit adds kvm_gmem_slot_supports_mmap() and updates
kvm_arch_prepare_memory_region() to check whether the guest_memfd backing
file supports mmap rather than checking kvm_memslot_is_gmem_only().

> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 1db10d8d6db73..a146f6cde3d02 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -2839,10 +2839,11 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
>  		return -EFAULT;
>  
>  	/*
> -	 * Only support guest_memfd backed memslots with mappable memory, since
> -	 * there aren't any CoCo VMs that support only private memory on arm64.
> +	 * Protected VMs currently require guest_memfd backed memslots with
> +	 * mappable memory to support shared mappings.
>  	 */
> -	if (kvm_slot_has_gmem(new) && !kvm_memslot_is_gmem_only(new))
> +	if (kvm_arch_has_private_mem(kvm) && kvm_slot_has_gmem(new) &&
> +	    !kvm_gmem_slot_supports_mmap(new))
>  		return -EINVAL;

[Severity: Medium]
Does gating this check on kvm_arch_has_private_mem(kvm) cause a
regression that allows binding non-mappable guest_memfds to non-Realm VMs
on arm64?

At this commit kvm_arch_has_private_mem(kvm) resolves to the stub in
include/linux/kvm_host.h that unconditionally returns false, and even
after commit "KVM: arm64: CCA: Prevent memslot modifications after Realm
creation" defines it as kvm_vm_is_realm(kvm), it remains false for all
non-Realm VMs.

Userspace can then create a guest_memfd without GUEST_MEMFD_FLAG_MMAP and
bind it to a normal VM via KVM_SET_USER_MEMORY_REGION2.  Stage-2 faults
in kvm_vm_mem_abort() -> gmem_abort() will fault those unmappable pages
into the guest while HVA-based KVM accesses via slot->userspace_addr
(such as kvm_read_guest() and kvm_write_guest()) access unrelated VMA
memory.  Dropping the kvm_arch_has_private_mem(kvm) condition here would
preserve the requirement across all arm64 VMs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111145758.217946-1-steven.price@arm.com?part=2

  parent reply	other threads:[~2026-11-11 16:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 14:57 [PATCH v2 00/12] KVM: arm64: CCA: Prepare Realm memory management Steven Price
2026-11-11 14:57 ` [PATCH v2 01/12] KVM: arm64: CCA: Reserve the RMM mode Steven Price
2026-11-11 14:57 ` [PATCH v2 02/12] KVM: arm64: guest_memfd: Check mmap support when preparing memslot Steven Price
2026-11-11 15:21   ` Suzuki K Poulose
2026-11-12 10:43     ` Steven Price
2026-11-12 16:35       ` Suzuki K Poulose
2026-11-12 16:57         ` Suzuki K Poulose
2026-11-11 16:30   ` sashiko-bot [this message]
2026-11-11 14:57 ` [PATCH v2 03/12] KVM: arm64: CCA: Introduce Realms Steven Price
2026-11-11 14:57 ` [PATCH v2 04/12] KVM: arm64: CCA: Check RMI support and features at init Steven Price
2026-11-12 16:39   ` Suzuki K Poulose
2026-11-11 14:57 ` [PATCH v2 05/12] KVM: arm64: Handle attributes in stage2_unmap_range Steven Price
2026-11-11 14:57 ` [PATCH v2 06/12] KVM: arm64: CCA: Add basic infrastructure for creating a realm Steven Price
2026-11-11 14:57 ` [PATCH v2 07/12] KVM: arm64: CCA: Tear down RTTs Steven Price
2026-11-11 17:38   ` sashiko-bot
2026-11-12 13:47     ` Steven Price
2026-11-11 14:57 ` [PATCH v2 08/12] KVM: arm64: CCA: Add Realm RTT mapping and invalidation helpers Steven Price
2026-11-11 18:06   ` sashiko-bot
2026-11-12 16:38     ` Steven Price
2026-11-11 14:57 ` [PATCH v2 09/12] KVM: Allow architectures to reject memslot changes before invalidation Steven Price
2026-11-11 14:57 ` [PATCH v2 10/12] KVM: arm64: CCA: Prevent memslot modifications after Realm creation Steven Price
2026-11-11 18:54   ` sashiko-bot
2026-11-11 14:57 ` [PATCH v2 11/12] KVM: arm64: CCA: Support runtime faulting of memory Steven Price
2026-11-11 19:34   ` sashiko-bot
2026-11-11 14:57 ` [PATCH v2 12/12] KVM: arm64: CCA: Add Realm stage-2 MMU operations Steven Price
2026-11-12  9:08 ` [PATCH v2 00/12] KVM: arm64: CCA: Prepare Realm memory management Kohei Enju
2026-11-12  9:41   ` Steven Price

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=sashiko-outbox-209288@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=steven.price@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.