Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0017-zaurus-fix-buffer-overrun-on-invalid-state-load.patch
1 From 985b046012f258fd5a2164fb85e9d792f574697c Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 3 Apr 2014 19:52:13 +0300
4 Subject: [PATCH] zaurus: fix buffer overrun on invalid state load
5
6 CVE-2013-4540
7
8 Within scoop_gpio_handler_update, if prev_level has a high bit set, then
9 we get bit > 16 and that causes a buffer overrun.
10
11 Since prev_level comes from wire indirectly, this can
12 happen on invalid state load.
13
14 Similarly for gpio_level and gpio_dir.
15
16 To fix, limit to 16 bit.
17
18 Reported-by: Michael S. Tsirkin <mst@redhat.com>
19 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
20 Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
21 Signed-off-by: Juan Quintela <quintela@redhat.com>
22 (cherry picked from commit 52f91c3723932f8340fe36c8ec8b18a757c37b2b)
23 ---
24  hw/gpio/zaurus.c | 10 ++++++++++
25  1 file changed, 10 insertions(+)
26
27 diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c
28 index dc79a8b..8e2ce04 100644
29 --- a/hw/gpio/zaurus.c
30 +++ b/hw/gpio/zaurus.c
31 @@ -203,6 +203,15 @@ static bool is_version_0 (void *opaque, int version_id)
32      return version_id == 0;
33  }
34  
35 +static bool vmstate_scoop_validate(void *opaque, int version_id)
36 +{
37 +    ScoopInfo *s = opaque;
38 +
39 +    return !(s->prev_level & 0xffff0000) &&
40 +        !(s->gpio_level & 0xffff0000) &&
41 +        !(s->gpio_dir & 0xffff0000);
42 +}
43 +
44  static const VMStateDescription vmstate_scoop_regs = {
45      .name = "scoop",
46      .version_id = 1,
47 @@ -215,6 +224,7 @@ static const VMStateDescription vmstate_scoop_regs = {
48          VMSTATE_UINT32(gpio_level, ScoopInfo),
49          VMSTATE_UINT32(gpio_dir, ScoopInfo),
50          VMSTATE_UINT32(prev_level, ScoopInfo),
51 +        VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate),
52          VMSTATE_UINT16(mcr, ScoopInfo),
53          VMSTATE_UINT16(cdr, ScoopInfo),
54          VMSTATE_UINT16(ccr, ScoopInfo),