[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 068/156] migration: catch unknown flags in ram_load
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 068/156] migration: catch unknown flags in ram_load |
Date: |
Tue, 8 Jul 2014 12:17:39 -0500 |
From: Peter Lieven <address@hidden>
if a saved vm has unknown flags in the memory data qemu
currently simply ignores this flag and continues which
yields in an unpredictable result.
This patch catches all unknown flags and aborts the
loading of the vm. Additionally error reports are thrown
if the migration aborts abnormally.
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
(cherry picked from commit db80facefa62dff42bb50c73b0f03eda5f732b49)
Conflicts:
arch_init.c
*removed unecessary context from 4798fe55
Signed-off-by: Michael Roth <address@hidden>
---
arch_init.c | 32 +++++++++++++++++---------------
migration.c | 2 +-
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 85652aa..8038937 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -857,7 +857,6 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
{
ram_addr_t addr;
int flags, ret = 0;
- int error;
static uint64_t seq_iter;
seq_iter++;
@@ -866,7 +865,7 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
return -EINVAL;
}
- do {
+ while (!ret) {
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
@@ -895,7 +894,6 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
" in != " RAM_ADDR_FMT "\n", id, length,
block->length);
ret = -EINVAL;
- goto done;
}
break;
}
@@ -905,14 +903,14 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
fprintf(stderr, "Unknown ramblock \"%s\", cannot "
"accept migration\n", id);
ret = -EINVAL;
- goto done;
+ }
+ if (ret) {
+ break;
}
total_ram_bytes -= length;
}
- }
-
- if (flags & RAM_SAVE_FLAG_COMPRESS) {
+ } else if (flags & RAM_SAVE_FLAG_COMPRESS) {
void *host;
uint8_t ch;
@@ -939,20 +937,24 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
}
if (load_xbzrle(f, addr, host) < 0) {
+ error_report("Failed to decompress XBZRLE page at "
+ RAM_ADDR_FMT, addr);
ret = -EINVAL;
- goto done;
+ break;
}
} else if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, flags);
+ } else if (flags & RAM_SAVE_FLAG_EOS) {
+ /* normal exit */
+ break;
+ } else {
+ error_report("Unknown migration flags: %#x", flags);
+ ret = -EINVAL;
+ break;
}
- error = qemu_file_get_error(f);
- if (error) {
- ret = error;
- goto done;
- }
- } while (!(flags & RAM_SAVE_FLAG_EOS));
+ ret = qemu_file_get_error(f);
+ }
-done:
DPRINTF("Completed load of VM with exit code %d seq iteration "
"%" PRIu64 "\n", ret, seq_iter);
return ret;
diff --git a/migration.c b/migration.c
index 79c86c9..22a1399 100644
--- a/migration.c
+++ b/migration.c
@@ -105,7 +105,7 @@ static void process_incoming_migration_co(void *opaque)
ret = qemu_loadvm_state(f);
qemu_fclose(f);
if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
+ error_report("load of migration failed: %s", strerror(-ret));
exit(EXIT_FAILURE);
}
qemu_announce_self();
--
1.9.1
- [Qemu-devel] [PATCH 095/156] qcow2: Zero-initialise first cluster for new images, (continued)
- [Qemu-devel] [PATCH 095/156] qcow2: Zero-initialise first cluster for new images, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 108/156] dmg: prevent chunk buffer overflow (CVE-2014-0145), Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 113/156] qcow2: Check maximum L1 size in qcow2_snapshot_load_tmp() (CVE-2014-0143), Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 051/156] tsc210x: fix buffer overrun on invalid state load, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 070/156] qemu-iotests: add cloop input validation tests, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 146/156] virtio-net: byteswap virtio-net header, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 004/156] s390x/virtio-hcall: Add range check for hypervisor call, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 010/156] tests: Fix 'make test' for i686 hosts (build regression), Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 012/156] mirror: fix throttling delay calculation, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 116/156] qcow1: Make padding in the header explicit, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 068/156] migration: catch unknown flags in ram_load,
Michael Roth <=
- [Qemu-devel] [PATCH 048/156] pxa2xx: avoid buffer overrun on incoming migration, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 053/156] virtio-scsi: fix buffer overrun on invalid state load, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 115/156] parallels: Sanity check for s->tracks (CVE-2014-0142), Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 058/156] stellaris_enet: block migration, Michael Roth, 2014/07/10
- [Qemu-devel] [PATCH 102/156] dmg: coding style and indentation cleanup, Michael Roth, 2014/07/10