linux/arch/arm64/kvm/hyp
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
..
include Merge branch kvm-arm64/misc into kvmarm/next 2024-11-11 18:47:50 +00:00
nvhe KVM: arm64: Always check the state from hyp_ack_unshare() 2024-12-18 13:21:37 -08:00
vhe KVM: arm64: Add save/restore support for POR_EL2 2024-10-31 02:44:22 +00:00
aarch32.c KVM: arm64: AArch32: Fix spurious trapping of conditional instructions 2024-05-27 17:46:09 +01:00
entry.S KVM: arm64: Fix clobbered ELR in sync abort/SError 2024-06-20 17:40:53 +00:00
exception.c
fpsimd.S KVM: arm64: Reintroduce __sve_save_state 2024-06-04 15:06:32 +01:00
hyp-constants.c
hyp-entry.S KVM: arm64: Add missing BTI instructions 2023-07-12 22:15:36 +00:00
Makefile kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
pgtable.c KVM: arm64: Don't mark "struct page" accessed when making SPTE young 2024-10-25 13:01:35 -04:00
vgic-v2-cpuif-proxy.c
vgic-v3-sr.c KVM: arm64: Just advertise SEIS as 0 when emulating ICC_CTLR_EL1 2024-10-23 23:21:45 +00:00