diff options
author | Avi Kivity <avi@redhat.com> | 2009-10-04 16:45:13 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-10-04 17:04:16 +0200 |
commit | 6a54435560efdab1a08f429a954df4d6c740bddf (patch) | |
tree | f2141a331095cf2e7d3e1e5a14f2a7c264eaf923 | |
parent | eb5109e311b5152c0614a28d7d615d087f268f19 (diff) | |
download | linux-3.10-6a54435560efdab1a08f429a954df4d6c740bddf.tar.gz linux-3.10-6a54435560efdab1a08f429a954df4d6c740bddf.tar.bz2 linux-3.10-6a54435560efdab1a08f429a954df4d6c740bddf.zip |
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 <daw@cs.berkeley.edu>
Cc: stable@kernel.org
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index be451ee4424..9b9695322f5 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) |