Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0010-pl022-fix-buffer-overun-on-invalid-state-load.patch
1 From 872fc04ecd90e0ca4d8ac4565b3a9f246c070873 Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 3 Apr 2014 19:51:35 +0300
4 Subject: [PATCH] pl022: fix buffer overun on invalid state load
5
6 CVE-2013-4530
7
8 pl022.c did not bounds check tx_fifo_head and
9 rx_fifo_head after loading them from file and
10 before they are used to dereference array.
11
12 Reported-by: Michael S. Tsirkin <mst@redhat.com
13 Reported-by: Anthony Liguori <anthony@codemonkey.ws>
14 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
15 Signed-off-by: Juan Quintela <quintela@redhat.com>
16 (cherry picked from commit d8d0a0bc7e194300e53a346d25fe5724fd588387)
17 ---
18  hw/ssi/pl022.c | 14 ++++++++++++++
19  1 file changed, 14 insertions(+)
20
21 diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
22 index fd479ef..b19bc71 100644
23 --- a/hw/ssi/pl022.c
24 +++ b/hw/ssi/pl022.c
25 @@ -240,11 +240,25 @@ static const MemoryRegionOps pl022_ops = {
26      .endianness = DEVICE_NATIVE_ENDIAN,
27  };
28  
29 +static int pl022_post_load(void *opaque, int version_id)
30 +{
31 +    PL022State *s = opaque;
32 +
33 +    if (s->tx_fifo_head < 0 ||
34 +        s->tx_fifo_head >= ARRAY_SIZE(s->tx_fifo) ||
35 +        s->rx_fifo_head < 0 ||
36 +        s->rx_fifo_head >= ARRAY_SIZE(s->rx_fifo)) {
37 +        return -1;
38 +    }
39 +    return 0;
40 +}
41 +
42  static const VMStateDescription vmstate_pl022 = {
43      .name = "pl022_ssp",
44      .version_id = 1,
45      .minimum_version_id = 1,
46      .minimum_version_id_old = 1,
47 +    .post_load = pl022_post_load,
48      .fields      = (VMStateField[]) {
49          VMSTATE_UINT32(cr0, PL022State),
50          VMSTATE_UINT32(cr1, PL022State),