From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: "Marc Zyngier" <maz@kernel.org>,
kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v1 11/11] KVM: arm64: Tag host-VA hypercall parameters __hostva
Date: Mon, 20 Jul 2026 17:55:13 +0000 [thread overview]
Message-ID: <20260720175513.8D4DF1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720162412.1401272-2-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] `kern_hyp_va_host()` macro fails to strip the `__hostva` address space tag for Sparse.
Pre-existing issues:
- [Critical] Missing host pointer ownership validation in always-on hypercalls allows a malicious host to corrupt EL2-private memory (Confused Deputy).
--
--- Patch [11]: [PATCH v1 11/11] KVM: arm64: Tag host-VA hypercall parameters __hostva ---
commit 4acf0dff6116caffddce5517211ac9136d9b0ee1
Author: Fuad Tabba <fuad.tabba@linux.dev>
KVM: arm64: Tag host-VA hypercall parameters __hostva
This commit introduces the __hostva sparse address space to tag host virtual
addresses passed as hypercall arguments in the nVHE hypervisor. It adds
kern_hyp_va_host() to explicitly unwrap and translate these tagged pointers,
ensuring that untranslated host VAs are caught by sparse checks.
> diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
> --- a/arch/arm64/include/asm/kvm_mmu.h
> +++ b/arch/arm64/include/asm/kvm_mmu.h
[ ... ]
> @@ -140,6 +142,14 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v)
>
> #define kern_hyp_va(v) ((typeof(v))(__kern_hyp_va((unsigned long)(v))))
>
> +/*
> + * Translate a __hostva-tagged host VA, dropping the tag: the only sanctioned
> + * unwrap. Translation only, no ownership or bounds validation; the result
> + * carries the pointee type stripped of the tag and of any cv-qualifiers.
> + */
> +#define kern_hyp_va_host(v) \
> + ((TYPEOF_UNQUAL(*(v)) *)__kern_hyp_va((unsigned long)(__force void *)(v)))
[Severity: Medium]
Does TYPEOF_UNQUAL() actually strip the address space tag in Sparse?
Sparse treats address spaces as type qualifiers that typeof_unqual (and
by extension TYPEOF_UNQUAL) does not remove, unlike const or volatile.
Consequently, this cast evaluates to a pointer that still carries the
__hostva tag.
When assigned to a regular kernel pointer, this will trigger incorrect type
in assignment (different address spaces) false positive warnings across the
codebase when running make C=2.
Should this use an explicit cast to __kernel (address_space(0)) to
correctly strip the tag, similar to how per_cpu_ptr handles __percpu?
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
[ ... ]
> @@ -421,9 +421,9 @@ DEFINE_KVM_HOST_HCALL(int, __pkvm_host_mkyoung_guest, 1,
> }
>
> DEFINE_KVM_HOST_HCALL_VOID(__kvm_adjust_pc, 1,
> - struct kvm_vcpu *, vcpu)
> + struct kvm_vcpu __hostva *, vcpu)
> {
> - __kvm_adjust_pc(kern_hyp_va(vcpu));
> + __kvm_adjust_pc(kern_hyp_va_host(vcpu));
> }
[Severity: Critical]
This is a pre-existing issue, but does this lack of ownership validation
allow the host to corrupt EL2-private memory?
Under pKVM, the host is treated as an adversary. If the host provides a
TTBR1 virtual address that maps to an EL2-private physical address,
kern_hyp_va_host() will translate it into a valid EL2 linear map pointer
without verifying ownership.
The hypervisor will then write into EL2-private memory when modifying
flags in __kvm_adjust_pc() or hardware register state in
__vgic_v3_save_aprs(), corrupting its own state or the state of
protected guests.
Should there be an explicit ownership check before dereferencing
pointers from these always-on hypercalls?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720162412.1401272-1-fuad.tabba@linux.dev?part=11
next prev parent reply other threads:[~2026-07-20 17:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 16:13 [PATCH v1 00/11] KVM: arm64: Restore type-checking across the host/hyp hypercall boundary Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 01/11] tracing: Include linux/types.h in trace_remote_event.h Fuad Tabba
2026-07-20 18:32 ` Steven Rostedt
2026-07-20 16:13 ` [PATCH v1 02/11] KVM: arm64: nVHE: Share the stacktrace per-CPU declarations with EL2 Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 03/11] KVM: arm64: nVHE: Declare the hyp event IDs before defining them Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 04/11] KVM: arm64: nVHE: Use NULL to reset the trace buffer backing pointer Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 05/11] KVM: arm64: nVHE: Run the source checker under C=2 Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 06/11] arm64: pi: Run the source checker on the libfdt objects " Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 07/11] KVM: arm64: nVHE: Pass host VA arguments as pointers Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 08/11] KVM: arm64: Move the host hypercall interface to its own header Fuad Tabba
2026-07-20 16:13 ` [PATCH v1 09/11] KVM: arm64: Type-check hypercall arguments at the caller Fuad Tabba
2026-07-20 17:29 ` sashiko-bot
2026-07-20 17:59 ` Fuad Tabba
2026-07-20 16:24 ` [PATCH v1 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI Fuad Tabba
2026-07-20 16:24 ` [PATCH v1 11/11] KVM: arm64: Tag host-VA hypercall parameters __hostva Fuad Tabba
2026-07-20 17:55 ` sashiko-bot [this message]
2026-07-20 18:24 ` Fuad Tabba
2026-07-20 17:42 ` [PATCH v1 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI sashiko-bot
2026-07-20 18:01 ` Fuad Tabba
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=20260720175513.8D4DF1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fuad.tabba@linux.dev \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@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.