9ae3a8
From 5ba6a1889f6da826b7a3b16381977806d8efe553 Mon Sep 17 00:00:00 2001
9ae3a8
From: Petr Matousek <pmatouse@redhat.com>
9ae3a8
Date: Thu, 25 Jun 2015 12:46:37 +0200
9ae3a8
Subject: [PATCH 01/10] i8254: fix out-of-bounds memory access in
9ae3a8
 pit_ioport_read()
9ae3a8
9ae3a8
Message-id: <20150625124637.GJ18896@dhcp-25-225.brq.redhat.com>
9ae3a8
Patchwork-id: 66478
9ae3a8
O-Subject: [RHEL-7.2 qemu-kvm PATCH] i8254: fix out-of-bounds memory access in pit_ioport_read()
9ae3a8
Bugzilla: 1229646
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
9ae3a8
Upstream: d4862a87e31a51de9eb260f25c9e99a75efe3235
9ae3a8
9ae3a8
Due converting PIO to the new memory read/write api we no longer provide
9ae3a8
separate I/O region lenghts for read and write operations. As a result,
9ae3a8
reading from PIT Mode/Command register will end with accessing
9ae3a8
pit->channels with invalid index.
9ae3a8
9ae3a8
Fix this by ignoring read from the Mode/Command register.
9ae3a8
9ae3a8
This is CVE-2015-3214.
9ae3a8
9ae3a8
Reported-by: Matt Tait <matttait@google.com>
9ae3a8
Fixes: 0505bcdec8228d8de39ab1a02644e71999e7c052
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
Signed-off-by: Petr Matousek <pmatouse@redhat.com>
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Petr Matousek <pmatouse@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/timer/i8254.c | 6 ++++++
9ae3a8
 1 file changed, 6 insertions(+)
9ae3a8
9ae3a8
diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c
9ae3a8
index 20c0c36..64c9f58 100644
9ae3a8
--- a/hw/timer/i8254.c
9ae3a8
+++ b/hw/timer/i8254.c
9ae3a8
@@ -187,6 +187,12 @@ static uint64_t pit_ioport_read(void *opaque, hwaddr addr,
9ae3a8
     PITChannelState *s;
9ae3a8
 
9ae3a8
     addr &= 3;
9ae3a8
+
9ae3a8
+    if (addr == 3) {
9ae3a8
+        /* Mode/Command register is write only, read is ignored */
9ae3a8
+        return 0;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     s = &pit->channels[addr];
9ae3a8
     if (s->status_latched) {
9ae3a8
         s->status_latched = 0;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8