linux/arch/arm64/kvm/hyp/nvhe
Quentin Perret 985bb51f17 KVM: arm64: Always check the state from hyp_ack_unshare()
There are multiple pKVM memory transitions where the state of a page is
not cross-checked from the completer's PoV for performance reasons.
For example, if a page is PKVM_PAGE_OWNED from the initiator's PoV,
we should be guaranteed by construction that it is PKVM_NOPAGE for
everybody else, hence allowing us to save a page-table lookup.

When it was introduced, hyp_ack_unshare() followed that logic and bailed
out without checking the PKVM_PAGE_SHARED_BORROWED state in the
hypervisor's stage-1. This was correct as we could safely assume that
all host-initiated shares were directed at the hypervisor at the time.
But with the introduction of other types of shares (e.g. for FF-A or
non-protected guests), it is now very much required to cross check this
state to prevent the host from running __pkvm_host_unshare_hyp() on a
page shared with TZ or a non-protected guest.

Thankfully, if an attacker were to try this, the hyp_unmap() call from
hyp_complete_unshare() would fail, hence causing to WARN() from
__do_unshare() with the host lock held, which is fatal. But this is
fragile at best, and can hardly be considered a security measure.

Let's just do the right thing and always check the state from
hyp_ack_unshare().

Signed-off-by: Quentin Perret <qperret@google.com>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20241128154406.602875-1-qperret@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
2024-12-18 13:21:37 -08:00
..
.gitignore
cache.S
debug-sr.c
early_alloc.c
ffa.c KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer 2024-09-10 21:05:29 +01:00
gen-hyprel.c KVM: arm64: nVHE: gen-hyprel: Skip R_AARCH64_ABS32 2024-06-20 17:40:54 +00:00
host.S
hyp-init.S KVM: arm64: Shave a few bytes from the EL2 idmap code 2024-10-17 09:17:56 +01:00
hyp-main.c KVM: arm64: Initialize trap register values in hyp in pKVM 2024-10-31 18:45:24 +00:00
hyp-smp.c
hyp.lds.S
list_debug.c
Makefile KVM: arm64: fix override-init warnings in W=1 builds 2024-08-02 18:58:03 +00:00
mem_protect.c KVM: arm64: Always check the state from hyp_ack_unshare() 2024-12-18 13:21:37 -08:00
mm.c
page_alloc.c
pkvm.c arm64: Fix usage of new shifted MDCR_EL2 values 2024-11-26 06:31:36 -08:00
psci-relay.c KVM: arm64: nvhe: Pass through PSCI v1.3 SYSTEM_OFF2 call 2024-10-24 16:49:09 -07:00
setup.c KVM: arm64: Pass on SVE mapping failures 2024-11-12 11:04:39 -08:00
stacktrace.c
switch.c Merge branch kvm-arm64/fpmr into kvmarm-master/next 2024-09-12 08:36:41 +01:00
sys_regs.c KVM: arm64: Replace custom macros with fields from ID_AA64PFR0_EL1 2024-07-04 12:21:12 +01:00
sysreg-sr.c KVM: arm64: nv: Save/Restore vEL2 sysregs 2024-10-31 02:42:30 +00:00
timer-sr.c
tlb.c KVM: arm64: Ensure TLBI uses correct VMID after changing context 2024-08-15 14:05:02 +01:00