Skip to content

Commit 433f4ba

Browse files
committed
KVM: x86: fix out-of-bounds write in KVM_GET_EMULATED_CPUID (CVE-2019-19332)
The bounds check was present in KVM_GET_SUPPORTED_CPUID but not KVM_GET_EMULATED_CPUID. Reported-by: [email protected] Fixes: 84cffe4 ("kvm: Emulate MOVBE", 2013-10-29) Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 3525d0c commit 433f4ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
504504

505505
r = -E2BIG;
506506

507-
if (*nent >= maxnent)
507+
if (WARN_ON(*nent >= maxnent))
508508
goto out;
509509

510510
do_host_cpuid(entry, function, 0);
@@ -815,6 +815,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
815815
static int do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 func,
816816
int *nent, int maxnent, unsigned int type)
817817
{
818+
if (*nent >= maxnent)
819+
return -E2BIG;
820+
818821
if (type == KVM_GET_EMULATED_CPUID)
819822
return __do_cpuid_func_emulated(entry, func, nent, maxnent);
820823

0 commit comments

Comments
 (0)