aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-04-03 19:51:23 +0300
committerMichael Roth <mdroth@linux.vnet.ibm.com>2014-06-26 14:01:11 -0500
commitd8aba740f274514bdda2a240f8b881f8d928f5cd (patch)
tree53827a819e8e52e9a51292890132a8f8679087f6 /hw
parentd34e6f796097bd46d1bf8b26916df757d54aba03 (diff)
downloadqemu-d8aba740f274514bdda2a240f8b881f8d928f5cd.zip
qemu-d8aba740f274514bdda2a240f8b881f8d928f5cd.tar.gz
qemu-d8aba740f274514bdda2a240f8b881f8d928f5cd.tar.bz2
hpet: fix buffer overrun on invalid state load
CVE-2013-4527 hw/timer/hpet.c buffer overrun hpet is a VARRAY with a uint8 size but static array of 32 To fix, make sure num_timers is valid using VMSTATE_VALID hook. Reported-by: Anthony Liguori <anthony@codemonkey.ws> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> (cherry picked from commit 3f1c49e2136fa08ab1ef3183fd55def308829584) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/timer/hpet.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index c6c2803..60892da 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -227,6 +227,18 @@ static int hpet_pre_load(void *opaque)
return 0;
}
+static bool hpet_validate_num_timers(void *opaque, int version_id)
+{
+ HPETState *s = opaque;
+
+ if (s->num_timers < HPET_MIN_TIMERS) {
+ return false;
+ } else if (s->num_timers > HPET_MAX_TIMERS) {
+ return false;
+ }
+ return true;
+}
+
static int hpet_post_load(void *opaque, int version_id)
{
HPETState *s = opaque;
@@ -295,6 +307,7 @@ static const VMStateDescription vmstate_hpet = {
VMSTATE_UINT64(isr, HPETState),
VMSTATE_UINT64(hpet_counter, HPETState),
VMSTATE_UINT8_V(num_timers, HPETState, 2),
+ VMSTATE_VALIDATE("num_timers in range", hpet_validate_num_timers),
VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
vmstate_hpet_timer, HPETTimer),
VMSTATE_END_OF_LIST()