Skip to content

Commit

Permalink
KVM: Add build-time error check on kvm_run size
Browse files Browse the repository at this point in the history
It's already going to reach 2400 Bytes (which is over half of page
size on 4K page archs), so maybe it's good to have this build-time
check in case it overflows when adding new fields.

Signed-off-by: Peter Xu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
xzpeter authored and bonzini committed Jan 27, 2020
1 parent ef82edd commit fcd97ad
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
goto vcpu_decrement;
}

BUILD_BUG_ON(sizeof(struct kvm_run) > PAGE_SIZE);
page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!page) {
r = -ENOMEM;
Expand Down

0 comments on commit fcd97ad

Please sign in to comment.