peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0014-pxa2xx-avoid-buffer-overrun-on-incoming-migration.patch

70114f
From 43b30dec4d07aa81ff5f2dc3b0a064fa589fd3af Mon Sep 17 00:00:00 2001
70114f
From: "Michael S. Tsirkin" <mst@redhat.com>
70114f
Date: Thu, 3 Apr 2014 19:51:57 +0300
70114f
Subject: [PATCH] pxa2xx: avoid buffer overrun on incoming migration
70114f
70114f
CVE-2013-4533
70114f
70114f
s->rx_level is read from the wire and used to determine how many bytes
70114f
to subsequently read into s->rx_fifo[]. If s->rx_level exceeds the
70114f
length of s->rx_fifo[] the buffer can be overrun with arbitrary data
70114f
from the wire.
70114f
70114f
Fix this by validating rx_level against the size of s->rx_fifo.
70114f
70114f
Cc: Don Koch <dkoch@verizon.com>
70114f
Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
70114f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
70114f
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
70114f
Reviewed-by: Don Koch <dkoch@verizon.com>
70114f
Signed-off-by: Juan Quintela <quintela@redhat.com>
70114f
(cherry picked from commit caa881abe0e01f9931125a0977ec33c5343e4aa7)
70114f
---
70114f
 hw/arm/pxa2xx.c | 8 ++++++--
70114f
 1 file changed, 6 insertions(+), 2 deletions(-)
70114f
70114f
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
70114f
index 0429148..e0cd847 100644
70114f
--- a/hw/arm/pxa2xx.c
70114f
+++ b/hw/arm/pxa2xx.c
70114f
@@ -732,7 +732,7 @@ static void pxa2xx_ssp_save(QEMUFile *f, void *opaque)
70114f
 static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
70114f
 {
70114f
     PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;
70114f
-    int i;
70114f
+    int i, v;
70114f
 
70114f
     s->enable = qemu_get_be32(f);
70114f
 
70114f
@@ -746,7 +746,11 @@ static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
70114f
     qemu_get_8s(f, &s->ssrsa);
70114f
     qemu_get_8s(f, &s->ssacd);
70114f
 
70114f
-    s->rx_level = qemu_get_byte(f);
70114f
+    v = qemu_get_byte(f);
70114f
+    if (v < 0 || v > ARRAY_SIZE(s->rx_fifo)) {
70114f
+        return -EINVAL;
70114f
+    }
70114f
+    s->rx_level = v;
70114f
     s->rx_start = 0;
70114f
     for (i = 0; i < s->rx_level; i ++)
70114f
         s->rx_fifo[i] = qemu_get_byte(f);