* [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load().
@ 2011-01-24 9:30 Yoshiaki Tamura
2011-01-24 15:35 ` [Qemu-devel] " Paolo Bonzini
2011-06-09 12:48 ` [Qemu-devel] " Kevin Wolf
0 siblings, 2 replies; 4+ messages in thread
From: Yoshiaki Tamura @ 2011-01-24 9:30 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, 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 | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/savevm.c b/savevm.c
index fcd8db4..3be875d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1639,6 +1639,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;
@@ -1651,10 +1657,11 @@ 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;
}
+ assert(!sub_vmsd->subsections);
ret = vmstate_load_state(f, sub_vmsd, opaque, version_id);
if (ret) {
return ret;
@@ -1678,6 +1685,7 @@ static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
qemu_put_byte(f, len);
qemu_put_buffer(f, (uint8_t *)vmsd->name, len);
qemu_put_be32(f, vmsd->version_id);
+ assert(!vmsd->subsections);
vmstate_save_state(f, vmsd, opaque);
}
sub++;
--
1.7.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH v2] savevm: fix corruption in vmstate_subsection_load().
2011-01-24 9:30 [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load() Yoshiaki Tamura
@ 2011-01-24 15:35 ` Paolo Bonzini
2011-06-09 12:48 ` [Qemu-devel] " Kevin Wolf
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-01-24 15:35 UTC (permalink / raw)
To: Yoshiaki Tamura; +Cc: aliguori, qemu-devel, quintela
On 01/24/2011 10:30 AM, Yoshiaki Tamura wrote:
> 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>
VMS_STRUCT is a can of worms, since almost all uses of subsections _are_
VMS_STRUCTs. So almost all uses of subsections have ambiguous parsing. :/
So, for now,
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load().
2011-01-24 9:30 [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load() Yoshiaki Tamura
2011-01-24 15:35 ` [Qemu-devel] " Paolo Bonzini
@ 2011-06-09 12:48 ` Kevin Wolf
2011-06-09 13:19 ` Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2011-06-09 12:48 UTC (permalink / raw)
To: Yoshiaki Tamura; +Cc: pbonzini, aliguori, qemu-devel, quintela
Am 24.01.2011 10:30, schrieb Yoshiaki Tamura:
> 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 | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/savevm.c b/savevm.c
> index fcd8db4..3be875d 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1639,6 +1639,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;
> + }
This means that subsections are silently ignored if the old version
didn't have any subsection for the device. Wasn't it a fundamental point
of the design of subsections that this would fail?
Noticed this when trying to use subsections to fix up IDE, and new ->
old migration after an I/O error only correctly fails when I revert this
patch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load().
2011-06-09 12:48 ` [Qemu-devel] " Kevin Wolf
@ 2011-06-09 13:19 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-06-09 13:19 UTC (permalink / raw)
To: Kevin Wolf; +Cc: aliguori, quintela, Yoshiaki Tamura, qemu-devel
On 06/09/2011 02:48 PM, Kevin Wolf wrote:
> This means that subsections are silently ignored if the old version
> didn't have any subsection for the device. Wasn't it a fundamental point
> of the design of subsections that this would fail?
Unfortunately you cannot have it both ways because the migration format
is ambiguous.
> Noticed this when trying to use subsections to fix up IDE, and new ->
> old migration after an I/O error only correctly fails when I revert this
> patch.
I would have expected migration to fail anyway because the next
instances are not parsed correctly.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-09 13:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 9:30 [Qemu-devel] [PATCH v2] savevm: fix corruption in vmstate_subsection_load() Yoshiaki Tamura
2011-01-24 15:35 ` [Qemu-devel] " Paolo Bonzini
2011-06-09 12:48 ` [Qemu-devel] " Kevin Wolf
2011-06-09 13:19 ` Paolo Bonzini
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).