提交 9c695d42 编写于 作者: A Alex Williamson 提交者: Marcelo Tosatti

KVM: Check userspace_addr when modifying a memory slot

The API documents that only flags and guest physical memory space can
be modified on an existing slot, but we don't enforce that the
userspace address cannot be modified.  Instead we just ignore it.
This means that a user may think they've successfully moved both the
guest and user addresses, when in fact only the guest address changed.
Check and error instead.
Reviewed-by: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
上级 f0736cf0
......@@ -784,13 +784,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
r = -ENOMEM;
/* Allocate if a slot is being created */
/*
* Allocate if a slot is being created. If modifying a slot,
* the userspace_addr cannot change.
*/
if (!old.npages) {
new.user_alloc = user_alloc;
new.userspace_addr = mem->userspace_addr;
if (kvm_arch_create_memslot(&new, npages))
goto out_free;
} else if (npages && mem->userspace_addr != old.userspace_addr) {
r = -EINVAL;
goto out_free;
}
/* Allocate page dirty bitmap if needed */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册