From nobody Mon Apr 29 02:42:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565167308; cv=none; d=zoho.com; s=zohoarc; b=V6X9FkNYtSIG5sAF2p9pe5sUypStAKXvr+TNDE9nG+xwAHr27HKLmH0WeMzHIWlyT4ZHOgHxcRtMZ0SFdeJii+0N3+X3/Xrj/xPfVMdSJ3ITdBtekUSpkee3eqqtRG39KkBgB2HATGOHv/L8KmUL7O21SJGeXKiAo4FZ2bAVKos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565167308; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=z446deYhY3/sZvdlEvVzYw/Br0We3BDZRD7L/rnjhL4=; b=I8njctVTPRcgnE7XUEwKY3D/0vjHZ0CSOQmZQOlBdrzowb6YH2amCC4PoXXIREJGnZe2yKWUUl+O8X8atZU6t7twFFeOvqfW+AxS8+OPGaatZbzg5zMflSB6bnQYyqV0iRpnHNV58G07L1ro/vk1KpluP0VBgcqryUZQ9tgM128= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565167308963534.5233757541599; Wed, 7 Aug 2019 01:41:48 -0700 (PDT) Received: from localhost ([::1]:38826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvHW0-00023E-1z for importer@patchew.org; Wed, 07 Aug 2019 04:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47177) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvHVH-0000ok-8H for qemu-devel@nongnu.org; Wed, 07 Aug 2019 04:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvHVG-0007Nf-8E for qemu-devel@nongnu.org; Wed, 07 Aug 2019 04:41:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvHVG-0007MH-2a for qemu-devel@nongnu.org; Wed, 07 Aug 2019 04:41:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECBD93081CF6 for ; Wed, 7 Aug 2019 08:40:58 +0000 (UTC) Received: from localhost (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2437525261; Wed, 7 Aug 2019 08:40:52 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Aug 2019 12:40:48 +0400 Message-Id: <20190807084048.4258-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 07 Aug 2019 08:40:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] usbredir: fix buffer-overflow on vmload X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If interface_count is NO_INTERFACE_INFO, let's not access the arrays out-of-bounds. =3D=3D994=3D=3DERROR: AddressSanitizer: heap-buffer-overflow on address 0x6= 25000243930 at pc 0x5642068086a8 bp 0x7f0b6f9ffa50 sp 0x7f0b6f9ffa40 READ of size 1 at 0x625000243930 thread T0 #0 0x5642068086a7 in usbredir_check_bulk_receiving /home/elmarco/src/qe= mu/hw/usb/redirect.c:1503 #1 0x56420681301c in usbredir_post_load /home/elmarco/src/qemu/hw/usb/r= edirect.c:2154 #2 0x5642068a56c2 in vmstate_load_state /home/elmarco/src/qemu/migratio= n/vmstate.c:168 #3 0x56420688e2ac in vmstate_load /home/elmarco/src/qemu/migration/save= vm.c:829 #4 0x5642068980cb in qemu_loadvm_section_start_full /home/elmarco/src/q= emu/migration/savevm.c:2211 #5 0x564206899645 in qemu_loadvm_state_main /home/elmarco/src/qemu/migr= ation/savevm.c:2395 #6 0x5642068998cf in qemu_loadvm_state /home/elmarco/src/qemu/migration= /savevm.c:2467 #7 0x56420685f3e9 in process_incoming_migration_co /home/elmarco/src/qe= mu/migration/migration.c:449 #8 0x564207106c47 in coroutine_trampoline /home/elmarco/src/qemu/util/c= oroutine-ucontext.c:115 #9 0x7f0c0604e37f (/lib64/libc.so.6+0x4d37f) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Li Qiang Reviewed-by: Liam Merwick Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/redirect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 998fc6e4b0..9764a57987 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1495,6 +1495,11 @@ static void usbredir_check_bulk_receiving(USBRedirDe= vice *dev) for (i =3D EP2I(USB_DIR_IN); i < MAX_ENDPOINTS; i++) { dev->endpoint[i].bulk_receiving_enabled =3D 0; } + + if (dev->interface_info.interface_count =3D=3D NO_INTERFACE_INFO) { + return; + } + for (i =3D 0; i < dev->interface_info.interface_count; i++) { quirks =3D usb_get_quirks(dev->device_info.vendor_id, dev->device_info.product_id, --=20 2.23.0.rc1