yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-hw-pci-pcie_aer.c-fix-buffer-overruns-on-invalid-sta.patch

958e1b
From 546f9e97d193307a2ca26c11bf1162d07cc2d31f Mon Sep 17 00:00:00 2001
eb5a2f
From: Michael S. Tsirkin <mst@redhat.com>
958e1b
Date: Wed, 14 May 2014 08:52:59 +0200
958e1b
Subject: [PATCH 24/31] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
eb5a2f
eb5a2f
RH-Author: Michael S. Tsirkin <mst@redhat.com>
958e1b
Message-id: <1400057538-6975-6-git-send-email-mst@redhat.com>
958e1b
Patchwork-id: 58872
958e1b
O-Subject: [PATCH qemu-kvm RHEL7.1 5/5] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
958e1b
Bugzilla: 1095716
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
4) CVE-2013-4529
eb5a2f
hw/pci/pcie_aer.c    pcie aer log can overrun the buffer if log_num is
eb5a2f
                     too large
eb5a2f
eb5a2f
There are two issues in this file:
eb5a2f
1. log_max from remote can be larger than on local
eb5a2f
then buffer will overrun with data coming from state file.
eb5a2f
2. log_num can be larger then we get data corruption
eb5a2f
again with an overflow but not adversary controlled.
eb5a2f
eb5a2f
Fix both issues.
eb5a2f
eb5a2f
Reported-by: Anthony Liguori <anthony@codemonkey.ws>
eb5a2f
Reported-by: Michael S. Tsirkin <mst@redhat.com>
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 5f691ff91d323b6f97c6600405a7f9dc115a0ad1)
eb5a2f
eb5a2f
Tested: lightly on developer's box
958e1b
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
958e1b
Bugzilla:1095716
eb5a2f
---
eb5a2f
 hw/pci/pcie_aer.c | 10 +++++++++-
eb5a2f
 1 file changed, 9 insertions(+), 1 deletion(-)
eb5a2f
eb5a2f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
---
eb5a2f
 hw/pci/pcie_aer.c |   10 +++++++++-
eb5a2f
 1 files changed, 9 insertions(+), 1 deletions(-)
eb5a2f
eb5a2f
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
eb5a2f
index 1ce72ce..ab5c9c6 100644
eb5a2f
--- a/hw/pci/pcie_aer.c
eb5a2f
+++ b/hw/pci/pcie_aer.c
eb5a2f
@@ -795,6 +795,13 @@ static const VMStateDescription vmstate_pcie_aer_err = {
eb5a2f
     }
eb5a2f
 };
eb5a2f
 
eb5a2f
+static bool pcie_aer_state_log_num_valid(void *opaque, int version_id)
eb5a2f
+{
eb5a2f
+    PCIEAERLog *s = opaque;
eb5a2f
+
eb5a2f
+    return s->log_num <= s->log_max;
eb5a2f
+}
eb5a2f
+
eb5a2f
 const VMStateDescription vmstate_pcie_aer_log = {
eb5a2f
     .name = "PCIE_AER_ERROR_LOG",
eb5a2f
     .version_id = 1,
eb5a2f
@@ -802,7 +809,8 @@ const VMStateDescription vmstate_pcie_aer_log = {
eb5a2f
     .minimum_version_id_old = 1,
eb5a2f
     .fields     = (VMStateField[]) {
eb5a2f
         VMSTATE_UINT16(log_num, PCIEAERLog),
eb5a2f
-        VMSTATE_UINT16(log_max, PCIEAERLog),
eb5a2f
+        VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog),
eb5a2f
+        VMSTATE_VALIDATE("log_num <= log_max", pcie_aer_state_log_num_valid),
eb5a2f
         VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num,
eb5a2f
                               vmstate_pcie_aer_err, PCIEAERErr),
eb5a2f
         VMSTATE_END_OF_LIST()
eb5a2f
-- 
eb5a2f
1.7.1
eb5a2f