arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized
authorChristoffer Dall <christoffer.dall@linaro.org>
Tue, 9 Dec 2014 13:33:45 +0000 (14:33 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Sat, 13 Dec 2014 13:17:10 +0000 (14:17 +0100)
When the vgic initializes its internal state it does so based on the
number of VCPUs available at the time.  If we allow KVM to create more
VCPUs after the VGIC has been initialized, we are likely to error out in
unfortunate ways later, perform buffer overflows etc.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/kvm/arm.c

index c5a05f2c28ac07efecd24d15acba62f657889f1d..66f37c4cdf1376cb3f1c826d0032e69607f0488a 100644 (file)
@@ -213,6 +213,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
        int err;
        struct kvm_vcpu *vcpu;
 
+       if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) {
+               err = -EBUSY;
+               goto out;
+       }
+
        vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
        if (!vcpu) {
                err = -ENOMEM;
This page took 0.027341 seconds and 5 git commands to generate.