KVM: Improve create VCPU parameter (CVE-2013-4587)
[pandora-kernel.git] / virt / kvm / kvm_main.c
index 8bf05f0..bfa8e1e 100644 (file)
@@ -1683,6 +1683,9 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
        int r;
        struct kvm_vcpu *vcpu, *v;
 
+       if (id >= KVM_MAX_VCPUS)
+               return -EINVAL;
+
        vcpu = kvm_arch_vcpu_create(kvm, id);
        if (IS_ERR(vcpu))
                return PTR_ERR(vcpu);