From: sashiko-bot@kernel.org
To: "Ackerley Tng via B4 Relay" <devnull+ackerleytng.google.com@kernel.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v6 06/43] KVM: x86/mmu: Bug the VM if gmem attributes are queried to determine max mapping level
Date: Wed, 27 May 2026 03:29:52 +0000 [thread overview]
Message-ID: <20260527032952.DB30A1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260507-gmem-inplace-conversion-v6-6-91ab5a8b19a4@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The newly added KVM_BUG_ON check in kvm_mmu_max_mapping_level evaluates global state and unconditionally crashes standard, non-confidential VMs whenever user-space disables dirty logging.
- [Low] The patch unconditionally references conditionally compiled symbols (`__kvm_get_memory_attributes` and `kvm_gmem_get_memory_attributes`), resulting in build and link failures on standard configurations.
--
commit ffa430675edb844f07837310c0934745f310bf26
Author: Ackerley Tng <ackerleytng@google.com>
KVM: x86/mmu: Bug the VM if gmem attributes are queried to determine max mapping level
This commit introduces a KVM_BUG_ON check in kvm_mmu_max_mapping_level()
to prevent querying guest_memfd memory attributes while holding the MMU
lock.
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index a80a876ab4ad6..153bcc5369985 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
[ ... ]
> @@ -3357,6 +3357,15 @@ int kvm_mmu_max_mapping_level(struct kvm *kvm, struct kvm_page_fault *fault,
> max_level = fault->max_level;
> is_private = fault->is_private;
> } else {
> + /*
> + * Memory attributes cannot be obtained from guest_memfd while
> + * the MMU lock is held.
> + */
> + if (KVM_BUG_ON(static_call_query(__kvm_get_memory_attributes) ==
> + kvm_gmem_get_memory_attributes, kvm)) {
[Severity: Low]
Does this code cause build and link failures on standard configurations?
When CONFIG_KVM_MEMORY_ATTRIBUTES is disabled (e.g. standard x86 builds
without confidential VM features), __kvm_get_memory_attributes is not
declared.
Additionally, on 32-bit builds where CONFIG_KVM_GUEST_MEMFD is disabled,
kvm_gmem_get_memory_attributes is undefined. Unconditionally referencing
these symbols here breaks the build on those setups.
[Severity: High]
Does this check evaluate global state instead of checking if the specific
memslot uses guest_memfd, potentially crashing standard VMs?
On standard x86_64 configurations, KVM initialization can set this global
static call to kvm_gmem_get_memory_attributes for all VMs. If userspace
(like QEMU) disables dirty logging on any memslot, KVM triggers huge page
recovery:
kvm_tdp_mmu_recover_huge_pages()
kvm_mmu_max_mapping_level(..., fault = NULL, ...)
Since fault is NULL, this executes the KVM_BUG_ON() check. Because the
global static call matches, the condition evaluates to true and immediately
kills the innocent VM via kvm_vm_bugged().
Could an unprivileged userspace VMM trigger a local denial of service
simply by toggling dirty logging on standard non-confidential VMs?
> + return 0;
> + }
> +
> max_level = PG_LEVEL_NUM;
> is_private = kvm_mem_is_private(kvm, gfn);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260507-gmem-inplace-conversion-v6-0-91ab5a8b19a4@google.com?part=6
next prev parent reply other threads:[~2026-05-27 3:29 UTC|newest]
Thread overview: 144+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 20:22 [PATCH v6 00/43] guest_memfd: In-place conversion support Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 01/43] KVM: guest_memfd: Introduce per-gmem attributes, use to guard user mappings Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-08 23:36 ` Ackerley Tng
2026-05-22 21:45 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 02/43] KVM: Rename KVM_GENERIC_MEMORY_ATTRIBUTES to KVM_VM_MEMORY_ATTRIBUTES Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 12:08 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 03/43] KVM: Enumerate support for PRIVATE memory iff kvm_arch_has_private_mem is defined Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 12:08 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 04/43] KVM: Stub in ability to disable per-VM memory attribute tracking Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 12:08 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 05/43] KVM: guest_memfd: Wire up kvm_get_memory_attributes() to per-gmem attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 12:08 ` Fuad Tabba
2026-05-20 18:59 ` Sean Christopherson
2026-05-20 21:44 ` Ackerley Tng
2026-05-21 7:19 ` Fuad Tabba
2026-05-21 13:31 ` Sean Christopherson
2026-05-21 13:48 ` Fuad Tabba
2026-05-21 14:29 ` Ackerley Tng
2026-05-27 15:35 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 06/43] KVM: x86/mmu: Bug the VM if gmem attributes are queried to determine max mapping level Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 13:33 ` Fuad Tabba
2026-05-20 14:21 ` Sean Christopherson
2026-05-20 20:25 ` Ackerley Tng
2026-05-20 20:39 ` Sean Christopherson
2026-05-27 3:29 ` sashiko-bot [this message]
2026-05-07 20:22 ` [PATCH v6 07/43] KVM: guest_memfd: Update kvm_gmem_populate() to use gmem attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 13:47 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 08/43] KVM: guest_memfd: Only prepare folios for private pages Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 13:51 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 09/43] KVM: Move kvm_supported_mem_attributes() to kvm_host.h Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 13:53 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 10/43] KVM: guest_memfd: Add base support for KVM_SET_MEMORY_ATTRIBUTES2 Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 14:00 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 11/43] KVM: guest_memfd: Ensure pages are not in use before conversion Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 14:28 ` Fuad Tabba
2026-05-21 7:09 ` Fuad Tabba
2026-05-21 14:36 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 12/43] KVM: guest_memfd: Call arch invalidate hooks on conversion Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 14:30 ` Fuad Tabba
2026-05-20 20:35 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 13/43] KVM: guest_memfd: Return early if range already has requested attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 14:44 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 14/43] KVM: guest_memfd: Advertise KVM_SET_MEMORY_ATTRIBUTES2 ioctl Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 15:22 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 15/43] KVM: guest_memfd: Handle lru_add fbatch refcounts during conversion safety check Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 7:13 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 16/43] KVM: guest_memfd: Use actual size for invalidation in kvm_gmem_release() Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 7:30 ` Fuad Tabba
2026-05-21 12:59 ` Sean Christopherson
2026-05-21 13:29 ` Fuad Tabba
2026-05-21 14:40 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 17/43] KVM: guest_memfd: Determine invalidation filter from memory attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 7:56 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 18/43] KVM: Move KVM_VM_MEMORY_ATTRIBUTES config definition to x86 Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 8:07 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 19/43] KVM: Let userspace disable per-VM mem attributes, enable per-gmem attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 8:44 ` Fuad Tabba
2026-05-21 14:21 ` Sean Christopherson
2026-05-07 20:22 ` [PATCH v6 20/43] KVM: guest_memfd: Enable INIT_SHARED on guest_memfd for x86 Coco VMs Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-20 22:04 ` Ackerley Tng
2026-05-21 8:54 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 21/43] KVM: SEV: Make 'uaddr' parameter optional for KVM_SEV_SNP_LAUNCH_UPDATE Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 9:55 ` Fuad Tabba
2026-05-21 13:21 ` Sean Christopherson
2026-05-21 21:27 ` Ackerley Tng
2026-05-22 13:08 ` Sean Christopherson
2026-05-07 20:22 ` [PATCH v6 22/43] KVM: TDX: Make source page optional for KVM_TDX_INIT_MEM_REGION Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 23/43] KVM: selftests: Create gmem fd before "regular" fd when adding memslot Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 12:11 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 24/43] KVM: selftests: Rename guest_memfd{,_offset} to gmem_{fd,offset} Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-21 12:13 ` Fuad Tabba
2026-05-07 20:22 ` [PATCH v6 25/43] KVM: selftests: Add support for mmap() on guest_memfd in core library Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-22 23:02 ` Ackerley Tng
2026-05-07 20:22 ` [PATCH v6 26/43] KVM: selftests: Add selftests global for guest memory attributes capability Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 27/43] KVM: selftests: Add helpers for calling ioctls on guest_memfd Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 28/43] KVM: selftests: Test basic single-page conversion flow Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 29/43] KVM: selftests: Test conversion flow when INIT_SHARED Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 30/43] KVM: selftests: Test conversion precision in guest_memfd Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 31/43] KVM: selftests: Test conversion before allocation Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 32/43] KVM: selftests: Convert with allocated folios in different layouts Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 33/43] KVM: selftests: Test that truncation does not change shared/private status Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 34/43] KVM: selftests: Test that shared/private status is consistent across processes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-27 1:29 ` sashiko-bot
2026-05-07 20:22 ` [PATCH v6 35/43] KVM: selftests: Test conversion with elevated page refcount Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 36/43] KVM: selftests: Reset shared memory after hole-punching Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 37/43] KVM: selftests: Provide function to look up guest_memfd details from gpa Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 38/43] KVM: selftests: Provide common function to set memory attributes Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-27 1:45 ` sashiko-bot
2026-05-07 20:22 ` [PATCH v6 39/43] KVM: selftests: Check fd/flags provided to mmap() when setting up memslot Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:22 ` [PATCH v6 40/43] KVM: selftests: Make TEST_EXPECT_SIGBUS thread-safe Ackerley Tng
2026-05-07 20:22 ` Ackerley Tng via B4 Relay
2026-05-07 20:23 ` [PATCH v6 41/43] KVM: selftests: Update private_mem_conversions_test to mmap() guest_memfd Ackerley Tng
2026-05-07 20:23 ` Ackerley Tng via B4 Relay
2026-05-07 20:23 ` [PATCH v6 42/43] KVM: selftests: Add script to exercise private_mem_conversions_test Ackerley Tng
2026-05-07 20:23 ` Ackerley Tng via B4 Relay
2026-05-27 1:21 ` sashiko-bot
2026-05-07 20:23 ` [PATCH v6 43/43] KVM: selftests: Update private memory exits test to work with per-gmem attributes Ackerley Tng
2026-05-07 20:23 ` Ackerley Tng via B4 Relay
2026-05-07 20:34 ` [POC PATCH 0/5] guest_memfd in-place conversion selftests for SNP Ackerley Tng
2026-05-07 20:34 ` [POC PATCH 1/5] KVM: selftests: Initialize guest_memfd with INIT_SHARED Ackerley Tng
2026-05-07 20:34 ` [POC PATCH 2/5] KVM: selftests: Use guest_memfd memory contents in-place for SNP launch update Ackerley Tng
2026-05-07 20:34 ` [POC PATCH 3/5] KVM: selftests: Make guest_code_xsave more friendly Ackerley Tng
2026-05-07 20:34 ` [POC PATCH 4/5] KVM: selftests: Allow specifying CoCo-privateness while mapping a page Ackerley Tng
2026-05-07 20:34 ` [POC PATCH 5/5] KVM: selftests: Test conversions for SNP Ackerley Tng
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=20260527032952.DB30A1F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+ackerleytng.google.com@kernel.org \
--cc=kvm@vger.kernel.org \
--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 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.