From: Avi Kivity Date: Sun, 4 Oct 2009 14:45:13 +0000 (+0200) Subject: KVM: Prevent overflow in KVM_GET_SUPPORTED_CPUID X-Git-Tag: v2.6.32-rc4~55^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a54435560efdab1a08f429a954df4d6c740bddf;p=platform%2Fkernel%2Flinux-stable.git KVM: Prevent overflow in KVM_GET_SUPPORTED_CPUID The number of entries is multiplied by the entry size, which can overflow on 32-bit hosts. Bound the entry count instead. Reported-by: David Wagner Cc: stable@kernel.org Signed-off-by: Avi Kivity --- diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index be451ee..9b96953 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1591,6 +1591,8 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, if (cpuid->nent < 1) goto out; + if (cpuid->nent > KVM_MAX_CPUID_ENTRIES) + cpuid->nent = KVM_MAX_CPUID_ENTRIES; r = -ENOMEM; cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry2) * cpuid->nent); if (!cpuid_entries)