]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
KVM: x86: Catch potential overrun in MCE setup
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 23 Oct 2009 07:37:00 +0000 (09:37 +0200)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 4 Nov 2009 14:42:35 +0000 (12:42 -0200)
We only allocate memory for 32 MCE banks (KVM_MAX_MCE_BANKS) but we
allow user space to fill up to 255 on setup (mcg_cap & 0xff), corrupting
kernel memory. Catch these overflows.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/x86.c

index 9b9695322f567875169c4d934e4100cb266e5d52..8a93fa894ba65ae66905d6c1209b69c1ecad2500 100644 (file)
@@ -1692,7 +1692,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
        unsigned bank_num = mcg_cap & 0xff, bank;
 
        r = -EINVAL;
-       if (!bank_num)
+       if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS)
                goto out;
        if (mcg_cap & ~(KVM_MCE_CAP_SUPPORTED | 0xff | 0xff0000))
                goto out;