cryptospore / 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

eb5a2f
From ed30bd1d0e45463cc48aeb839b4ae3c65009ce79 Mon Sep 17 00:00:00 2001
eb5a2f
From: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Date: Wed, 14 May 2014 08:24:43 +0200
eb5a2f
Subject: [PATCH 13/30] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
eb5a2f
eb5a2f
RH-Author: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Message-id: <1400055633-6261-5-git-send-email-mst@redhat.com>
eb5a2f
Patchwork-id: 58852
eb5a2f
O-Subject: [PATCH qemu-kvm RHEL7.0.z 5/5] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
eb5a2f
Bugzilla: 1095714
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
eb5a2f
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7450401
eb5a2f
Bugzilla:1095714
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