Blame 0017-zaurus-fix-buffer-overrun-on-invalid-state-load.patch

70114f
From 985b046012f258fd5a2164fb85e9d792f574697c Mon Sep 17 00:00:00 2001
70114f
From: "Michael S. Tsirkin" <mst@redhat.com>
70114f
Date: Thu, 3 Apr 2014 19:52:13 +0300
70114f
Subject: [PATCH] zaurus: fix buffer overrun on invalid state load
70114f
70114f
CVE-2013-4540
70114f
70114f
Within scoop_gpio_handler_update, if prev_level has a high bit set, then
70114f
we get bit > 16 and that causes a buffer overrun.
70114f
70114f
Since prev_level comes from wire indirectly, this can
70114f
happen on invalid state load.
70114f
70114f
Similarly for gpio_level and gpio_dir.
70114f
70114f
To fix, limit to 16 bit.
70114f
70114f
Reported-by: Michael S. Tsirkin <mst@redhat.com>
70114f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
70114f
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
70114f
Signed-off-by: Juan Quintela <quintela@redhat.com>
70114f
(cherry picked from commit 52f91c3723932f8340fe36c8ec8b18a757c37b2b)
70114f
---
70114f
 hw/gpio/zaurus.c | 10 ++++++++++
70114f
 1 file changed, 10 insertions(+)
70114f
70114f
diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c
70114f
index dc79a8b..8e2ce04 100644
70114f
--- a/hw/gpio/zaurus.c
70114f
+++ b/hw/gpio/zaurus.c
70114f
@@ -203,6 +203,15 @@ static bool is_version_0 (void *opaque, int version_id)
70114f
     return version_id == 0;
70114f
 }
70114f
 
70114f
+static bool vmstate_scoop_validate(void *opaque, int version_id)
70114f
+{
70114f
+    ScoopInfo *s = opaque;
70114f
+
70114f
+    return !(s->prev_level & 0xffff0000) &&
70114f
+        !(s->gpio_level & 0xffff0000) &&
70114f
+        !(s->gpio_dir & 0xffff0000);
70114f
+}
70114f
+
70114f
 static const VMStateDescription vmstate_scoop_regs = {
70114f
     .name = "scoop",
70114f
     .version_id = 1,
70114f
@@ -215,6 +224,7 @@ static const VMStateDescription vmstate_scoop_regs = {
70114f
         VMSTATE_UINT32(gpio_level, ScoopInfo),
70114f
         VMSTATE_UINT32(gpio_dir, ScoopInfo),
70114f
         VMSTATE_UINT32(prev_level, ScoopInfo),
70114f
+        VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate),
70114f
         VMSTATE_UINT16(mcr, ScoopInfo),
70114f
         VMSTATE_UINT16(cdr, ScoopInfo),
70114f
         VMSTATE_UINT16(ccr, ScoopInfo),