* [PATCH] KVM: VMX: Add array_index_nospec() to evmcs_field_offset()
@ 2026-10-17 9:30 Amirmohammad Eftekhar
0 siblings, 0 replies; only message in thread
From: Amirmohammad Eftekhar @ 2026-10-17 9:30 UTC (permalink / raw)
To: seanjc, pbonzini; +Cc: kvm, linux-kernel
evmcs_field_offset() bounds-checks the guest-supplied field index against
nr_evmcs_1_fields and then indexes vmcs_field_to_evmcs_1[] without an
array_index_nospec() clamp, unlike its vmcs12 counterpart
get_vmcs12_field_offset(). An enlightened VMREAD/VMWRITE from the guest
can therefore speculatively read out of bounds of vmcs_field_to_evmcs_1[]
past the bound check (Spectre v1).
Clamp the index with array_index_nospec(), mirroring
get_vmcs12_field_offset().
Signed-off-by: Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>
---
arch/x86/kvm/vmx/hyperv_evmcs.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kvm/vmx/hyperv_evmcs.h b/arch/x86/kvm/vmx/hyperv_evmcs.h
index bc08fe405..052b62b8e 100644
--- a/arch/x86/kvm/vmx/hyperv_evmcs.h
+++ b/arch/x86/kvm/vmx/hyperv_evmcs.h
@@ -136,6 +136,8 @@ static __always_inline int evmcs_field_offset(unsigned long field,
if (unlikely(index >= nr_evmcs_1_fields))
return -ENOENT;
+ index = array_index_nospec(index, nr_evmcs_1_fields);
+
evmcs_field = &vmcs_field_to_evmcs_1[index];
/*
--
2.54.0 (Apple Git-157)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-17 9:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-17 9:30 [PATCH] KVM: VMX: Add array_index_nospec() to evmcs_field_offset() Amirmohammad Eftekhar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®