Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0020-usb-sanity-check-setup_index-setup_len-in-post_load.patch
1 From a608c9c4150820ec64f5f25f6ebe244906c015da Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 3 Apr 2014 19:52:25 +0300
4 Subject: [PATCH] usb: sanity check setup_index+setup_len in post_load
5
6 CVE-2013-4541
7
8 s->setup_len and s->setup_index are fed into usb_packet_copy as
9 size/offset into s->data_buf, it's possible for invalid state to exploit
10 this to load arbitrary data.
11
12 setup_len and setup_index should be checked to make sure
13 they are not negative.
14
15 Cc: Gerd Hoffmann <kraxel@redhat.com>
16 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
17 Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
18 Signed-off-by: Juan Quintela <quintela@redhat.com>
19 (cherry picked from commit 9f8e9895c504149d7048e9fc5eb5cbb34b16e49a)
20 ---
21  hw/usb/bus.c | 4 +++-
22  1 file changed, 3 insertions(+), 1 deletion(-)
23
24 diff --git a/hw/usb/bus.c b/hw/usb/bus.c
25 index fe70429..e48b19f 100644
26 --- a/hw/usb/bus.c
27 +++ b/hw/usb/bus.c
28 @@ -49,7 +49,9 @@ static int usb_device_post_load(void *opaque, int version_id)
29      } else {
30          dev->attached = 1;
31      }
32 -    if (dev->setup_index >= sizeof(dev->data_buf) ||
33 +    if (dev->setup_index < 0 ||
34 +        dev->setup_len < 0 ||
35 +        dev->setup_index >= sizeof(dev->data_buf) ||
36          dev->setup_len >= sizeof(dev->data_buf)) {
37          return -EINVAL;
38      }