Skip to content

KVM: arm64: Validate host pointers in __kvm_adjust_pc() under pKVM

Fuad Tabba kvmarm linux-arm-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 7 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: Validate the host vCPU's VM before reading it under pKVMarch/arm64/kvm/hyp/exception.c arch/arm64/kvm/hyp/include/hyp/adjust_pc.h arch/arm64/kvm/hyp/nvhe/pkvm.c+61 -14 replies
2/2KVM: arm64: Pin the host vCPU before adjusting its PC under pKVMarch/arm64/kvm/hyp/nvhe/hyp-main.c+18 -13 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchVincent DonnefortJoey Gouly
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] KVM: arm64: Validate host pointers in __kvm_adjust_pc() under pKVM

Hi folks,

Changes since v1 [1]:
- New patch 1: enter_exception64() reads the VM's MTE flag through a host-writable vcpu->kvm that nothing validates. It goes first, since pinning the vCPU alone leaves that read on an unmapped VM. (sashiko)
- Dropped the VM pin the fix carried in v1, patch 1 validating that read at its site.

Two host pointers reach EL2 unvalidated on the __kvm_adjust_pc() path under pKVM, and this series fixes both. The host vCPU isn't mapped at EL2 until its first KVM_RUN pins it, and KVM_SET_VCPU_EVENTS with ext_dabt_pending reaches the hypercall before that. The vcpu->kvm the exception entry reads the MTE flag from is host-writable, and nothing checks it. Either one panics the hypervisor, and on MTE-capable hardware the flag read leaks one bit of hyp memory the host chose, through PSR_TCO.

These are patches 2 and 3 of the pKVM core series [2], which carries them so that it applies as is. They're respun here so they can be applied on their own.

Based on v7.3-rc3 (fd73f4a665989).

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (2):
KVM: arm64: Validate the host vCPU's VM before reading it under pKVM
KVM: arm64: Pin the host vCPU before adjusting its PC under pKVM

 arch/arm64/kvm/hyp/exception.c             |  5 ++-
 arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 18 ++++++++++
 arch/arm64/kvm/hyp/nvhe/hyp-main.c         | 19 ++++++++++-
 arch/arm64/kvm/hyp/nvhe/pkvm.c             | 39 ++++++++++++++++++++++
 4 files changed, 79 insertions(+), 2 deletions(-)

base-commit: fd73f4a6659897191fa0d40695fe370925dd3780

Signature · 1 line
2.39.5