From 59469018432f7b2cf490a1cefe9855cfccdf0508 Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Tue, 7 Jul 2015 00:33:18 +0200 Subject: qemu: CVE-2014-7840 Fixes insufficient parameter validation during ram load Reference https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7840 Signed-off-by: Sona Sarmadi Signed-off-by: Tudor Florea --- .../recipes-devtools/qemu/qemu/CVE-2014-7840.patch | 57 ++++++++++++++++++++++ meta/recipes-devtools/qemu/qemu_1.7.2.bb | 3 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2014-7840.patch diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2014-7840.patch b/meta/recipes-devtools/qemu/qemu/CVE-2014-7840.patch new file mode 100644 index 0000000000..5405e7078a --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/CVE-2014-7840.patch @@ -0,0 +1,57 @@ +From 0be839a2701369f669532ea5884c15bead1c6e08 Mon Sep 17 00:00:00 2001 +From: "Michael S. Tsirkin" +Date: Wed, 12 Nov 2014 11:44:39 +0200 +Subject: [PATCH] migration: fix parameter validation on ram load + +During migration, the values read from migration stream during ram load +are not validated. Especially offset in host_from_stream_offset() and +also the length of the writes in the callers of said function. + +To fix this, we need to make sure that the [offset, offset + length] +range fits into one of the allocated memory regions. + +Validating addr < len should be sufficient since data seems to always be +managed in TARGET_PAGE_SIZE chunks. + +Fixes: CVE-2014-7840 + +Upstream-Status: Backport + +Note: follow-up patches add extra checks on each block->host access. + +Signed-off-by: Michael S. Tsirkin +Reviewed-by: Paolo Bonzini +Reviewed-by: Dr. David Alan Gilbert +Signed-off-by: Amit Shah +Signed-off-by: Sona Sarmadi +--- + arch_init.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/arch_init.c b/arch_init.c +index 88a5ba0..593a990 100644 +--- a/arch_init.c ++++ b/arch_init.c +@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f, + uint8_t len; + + if (flags & RAM_SAVE_FLAG_CONTINUE) { +- if (!block) { ++ if (!block || block->length <= offset) { + fprintf(stderr, "Ack, bad migration stream!\n"); + return NULL; + } +@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f, + id[len] = 0; + + QTAILQ_FOREACH(block, &ram_list.blocks, next) { +- if (!strncmp(id, block->idstr, sizeof(id))) ++ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) { + return memory_region_get_ram_ptr(block->mr) + offset; ++ } + } + + error_report("Can't find block %s!", id); +-- +1.9.1 + diff --git a/meta/recipes-devtools/qemu/qemu_1.7.2.bb b/meta/recipes-devtools/qemu/qemu_1.7.2.bb index c3c6d3652d..3fa7f201b5 100644 --- a/meta/recipes-devtools/qemu/qemu_1.7.2.bb +++ b/meta/recipes-devtools/qemu/qemu_1.7.2.bb @@ -11,7 +11,8 @@ SRC_URI += "file://fxrstorssefix.patch \ file://vmware-vga-CVE-2014-3689.patch \ file://vmstate_xhci_event-CVE-2014-5263.patch \ file://vnc-CVE-2014-7815.patch \ - file://fdc-CVE-2015-3456.patch" + file://fdc-CVE-2015-3456.patch \ + file://CVE-2014-7840.patch " SRC_URI_prepend = "http://wiki.qemu.org/download/qemu-${PV}.tar.bz2" SRC_URI[md5sum] = "a52e0acd37b0c9b06228fe98da0b1b43" -- cgit v1.2.3-54-g00ecf