cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-fix-double-free-the-memslot-in-kvm_set_phys_mem.patch

0a122b
From dc37b3a1cd7c01dfccf9459a973694cee266957f Mon Sep 17 00:00:00 2001
0a122b
From: Laszlo Ersek <lersek@redhat.com>
0a122b
Date: Sat, 11 Jan 2014 17:59:59 +0100
0a122b
Subject: [PATCH 09/22] fix double free the memslot in kvm_set_phys_mem
0a122b
0a122b
RH-Author: Laszlo Ersek <lersek@redhat.com>
0a122b
Message-id: <1389463208-6278-10-git-send-email-lersek@redhat.com>
0a122b
Patchwork-id: 56622
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 09/18] fix double free the memslot in kvm_set_phys_mem
0a122b
Bugzilla: 1032346
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Andrew Jones <drjones@redhat.com>
0a122b
0a122b
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
0a122b
0a122b
Luiz Capitulino reported that guest refused to boot and qemu
0a122b
complained with:
0a122b
kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument
0a122b
0a122b
It is caused by commit 235e8982ad that did double free for the memslot
0a122b
so that the second one raises the -EINVAL error
0a122b
0a122b
Fix it by reset memory size only if it is needed
0a122b
0a122b
Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
0a122b
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
0a122b
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
0a122b
(cherry picked from commit 651eb0f41b793021f7de672de78892def5819fb9)
0a122b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
0a122b
---
0a122b
 kvm-all.c | 3 ++-
0a122b
 1 file changed, 2 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 kvm-all.c |    3 ++-
0a122b
 1 files changed, 2 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/kvm-all.c b/kvm-all.c
0a122b
index 42c71b9..16e4f65 100644
0a122b
--- a/kvm-all.c
0a122b
+++ b/kvm-all.c
0a122b
@@ -208,7 +208,8 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
0a122b
     if (s->migration_log) {
0a122b
         mem.flags |= KVM_MEM_LOG_DIRTY_PAGES;
0a122b
     }
0a122b
-    if (mem.flags & KVM_MEM_READONLY) {
0a122b
+
0a122b
+    if (slot->memory_size && mem.flags & KVM_MEM_READONLY) {
0a122b
         /* Set the slot size to 0 before setting the slot to the desired
0a122b
          * value. This is needed based on KVM commit 75d61fbc. */
0a122b
         mem.memory_size = 0;
0a122b
-- 
0a122b
1.7.1
0a122b