diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-03-08 10:49:37 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-03-08 15:30:57 +0100 |
commit | 37b2a6510a48ca361ced679f92682b7b7d7d0330 (patch) | |
tree | fb2d48b31b583fff946d7472ecfb8d89ad70f7fe /virt | |
parent | mm: use vmalloc_array and vcalloc for array allocations (diff) | |
download | linux-37b2a6510a48ca361ced679f92682b7b7d7d0330.tar.xz linux-37b2a6510a48ca361ced679f92682b7b7d7d0330.zip |
KVM: use __vcalloc for very large allocations
Allocations whose size is related to the memslot size can be arbitrarily
large. Do not use kvzalloc/kvcalloc, as those are limited to "not crazy"
sizes that fit in 32 bits.
Cc: stable@vger.kernel.org
Fixes: 7661809d493b ("mm: don't allow oversized kvmalloc() calls")
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c941b97fa133..69c318fdff61 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1274,9 +1274,9 @@ static int kvm_vm_release(struct inode *inode, struct file *filp) */ static int kvm_alloc_dirty_bitmap(struct kvm_memory_slot *memslot) { - unsigned long dirty_bytes = 2 * kvm_dirty_bitmap_bytes(memslot); + unsigned long dirty_bytes = kvm_dirty_bitmap_bytes(memslot); - memslot->dirty_bitmap = kvzalloc(dirty_bytes, GFP_KERNEL_ACCOUNT); + memslot->dirty_bitmap = __vcalloc(2, dirty_bytes, GFP_KERNEL_ACCOUNT); if (!memslot->dirty_bitmap) return -ENOMEM; |