Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0016-tsc210x-fix-buffer-overrun-on-invalid-state-load.patch
1 From 984fcc9ad2abc4429422c045d68e17f1eb1fa4b2 Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 3 Apr 2014 19:52:09 +0300
4 Subject: [PATCH] tsc210x: fix buffer overrun on invalid state load
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2013-4539
10
11 s->precision, nextprecision, function and nextfunction
12 come from wire and are used
13 as idx into resolution[] in TSC_CUT_RESOLUTION.
14
15 Validate after load to avoid buffer overrun.
16
17 Cc: Andreas Färber <afaerber@suse.de>
18 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
19 Signed-off-by: Juan Quintela <quintela@redhat.com>
20 (cherry picked from commit 5193be3be35f29a35bc465036cd64ad60d43385f)
21 ---
22  hw/input/tsc210x.c | 12 ++++++++++++
23  1 file changed, 12 insertions(+)
24
25 diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
26 index 485c9e5..aa5b688 100644
27 --- a/hw/input/tsc210x.c
28 +++ b/hw/input/tsc210x.c
29 @@ -1070,9 +1070,21 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
30      s->enabled = qemu_get_byte(f);
31      s->host_mode = qemu_get_byte(f);
32      s->function = qemu_get_byte(f);
33 +    if (s->function < 0 || s->function >= ARRAY_SIZE(mode_regs)) {
34 +        return -EINVAL;
35 +    }
36      s->nextfunction = qemu_get_byte(f);
37 +    if (s->nextfunction < 0 || s->nextfunction >= ARRAY_SIZE(mode_regs)) {
38 +        return -EINVAL;
39 +    }
40      s->precision = qemu_get_byte(f);
41 +    if (s->precision < 0 || s->precision >= ARRAY_SIZE(resolution)) {
42 +        return -EINVAL;
43 +    }
44      s->nextprecision = qemu_get_byte(f);
45 +    if (s->nextprecision < 0 || s->nextprecision >= ARRAY_SIZE(resolution)) {
46 +        return -EINVAL;
47 +    }
48      s->filter = qemu_get_byte(f);
49      s->pin_func = qemu_get_byte(f);
50      s->ref = qemu_get_byte(f);