Skip to content

Commit f3310e6

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Initialize kvm_page_fault's pfn and hva to error values
Explicitly set "pfn" and "hva" to error values in kvm_mmu_do_page_fault() to harden KVM against using "uninitialized" values. In quotes because the fields are actually zero-initialized, and zero is a legal value for both page frame numbers and virtual addresses. E.g. failure to set "pfn" prior to creating an SPTE could result in KVM pointing at physical address '0', which is far less desirable than KVM generating a SPTE with reserved PA bits set and thus effectively killing the VM. Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Kai Huang <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 36d4492 commit f3310e6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kvm/mmu/mmu_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
307307
.req_level = PG_LEVEL_4K,
308308
.goal_level = PG_LEVEL_4K,
309309
.is_private = err & PFERR_PRIVATE_ACCESS,
310+
311+
.pfn = KVM_PFN_ERR_FAULT,
312+
.hva = KVM_HVA_ERR_BAD,
310313
};
311314
int r;
312315

0 commit comments

Comments
 (0)