|
|
70114f |
From b6f53085cc618bc7e58be702afacad1b5dcae5ba Mon Sep 17 00:00:00 2001
|
|
|
70114f |
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
|
70114f |
Date: Thu, 3 Apr 2014 19:51:31 +0300
|
|
|
70114f |
Subject: [PATCH] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
|
|
|
70114f |
|
|
|
70114f |
4) CVE-2013-4529
|
|
|
70114f |
hw/pci/pcie_aer.c pcie aer log can overrun the buffer if log_num is
|
|
|
70114f |
too large
|
|
|
70114f |
|
|
|
70114f |
There are two issues in this file:
|
|
|
70114f |
1. log_max from remote can be larger than on local
|
|
|
70114f |
then buffer will overrun with data coming from state file.
|
|
|
70114f |
2. log_num can be larger then we get data corruption
|
|
|
70114f |
again with an overflow but not adversary controlled.
|
|
|
70114f |
|
|
|
70114f |
Fix both issues.
|
|
|
70114f |
|
|
|
70114f |
Reported-by: Anthony Liguori <anthony@codemonkey.ws>
|
|
|
70114f |
Reported-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
70114f |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
70114f |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
70114f |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
70114f |
(cherry picked from commit 5f691ff91d323b6f97c6600405a7f9dc115a0ad1)
|
|
|
70114f |
---
|
|
|
70114f |
hw/pci/pcie_aer.c | 10 +++++++++-
|
|
|
70114f |
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
70114f |
|
|
|
70114f |
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
|
|
|
70114f |
index 991502e..535be2c 100644
|
|
|
70114f |
--- a/hw/pci/pcie_aer.c
|
|
|
70114f |
+++ b/hw/pci/pcie_aer.c
|
|
|
70114f |
@@ -795,6 +795,13 @@ static const VMStateDescription vmstate_pcie_aer_err = {
|
|
|
70114f |
}
|
|
|
70114f |
};
|
|
|
70114f |
|
|
|
70114f |
+static bool pcie_aer_state_log_num_valid(void *opaque, int version_id)
|
|
|
70114f |
+{
|
|
|
70114f |
+ PCIEAERLog *s = opaque;
|
|
|
70114f |
+
|
|
|
70114f |
+ return s->log_num <= s->log_max;
|
|
|
70114f |
+}
|
|
|
70114f |
+
|
|
|
70114f |
const VMStateDescription vmstate_pcie_aer_log = {
|
|
|
70114f |
.name = "PCIE_AER_ERROR_LOG",
|
|
|
70114f |
.version_id = 1,
|
|
|
70114f |
@@ -802,7 +809,8 @@ const VMStateDescription vmstate_pcie_aer_log = {
|
|
|
70114f |
.minimum_version_id_old = 1,
|
|
|
70114f |
.fields = (VMStateField[]) {
|
|
|
70114f |
VMSTATE_UINT16(log_num, PCIEAERLog),
|
|
|
70114f |
- VMSTATE_UINT16(log_max, PCIEAERLog),
|
|
|
70114f |
+ VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog),
|
|
|
70114f |
+ VMSTATE_VALIDATE("log_num <= log_max", pcie_aer_state_log_num_valid),
|
|
|
70114f |
VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num,
|
|
|
70114f |
vmstate_pcie_aer_err, PCIEAERErr),
|
|
|
70114f |
VMSTATE_END_OF_LIST()
|