qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	kraxel@redhat.com, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH] usbredir: fix buffer-overflow on migration load
Date: Fri,  5 Jul 2019 11:39:57 +0400	[thread overview]
Message-ID: <20190705073957.2921-1-marcandre.lureau@redhat.com> (raw)

NO_INTERFACE_INFO (255) is used to indicate no info.

/home/elmarco/src/qemu/hw/usb/redirect.c:1504:71: runtime error: index 32 out of bounds for type 'uint8_t [32]'
/home/elmarco/src/qemu/hw/usb/redirect.c:1503:71: runtime error: index 32 out of bounds for type 'uint8_t [32]'
/home/elmarco/src/qemu/hw/usb/redirect.c:1502:68: runtime error: index 32 out of bounds for type 'uint8_t [32]'
=================================================================
==32073==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x625000252930 at pc 0x556c5126b0b6 bp 0x7fc7793ffa50 sp 0x7fc7793ffa40
READ of size 1 at 0x625000252930 thread T0
    #0 0x556c5126b0b5 in usbredir_check_bulk_receiving /home/elmarco/src/qemu/hw/usb/redirect.c:1504
    #1 0x556c51275a2a in usbredir_post_load /home/elmarco/src/qemu/hw/usb/redirect.c:2154
    #2 0x556c51306f5e in vmstate_load_state /home/elmarco/src/qemu/migration/vmstate.c:168
    #3 0x556c512efb43 in vmstate_load /home/elmarco/src/qemu/migration/savevm.c:829
    #4 0x556c512f9967 in qemu_loadvm_section_start_full /home/elmarco/src/qemu/migration/savevm.c:2212
    #5 0x556c512faee1 in qemu_loadvm_state_main /home/elmarco/src/qemu/migration/savevm.c:2396
    #6 0x556c512fb16b in qemu_loadvm_state /home/elmarco/src/qemu/migration/savevm.c:2468
    #7 0x556c512c0d2b in process_incoming_migration_co /home/elmarco/src/qemu/migration/migration.c:449
    #8 0x556c51b62bcc in coroutine_trampoline /home/elmarco/src/qemu/util/coroutine-ucontext.c:115
    #9 0x7fc80fba637f  (/lib64/libc.so.6+0x4d37f)

Cc: qemu-stable@nongnu.org
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/usb/redirect.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 998fc6e4b0..3bda19bd64 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1495,6 +1495,9 @@ static void usbredir_check_bulk_receiving(USBRedirDevice *dev)
     for (i = EP2I(USB_DIR_IN); i < MAX_ENDPOINTS; i++) {
         dev->endpoint[i].bulk_receiving_enabled = 0;
     }
+    if (dev->interface_info.interface_count == NO_INTERFACE_INFO) {
+        return;
+    }
     for (i = 0; i < dev->interface_info.interface_count; i++) {
         quirks = usb_get_quirks(dev->device_info.vendor_id,
                                 dev->device_info.product_id,
-- 
2.22.0.214.g8dca754b1e



             reply	other threads:[~2019-07-05  7:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  7:39 Marc-André Lureau [this message]
2019-07-05  7:43 ` [Qemu-devel] [PATCH] usbredir: fix buffer-overflow on migration load Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190705073957.2921-1-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).