[patch 008/108] KVM: Prevent overflow in largepages calculation

Greg KH
2009-07-01T00:49:01Z

[-- Attachment #1: kvm-prevent-overflow-in-largepages-calculation.patch --]
[-- Type: text/plain, Size: 800 bytes --]

2.6.30-stable review patch. If anyone has any objections, please let us know.

------------------

From: Avi Kivity <avi@redhat.com>

commit 09f8ca74ae6c2d78b2c7f6c0751ed0cbe815a3d9 upstream.

If userspace specifies a memory slot that is larger than 8 petabytes, it
could overflow the largepages variable.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
virt/kvm/kvm_main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -920,8 +920,7 @@ int __kvm_set_memory_region(struct 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;