All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paolo Bonzini" <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 7.2-based 01/19] KVM: x86/hyperv: remove unnecessary mmu_is_nested() check
Date: Wed, 24 Jun 2026 22:07:17 +0000	[thread overview]
Message-ID: <20260624220718.2AAAD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624214218.73796-2-pbonzini@redhat.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] When an L2 guest issues a slow Hyper-V flush hypercall without nEPT/nNPT enabled, the commit fails to translate the L2 GPA or return an error, instead interpreting the untranslated L2-provided GPA as an L1 GPA. This allows the L2 guest to read arbitrary L1 memory for hypercall parameters.
- [High] When translating an L2 GPA to an L1 GPA for slow Hyper-V hypercalls, KVM translates only the base address (`hc->ingpa`) and then reads contiguous L1 physical memory. It fails to apply L2's nested EPT (nEPT) mappings for subsequent pages if the hypercall input data crosses an L2 page boundary, leaking out-of-bounds L1 memory.
--

commit 5644e8b1976b85a1ec2e9308b24a274e70825283
Author: Paolo Bonzini <pbonzini@redhat.com>

KVM: x86/hyperv: remove unnecessary mmu_is_nested() check

This commit simplifies kvm_hv_flush_tlb() by using kvm_translate_gpa()
instead of calling translate_nested_gpa() directly. This addresses the
nEPT/nNPT check in slow flush hypercalls.

> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index fd4eb1e561f7f..0b5050cccab4d 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -2045,10 +2045,9 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
>  	 * flush).  Translate the address here so the memory can be uniformly
>  	 * read with kvm_read_guest().
>  	 */
> -	if (!hc->fast && mmu_is_nested(vcpu)) {
> -		hc->ingpa = kvm_x86_ops.nested_ops->translate_nested_gpa(
> -					vcpu, hc->ingpa,
> -					PFERR_GUEST_FINAL_MASK, NULL, 0);
> +	if (!hc->fast) {
> +		hc->ingpa = kvm_translate_gpa(vcpu, vcpu->arch.walk_mmu, hc->ingpa,
> +					      PFERR_GUEST_FINAL_MASK, NULL, 0);
>  		if (unlikely(hc->ingpa == INVALID_GPA))
>  			return HV_STATUS_INVALID_HYPERCALL_INPUT;
>  	}

[Severity: High]
This isn't a bug introduced by this patch, but when an L2 guest issues a
slow Hyper-V flush hypercall without nEPT/nNPT enabled, it appears we fail
to translate the L2 GPA or return an error.

If kvm_translate_gpa() bypasses the nested translation (e.g., because
mmu_is_nested(vcpu) is false), the L2-provided hc->ingpa is returned
unchanged. 

Does this result in the untranslated L2 GPA being treated as an L1 GPA when
passed to kvm_read_guest(), potentially allowing the L2 guest to read
arbitrary L1 memory for hypercall parameters?

[Severity: High]
This is also a pre-existing issue, but when reading the hypercall input
data for slow Hyper-V hypercalls, does KVM fail to apply L2's nested EPT
(nEPT) mappings when the data crosses an L2 page boundary?

Later in the process, kvm_hv_get_hc_data() adds an offset to the translated
L1 base GPA:

arch/x86/kvm/hyperv.c:kvm_hv_get_hc_data() {
    ...
	return kvm_read_guest(kvm, hc->ingpa + hc->data_offset, data,
			      cnt * sizeof(*data));
}

Because kvm_read_guest() iterates contiguous L1 GFNs when crossing page
boundaries, if the hypercall input data straddles an L2 page boundary,
won't this ignore L2's EPT mappings for the subsequent pages and read
from unmapped, adjacent L1 physical memory?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260624214218.73796-1-pbonzini@redhat.com?part=1

  reply	other threads:[~2026-06-24 22:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 21:41 [PATCH v2 7.2-based 00/19] KVM: apply chainsaw to struct kvm_mmu Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 01/19] KVM: x86/hyperv: remove unnecessary mmu_is_nested() check Paolo Bonzini
2026-06-24 22:07   ` sashiko-bot [this message]
2026-06-24 21:42 ` [PATCH 7.2-based 02/19] KVM: x86/mmu: introduce struct kvm_pagewalk Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 03/19] KVM: x86/mmu: move get_guest_pgd to " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 04/19] KVM: x86/mmu: move gva_to_gpa " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 05/19] KVM: x86/mmu: move get_pdptr " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 06/19] KVM: x86/mmu: move inject_page_fault " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 07/19] KVM: x86/mmu: move CPU-related fields " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 08/19] KVM: x86/mmu: change CPU-role accessor fields to take " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 09/19] KVM: x86/mmu: move remaining permission fields to " Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 10/19] KVM: x86/mmu: pass struct kvm_pagewalk to kvm_mmu_invalidate_addr Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 11/19] KVM: x86/mmu: change walk_mmu to struct kvm_pagewalk Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 12/19] KVM: x86/mmu: change nested_mmu.w to ngva_walk Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 13/19] KVM: x86/mmu: pull struct kvm_pagewalk out of struct kvm_mmu Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 14/19] KVM: x86/mmu: unify root_gva_walk and ngva_walk Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 15/19] KVM: x86/mmu: cleanup functions that initialize shadow MMU Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 16/19] KVM: x86/mmu: pull page format to a new struct Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 17/19] KVM: x86/mmu: merge struct rsvd_bits_validate into struct kvm_page_format Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 18/19] KVM: x86/mmu: parameterize update_permission_bitmask() Paolo Bonzini
2026-06-24 21:42 ` [PATCH 7.2-based 19/19] KVM: x86/mmu: use kvm_page_format to test SPTEs Paolo Bonzini

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=20260624220718.2AAAD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@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 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.