render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0106-usb-fix-up-post-load-checks.patch

12cd54
From 40e49e4fab60b3b323263f06b7a8385fa9b62e89 Mon Sep 17 00:00:00 2001
12cd54
From: "Michael S. Tsirkin" <mst@redhat.com>
12cd54
Date: Tue, 13 May 2014 12:33:16 +0300
12cd54
Subject: [PATCH] usb: fix up post load checks
12cd54
12cd54
Correct post load checks:
12cd54
1. dev->setup_len == sizeof(dev->data_buf)
12cd54
    seems fine, no need to fail migration
12cd54
2. When state is DATA, passing index > len
12cd54
   will cause memcpy with negative length,
12cd54
   resulting in heap overflow
12cd54
12cd54
First of the issues was reported by dgilbert.
12cd54
12cd54
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
12cd54
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12cd54
Signed-off-by: Juan Quintela <quintela@redhat.com>
12cd54
(cherry picked from commit 719ffe1f5f72b1c7ace4afe9ba2815bcb53a829e)
12cd54
---
12cd54
 hw/usb/bus.c | 4 ++--
12cd54
 1 file changed, 2 insertions(+), 2 deletions(-)
12cd54
12cd54
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
12cd54
index e48b19f..ff1dfe6 100644
12cd54
--- a/hw/usb/bus.c
12cd54
+++ b/hw/usb/bus.c
12cd54
@@ -51,8 +51,8 @@ static int usb_device_post_load(void *opaque, int version_id)
12cd54
     }
12cd54
     if (dev->setup_index < 0 ||
12cd54
         dev->setup_len < 0 ||
12cd54
-        dev->setup_index >= sizeof(dev->data_buf) ||
12cd54
-        dev->setup_len >= sizeof(dev->data_buf)) {
12cd54
+        dev->setup_index > dev->setup_len ||
12cd54
+        dev->setup_len > sizeof(dev->data_buf)) {
12cd54
         return -EINVAL;
12cd54
     }
12cd54
     return 0;