dcavalca / rpms / qemu

Forked from rpms/qemu 11 months ago
Clone

Blame 0011-vmstate-fix-buffer-overflow-in-target-arm-machine.c.patch

70114f
From acf45756e165664f6d70025c02ddca563adee496 Mon Sep 17 00:00:00 2001
70114f
From: "Michael S. Tsirkin" <mst@redhat.com>
70114f
Date: Thu, 3 Apr 2014 19:51:42 +0300
70114f
Subject: [PATCH] vmstate: fix buffer overflow in target-arm/machine.c
70114f
70114f
CVE-2013-4531
70114f
70114f
cpreg_vmstate_indexes is a VARRAY_INT32. A negative value for
70114f
cpreg_vmstate_array_len will cause a buffer overflow.
70114f
70114f
VMSTATE_INT32_LE was supposed to protect against this
70114f
but doesn't because it doesn't validate that input is
70114f
non-negative.
70114f
70114f
Fix this macro to valide the value appropriately.
70114f
70114f
The only other user of VMSTATE_INT32_LE doesn't
70114f
ever use negative numbers so it doesn't care.
70114f
70114f
Reported-by: Anthony Liguori <anthony@codemonkey.ws>
70114f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
70114f
Signed-off-by: Juan Quintela <quintela@redhat.com>
70114f
(cherry picked from commit d2ef4b61fe6d33d2a5dcf100a9b9440de341ad62)
70114f
---
70114f
 vmstate.c | 7 ++++---
70114f
 1 file changed, 4 insertions(+), 3 deletions(-)
70114f
70114f
diff --git a/vmstate.c b/vmstate.c
70114f
index d856319..105f184 100644
70114f
--- a/vmstate.c
70114f
+++ b/vmstate.c
70114f
@@ -333,8 +333,9 @@ const VMStateInfo vmstate_info_int32_equal = {
70114f
     .put  = put_int32,
70114f
 };
70114f
 
70114f
-/* 32 bit int. Check that the received value is less than or equal to
70114f
-   the one in the field */
70114f
+/* 32 bit int. Check that the received value is non-negative
70114f
+ * and less than or equal to the one in the field.
70114f
+ */
70114f
 
70114f
 static int get_int32_le(QEMUFile *f, void *pv, size_t size)
70114f
 {
70114f
@@ -342,7 +343,7 @@ static int get_int32_le(QEMUFile *f, void *pv, size_t size)
70114f
     int32_t loaded;
70114f
     qemu_get_sbe32s(f, &loaded);
70114f
 
70114f
-    if (loaded <= *cur) {
70114f
+    if (loaded >= 0 && loaded <= *cur) {
70114f
         *cur = loaded;
70114f
         return 0;
70114f
     }