From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: "Oliver Upton" <oupton@kernel.org>,
kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v7 6/8] KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch
Date: Wed, 29 Jul 2026 13:39:29 +0000 [thread overview]
Message-ID: <20260729133929.CFE191F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260729131823.2021516-7-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The patch fixes an arbitrary host pointer dereference in GICv3 hypercalls but completely misses the identical vulnerabilities in GICv5 hypercalls (`handle___vgic_v5_save_apr` and `handle___vgic_v5_restore_vmcr_apr`).
- [Critical] Unvalidated host pointer dereference in `handle___kvm_adjust_pc` allows arbitrary memory modification in EL2.
--
--- Patch [6]: [PATCH v7 6/8] KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch ---
commit def324be61872b6056efce4e3eb9ff57eb9a9e10
Author: Marc Zyngier <maz@kernel.org>
Subject: KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch
This commit restricts EL2's exposure to host VGIC state by recovering the
host vCPU securely rather than directly dereferencing the host-provided
vgic_v3_cpu_if pointer in __vgic_v3_save_aprs and
__vgic_v3_restore_vmcr_aprs. It introduces a helper to fetch the host
vCPU using container_of() and copies only the necessary state.
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 45d717889f6ea..f3233ee343a39 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
[ ... ]
> @@ -508,16 +520,63 @@ static void handle___vgic_v3_save_aprs(struct kvm_cpu_context *host_ctxt)
> {
> - DECLARE_REG(struct vgic_v3_cpu_if *, cpu_if, host_ctxt, 1);
> + struct pkvm_hyp_vcpu *hyp_vcpu;
> + struct kvm_vcpu *host_vcpu;
>
> - __vgic_v3_save_aprs(kern_hyp_va(cpu_if));
> + host_vcpu = get_host_hyp_vcpus_from_vgic_v3_cpu_if(host_ctxt, 1,
> + &hyp_vcpu);
[ ... ]
[Severity: Critical]
This is a pre-existing issue, but does the same regression exist for the
GICv5 hypercalls?
The patch replaces the direct kern_hyp_va() dereference with a secure lookup
for GICv3. However, it appears the same pattern remains in
handle___vgic_v5_save_apr() and handle___vgic_v5_restore_vmcr_apr():
handle___vgic_v5_save_apr()
__vgic_v5_save_apr(kern_hyp_va(cpu_if));
Can a compromised host pass an arbitrary physical address here, causing
__vgic_v5_save_apr() to write the hardware value of SYS_ICH_APR_EL2 to that
chosen address, breaking EL2 isolation?
[Severity: Critical]
This is also a pre-existing issue, but does handle___kvm_adjust_pc() have a
similar unvalidated host pointer dereference?
In arch/arm64/kvm/hyp/nvhe/hyp-main.c:
static void handle___kvm_adjust_pc(struct kvm_cpu_context *host_ctxt)
{
DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1);
__kvm_adjust_pc(kern_hyp_va(vcpu));
}
If the host kernel passes a crafted vcpu pointer, could it point to an
arbitrary memory region where the iflags offset has the INCREMENT_PC bit set?
This would cause the hypervisor to execute:
arch/arm64/kvm/hyp/exception.c:__kvm_adjust_pc() {
...
} else if (vcpu_get_flag(vcpu, INCREMENT_PC)) {
kvm_skip_instr(vcpu);
...
}
Could this allow an attacker to increment arbitrary EL2 memory by adding 4 to
the value at the regs.pc offset?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729131823.2021516-1-fuad.tabba@linux.dev?part=6
next prev parent reply other threads:[~2026-07-29 13:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 13:18 [PATCH v7 0/8] KVM: arm64: pKVM vCPU state management at EL2 Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 1/8] KVM: arm64: Extract MPIDR computation into a shared header Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 2/8] KVM: arm64: Make vcpu_{read,write}_sys_reg available to HYP code Fuad Tabba
2026-07-29 13:34 ` sashiko-bot
2026-07-29 13:40 ` Fuad Tabba
2026-07-29 13:52 ` Joey Gouly
2026-07-29 14:51 ` Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 3/8] KVM: arm64: Factor out reusable vCPU reset helpers Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 4/8] KVM: arm64: Move PSCI helper functions to a shared header Fuad Tabba
2026-07-29 13:31 ` sashiko-bot
2026-07-29 13:33 ` Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 5/8] KVM: arm64: Add host and hypervisor vCPU lookup primitives Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 6/8] KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch Fuad Tabba
2026-07-29 13:39 ` sashiko-bot [this message]
2026-07-29 13:44 ` Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 7/8] KVM: arm64: Add primitives to flush/sync the VGIC state at EL2 Fuad Tabba
2026-07-29 13:18 ` [PATCH v7 8/8] KVM: arm64: Implement lazy vCPU state sync for non-protected guests Fuad Tabba
2026-07-29 13:36 ` sashiko-bot
2026-07-29 13:46 ` Fuad Tabba
2026-07-31 18:51 ` [PATCH v7 0/8] KVM: arm64: pKVM vCPU state management at EL2 Oliver Upton
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=20260729133929.CFE191F00A3D@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox