From: Xiao Guangrong Date: Tue, 21 Aug 2012 02:58:13 +0000 (+0800) Subject: KVM: fix missing check for memslot flags X-Git-Tag: v3.7-rc1~113^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a50d64d6590f470b712758598a077ef4fd0fc40a;p=profile%2Fivi%2Fkernel-x86-ivi.git KVM: fix missing check for memslot flags Check flags when memslot is registered from userspace as Avi's suggestion Signed-off-by: Xiao Guangrong Signed-off-by: Avi Kivity --- diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a2e85af..7b94d70 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) slots->generation++; } +static int check_memory_region_flags(struct kvm_userspace_memory_region *mem) +{ + if (mem->flags & ~KVM_MEM_LOG_DIRTY_PAGES) + return -EINVAL; + + return 0; +} + /* * Allocate some memory and give it an address in the guest physical address * space. @@ -698,6 +706,10 @@ int __kvm_set_memory_region(struct kvm *kvm, struct kvm_memory_slot old, new; struct kvm_memslots *slots, *old_memslots; + r = check_memory_region_flags(mem); + if (r) + goto out; + r = -EINVAL; /* General sanity checks */ if (mem->memory_size & (PAGE_SIZE - 1))