KVM: Prevent overflow in largepages calculation
authorAvi Kivity <avi@redhat.com>
Mon, 8 Jun 2009 12:55:21 +0000 (15:55 +0300)
committerAvi Kivity <avi@redhat.com>
Wed, 10 Jun 2009 12:18:16 +0000 (15:18 +0300)
If userspace specifies a memory slot that is larger than 8 petabytes, it
could overflow the largepages variable.

Cc: stable@kernel.org
Signed-off-by: Avi Kivity <avi@redhat.com>
virt/kvm/kvm_main.c

index 5f865ed4c4318275af4b6e661f9bc49e750de540..e21194566b7140b423d9d438e433f737256681bb 100644 (file)
@@ -1087,8 +1087,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
        int r;
        gfn_t base_gfn;
        unsigned long npages, ugfn;
-       int largepages;
-       unsigned long i;
+       unsigned long largepages, i;
        struct kvm_memory_slot *memslot;
        struct kvm_memory_slot old, new;