qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] savevm: fix corruption in vmstate_subsection_load().
@ 2010-12-14  9:07 Yoshiaki Tamura
  2011-01-20  2:09 ` Yoshiaki Tamura
  2011-01-20  8:27 ` [Qemu-devel] " Paolo Bonzini
  0 siblings, 2 replies; 7+ messages in thread
From: Yoshiaki Tamura @ 2010-12-14  9:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Yoshiaki Tamura, quintela

Although it's rare to happen in live migration, when the head of a
byte stream contains 0x05 which is the marker of subsection, the
loader gets corrupted because vmstate_subsection_load() continues even
the device doesn't require it.  This patch adds a checker whether
subsection is needed, and skips following routines if not needed.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
---
 savevm.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/savevm.c b/savevm.c
index d38f79e..72f6249 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1633,6 +1633,12 @@ static const VMStateDescription *vmstate_get_subsection(const VMStateSubsection
 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
                                    void *opaque)
 {
+    const VMStateSubsection *sub = vmsd->subsections;
+
+    if (!sub || !sub->needed) {
+        return 0;
+    }
+
     while (qemu_peek_byte(f) == QEMU_VM_SUBSECTION) {
         char idstr[256];
         int ret;
@@ -1645,7 +1651,7 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
         idstr[len] = 0;
         version_id = qemu_get_be32(f);
 
-        sub_vmsd = vmstate_get_subsection(vmsd->subsections, idstr);
+        sub_vmsd = vmstate_get_subsection(sub, idstr);
         if (sub_vmsd == NULL) {
             return -ENOENT;
         }
-- 
1.7.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-24  8:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14  9:07 [Qemu-devel] [PATCH] savevm: fix corruption in vmstate_subsection_load() Yoshiaki Tamura
2011-01-20  2:09 ` Yoshiaki Tamura
2011-01-20  8:27 ` [Qemu-devel] " Paolo Bonzini
2011-01-20  8:57   ` Yoshiaki Tamura
2011-01-20  9:06     ` Paolo Bonzini
2011-01-20 10:23       ` Yoshiaki Tamura
2011-01-24  8:48         ` Yoshiaki Tamura

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).