lkml.org 
[lkml]   [2012]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH v2 02/10] kvm: Check userspace_addr when modifying a memory slot
From
Date
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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
virt/kvm/kvm_main.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e426704..6e9d3f9 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -779,13 +779,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 */


\
 
 \ /
  Last update: 2012-12-10 19:01    [W:0.073 / U:2.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site