Skip to content

Commit d650014

Browse files
Yu Zhangrkrcmar
authored andcommitted
KVM: x86: Fix the NULL pointer parameter in check_cr_write()
Routine check_cr_write() will trigger emulator_get_cpuid()-> kvm_cpuid() to get maxphyaddr, and NULL is passed as values for ebx/ecx/edx. This is problematic because kvm_cpuid() will dereference these pointers. Fixes: d1cd3ce ("KVM: MMU: check guest CR3 reserved bits based on its physical address width.") Reported-by: Jim Mattson <[email protected]> Signed-off-by: Yu Zhang <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Signed-off-by: Radim Krčmář <[email protected]>
1 parent 95e2a3b commit d650014

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/kvm/emulate.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,10 +4102,12 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
41024102
ctxt->ops->get_msr(ctxt, MSR_EFER, &efer);
41034103
if (efer & EFER_LMA) {
41044104
u64 maxphyaddr;
4105-
u32 eax = 0x80000008;
4105+
u32 eax, ebx, ecx, edx;
41064106

4107-
if (ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL,
4108-
NULL, false))
4107+
eax = 0x80000008;
4108+
ecx = 0;
4109+
if (ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx,
4110+
&edx, false))
41094111
maxphyaddr = eax & 0xff;
41104112
else
41114113
maxphyaddr = 36;

0 commit comments

Comments
 (0)