aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2012-08-20 22:58:13 -0400
committerAvi Kivity <avi@redhat.com>2012-08-22 08:08:50 -0400
commita50d64d6590f470b712758598a077ef4fd0fc40a (patch)
tree4e673d5f51e95e00c218abec66f8cccb9fa8664b /virt/kvm/kvm_main.c
parent8e3d9d061b5d132217629e7b5635ff0c02488e65 (diff)
KVM: fix missing check for memslot flags
Check flags when memslot is registered from userspace as Avi's suggestion Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a2e85af847c1..7b94d70a323f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -678,6 +678,14 @@ void update_memslots(struct kvm_memslots *slots, struct kvm_memory_slot *new)
678 slots->generation++; 678 slots->generation++;
679} 679}
680 680
681static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
682{
683 if (mem->flags & ~KVM_MEM_LOG_DIRTY_PAGES)
684 return -EINVAL;
685
686 return 0;
687}
688
681/* 689/*
682 * Allocate some memory and give it an address in the guest physical address 690 * Allocate some memory and give it an address in the guest physical address
683 * space. 691 * space.
@@ -698,6 +706,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
698 struct kvm_memory_slot old, new; 706 struct kvm_memory_slot old, new;
699 struct kvm_memslots *slots, *old_memslots; 707 struct kvm_memslots *slots, *old_memslots;
700 708
709 r = check_memory_region_flags(mem);
710 if (r)
711 goto out;
712
701 r = -EINVAL; 713 r = -EINVAL;
702 /* General sanity checks */ 714 /* General sanity checks */
703 if (mem->memory_size & (PAGE_SIZE - 1)) 715 if (mem->memory_size & (PAGE_SIZE - 1))