cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-hpet-fix-buffer-overrun-on-invalid-state-load.patch

958e1b
From 4b41911968cb53458b86b027f0d028e38618df46 Mon Sep 17 00:00:00 2001
eb5a2f
From: Michael S. Tsirkin <mst@redhat.com>
958e1b
Date: Wed, 14 May 2014 08:52:54 +0200
958e1b
Subject: [PATCH 23/31] hpet: fix buffer overrun on invalid state load
eb5a2f
eb5a2f
RH-Author: Michael S. Tsirkin <mst@redhat.com>
958e1b
Message-id: <1400057538-6975-5-git-send-email-mst@redhat.com>
958e1b
Patchwork-id: 58871
958e1b
O-Subject: [PATCH qemu-kvm RHEL7.1 4/5] hpet: fix buffer overrun on invalid state load
958e1b
Bugzilla: 1095707
eb5a2f
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
eb5a2f
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
eb5a2f
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
eb5a2f
RH-Acked-by: Juan Quintela <quintela@redhat.com>
eb5a2f
eb5a2f
CVE-2013-4527 hw/timer/hpet.c buffer overrun
eb5a2f
eb5a2f
hpet is a VARRAY with a uint8 size but static array of 32
eb5a2f
eb5a2f
To fix, make sure num_timers is valid using VMSTATE_VALID hook.
eb5a2f
eb5a2f
Reported-by: Anthony Liguori <anthony@codemonkey.ws>
eb5a2f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
eb5a2f
Signed-off-by: Juan Quintela <quintela@redhat.com>
eb5a2f
(cherry picked from commit 3f1c49e2136fa08ab1ef3183fd55def308829584)
eb5a2f
eb5a2f
Tested: lightly on developer's box
958e1b
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
958e1b
Bugzilla:1095707
eb5a2f
---
eb5a2f
 hw/timer/hpet.c | 13 +++++++++++++
eb5a2f
 1 file changed, 13 insertions(+)
eb5a2f
eb5a2f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
---
eb5a2f
 hw/timer/hpet.c |   13 +++++++++++++
eb5a2f
 1 files changed, 13 insertions(+), 0 deletions(-)
eb5a2f
eb5a2f
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
eb5a2f
index dd486a1..54ffa49 100644
eb5a2f
--- a/hw/timer/hpet.c
eb5a2f
+++ b/hw/timer/hpet.c
eb5a2f
@@ -222,6 +222,18 @@ static int hpet_pre_load(void *opaque)
eb5a2f
     return 0;
eb5a2f
 }
eb5a2f
 
eb5a2f
+static bool hpet_validate_num_timers(void *opaque, int version_id)
eb5a2f
+{
eb5a2f
+    HPETState *s = opaque;
eb5a2f
+
eb5a2f
+    if (s->num_timers < HPET_MIN_TIMERS) {
eb5a2f
+        return false;
eb5a2f
+    } else if (s->num_timers > HPET_MAX_TIMERS) {
eb5a2f
+        return false;
eb5a2f
+    }
eb5a2f
+    return true;
eb5a2f
+}
eb5a2f
+
eb5a2f
 static int hpet_post_load(void *opaque, int version_id)
eb5a2f
 {
eb5a2f
     HPETState *s = opaque;
eb5a2f
@@ -290,6 +302,7 @@ static const VMStateDescription vmstate_hpet = {
eb5a2f
         VMSTATE_UINT64(isr, HPETState),
eb5a2f
         VMSTATE_UINT64(hpet_counter, HPETState),
eb5a2f
         VMSTATE_UINT8_V(num_timers, HPETState, 2),
eb5a2f
+        VMSTATE_VALIDATE("num_timers in range", hpet_validate_num_timers),
eb5a2f
         VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
eb5a2f
                                     vmstate_hpet_timer, HPETTimer),
eb5a2f
         VMSTATE_END_OF_LIST()
eb5a2f
-- 
eb5a2f
1.7.1
eb5a2f