peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0010-pl022-fix-buffer-overun-on-invalid-state-load.patch

70114f
From 872fc04ecd90e0ca4d8ac4565b3a9f246c070873 Mon Sep 17 00:00:00 2001
70114f
From: "Michael S. Tsirkin" <mst@redhat.com>
70114f
Date: Thu, 3 Apr 2014 19:51:35 +0300
70114f
Subject: [PATCH] pl022: fix buffer overun on invalid state load
70114f
70114f
CVE-2013-4530
70114f
70114f
pl022.c did not bounds check tx_fifo_head and
70114f
rx_fifo_head after loading them from file and
70114f
before they are used to dereference array.
70114f
70114f
Reported-by: Michael S. Tsirkin 
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 d8d0a0bc7e194300e53a346d25fe5724fd588387)
70114f
---
70114f
 hw/ssi/pl022.c | 14 ++++++++++++++
70114f
 1 file changed, 14 insertions(+)
70114f
70114f
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
70114f
index fd479ef..b19bc71 100644
70114f
--- a/hw/ssi/pl022.c
70114f
+++ b/hw/ssi/pl022.c
70114f
@@ -240,11 +240,25 @@ static const MemoryRegionOps pl022_ops = {
70114f
     .endianness = DEVICE_NATIVE_ENDIAN,
70114f
 };
70114f
 
70114f
+static int pl022_post_load(void *opaque, int version_id)
70114f
+{
70114f
+    PL022State *s = opaque;
70114f
+
70114f
+    if (s->tx_fifo_head < 0 ||
70114f
+        s->tx_fifo_head >= ARRAY_SIZE(s->tx_fifo) ||
70114f
+        s->rx_fifo_head < 0 ||
70114f
+        s->rx_fifo_head >= ARRAY_SIZE(s->rx_fifo)) {
70114f
+        return -1;
70114f
+    }
70114f
+    return 0;
70114f
+}
70114f
+
70114f
 static const VMStateDescription vmstate_pl022 = {
70114f
     .name = "pl022_ssp",
70114f
     .version_id = 1,
70114f
     .minimum_version_id = 1,
70114f
     .minimum_version_id_old = 1,
70114f
+    .post_load = pl022_post_load,
70114f
     .fields      = (VMStateField[]) {
70114f
         VMSTATE_UINT32(cr0, PL022State),
70114f
         VMSTATE_UINT32(cr1, PL022State),