All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/2] Usb 20210901 patches
@ 2021-09-01  6:53 Gerd Hoffmann
  2021-09-01  6:53 ` [PULL 1/2] uas: add stream number sanity checks Gerd Hoffmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-09-01  6:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The following changes since commit ad22d0583300df420819e6c89b1c022b998fac8a:

  Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.2-20210827' into staging (2021-08-27 11:34:12 +0100)

are available in the Git repository at:

  git://git.kraxel.org/qemu tags/usb-20210901-pull-request

for you to fetch changes up to ae420c957aff2871b8a1af9cf9ee1a7a75b3552b:

  hw/usb: Fix typo in comments and print (2021-09-01 06:37:13 +0200)

----------------------------------------------------------------
usb: bugfixes.

----------------------------------------------------------------

Cai Huoqing (1):
  hw/usb: Fix typo in comments and print

Gerd Hoffmann (1):
  uas: add stream number sanity checks.

 hw/usb/desc.h            |  2 +-
 hw/usb/quirks-ftdi-ids.h |  4 ++--
 hw/usb/desc-msos.c       | 10 +++++-----
 hw/usb/dev-audio.c       |  4 ++--
 hw/usb/dev-uas.c         | 11 +++++++++++
 hw/usb/host-libusb.c     |  2 +-
 hw/usb/u2f-emulated.c    |  2 +-
 7 files changed, 23 insertions(+), 12 deletions(-)

-- 
2.31.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PULL 1/2] uas: add stream number sanity checks.
  2021-09-01  6:53 [PULL 0/2] Usb 20210901 patches Gerd Hoffmann
@ 2021-09-01  6:53 ` Gerd Hoffmann
  2021-09-01  6:53 ` [PULL 2/2] hw/usb: Fix typo in comments and print Gerd Hoffmann
  2021-09-01 16:44 ` [PULL 0/2] Usb 20210901 patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-09-01  6:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Chen Zhe, Philippe Mathieu-Daudé, Gerd Hoffmann, Tan Jingguo

The device uses the guest-supplied stream number unchecked, which can
lead to guest-triggered out-of-band access to the UASDevice->data3 and
UASDevice->status3 fields.  Add the missing checks.

Fixes: CVE-2021-3713
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reported-by: Chen Zhe <chenzhe@huawei.com>
Reported-by: Tan Jingguo <tanjingguo@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210818120505.1258262-2-kraxel@redhat.com>
---
 hw/usb/dev-uas.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index 263056231c79..f6309a5ebfdc 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -840,6 +840,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         }
         break;
     case UAS_PIPE_ID_STATUS:
+        if (p->stream > UAS_MAX_STREAMS) {
+            goto err_stream;
+        }
         if (p->stream) {
             QTAILQ_FOREACH(st, &uas->results, next) {
                 if (st->stream == p->stream) {
@@ -867,6 +870,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         break;
     case UAS_PIPE_ID_DATA_IN:
     case UAS_PIPE_ID_DATA_OUT:
+        if (p->stream > UAS_MAX_STREAMS) {
+            goto err_stream;
+        }
         if (p->stream) {
             req = usb_uas_find_request(uas, p->stream);
         } else {
@@ -902,6 +908,11 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         p->status = USB_RET_STALL;
         break;
     }
+
+err_stream:
+    error_report("%s: invalid stream %d", __func__, p->stream);
+    p->status = USB_RET_STALL;
+    return;
 }
 
 static void usb_uas_unrealize(USBDevice *dev)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PULL 2/2] hw/usb: Fix typo in comments and print
  2021-09-01  6:53 [PULL 0/2] Usb 20210901 patches Gerd Hoffmann
  2021-09-01  6:53 ` [PULL 1/2] uas: add stream number sanity checks Gerd Hoffmann
@ 2021-09-01  6:53 ` Gerd Hoffmann
  2021-09-01 16:44 ` [PULL 0/2] Usb 20210901 patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-09-01  6:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cai Huoqing, Gerd Hoffmann

From: Cai Huoqing <caihuoqing@baidu.com>

Fix typo:
*informations  ==> information
*enougth  ==> enough
*enouth  ==> enough
*registy  ==> registry
*releated  ==> related
*Ouptut  ==> Output
*manualy  ==> manually
*Attemping  ==> Attempting
*contine  ==> continue
*tranceiver  ==> transceiver
*Tranceiver  ==> Transceiver

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Message-Id: <20210730012720.2246-1-caihuoqing@baidu.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/desc.h            |  2 +-
 hw/usb/quirks-ftdi-ids.h |  4 ++--
 hw/usb/desc-msos.c       | 10 +++++-----
 hw/usb/dev-audio.c       |  4 ++--
 hw/usb/host-libusb.c     |  2 +-
 hw/usb/u2f-emulated.c    |  2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/usb/desc.h b/hw/usb/desc.h
index 4d81c68e0ef8..3ac604ecfa17 100644
--- a/hw/usb/desc.h
+++ b/hw/usb/desc.h
@@ -133,7 +133,7 @@ struct USBDescConfig {
     const USBDescIface        *ifs;
 };
 
-/* conceptually an Interface Association Descriptor, and releated interfaces */
+/* conceptually an Interface Association Descriptor, and related interfaces */
 struct USBDescIfaceAssoc {
     uint8_t                   bFirstInterface;
     uint8_t                   bInterfaceCount;
diff --git a/hw/usb/quirks-ftdi-ids.h b/hw/usb/quirks-ftdi-ids.h
index 01aca55ca771..f3cb157d6fa1 100644
--- a/hw/usb/quirks-ftdi-ids.h
+++ b/hw/usb/quirks-ftdi-ids.h
@@ -625,9 +625,9 @@
  * Definitions for Icom Inc. devices
  */
 #define ICOM_VID		0x0C26 /* Icom vendor ID */
-/* Note: ID-1 is a communications tranceiver for HAM-radio operators */
+/* Note: ID-1 is a communications transceiver for HAM-radio operators */
 #define ICOM_ID_1_PID		0x0004 /* ID-1 USB to RS-232 */
-/* Note: OPC is an Optional cable to connect an Icom Tranceiver */
+/* Note: OPC is an Optional cable to connect an Icom Transceiver */
 #define ICOM_OPC_U_UC_PID	0x0018 /* OPC-478UC, OPC-1122U cloning cable */
 /* Note: ID-RP* devices are Icom Repeater Devices for HAM-radio */
 #define ICOM_ID_RP2C1_PID	0x0009 /* ID-RP2C Asset 1 to RS-232 */
diff --git a/hw/usb/desc-msos.c b/hw/usb/desc-msos.c
index 836e38c67e1e..c72c65b650c7 100644
--- a/hw/usb/desc-msos.c
+++ b/hw/usb/desc-msos.c
@@ -5,12 +5,12 @@
 /*
  * Microsoft OS Descriptors
  *
- * Windows tries to fetch some special descriptors with informations
+ * Windows tries to fetch some special descriptors with information
  * specifically for windows.  Presence is indicated using a special
  * string @ index 0xee.  There are two kinds of descriptors:
  *
  * compatid descriptor
- *   Used to bind drivers, if usb class isn't specific enougth.
+ *   Used to bind drivers, if usb class isn't specific enough.
  *   Used for PTP/MTP for example (both share the same usb class).
  *
  * properties descriptor
@@ -23,7 +23,7 @@
  *   HLM\SYSTEM\CurrentControlSet\Control\usbflags
  *   HLM\SYSTEM\CurrentControlSet\Enum\USB
  * Windows will complain it can't delete entries on the second one.
- * It has deleted everything it had permissions too, which is enouth
+ * It has deleted everything it had permissions too, which is enough
  * as this includes "Device Parameters".
  *
  * http://msdn.microsoft.com/en-us/library/windows/hardware/ff537430.aspx
@@ -192,8 +192,8 @@ static int usb_desc_msos_prop(const USBDesc *desc, uint8_t *dest)
     if (desc->msos->SelectiveSuspendEnabled) {
         /*
          * Signaling remote wakeup capability in the standard usb
-         * descriptors isn't enouth to make windows actually use it.
-         * This is the "Yes, we really mean it" registy entry to flip
+         * descriptors isn't enough to make windows actually use it.
+         * This is the "Yes, we really mean it" registry entry to flip
          * the switch in the windows drivers.
          */
         length += usb_desc_msos_prop_dword(dest+length,
diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c
index f5cb2467929a..8748c1ba0401 100644
--- a/hw/usb/dev-audio.c
+++ b/hw/usb/dev-audio.c
@@ -168,7 +168,7 @@ static const USBDescIface desc_iface[] = {
                     STRING_FEATURE_UNIT,        /*  u8  iFeature */
                 }
             },{
-                /* Headphone Ouptut Terminal ID3 Descriptor */
+                /* Headphone Output Terminal ID3 Descriptor */
                 .data = (uint8_t[]) {
                     0x09,                       /*  u8  bLength */
                     USB_DT_CS_INTERFACE,        /*  u8  bDescriptorType */
@@ -332,7 +332,7 @@ static const USBDescIface desc_iface_multi[] = {
                     STRING_FEATURE_UNIT,        /*  u8  iFeature */
                 }
             },{
-                /* Headphone Ouptut Terminal ID3 Descriptor */
+                /* Headphone Output Terminal ID3 Descriptor */
                 .data = (uint8_t[]) {
                     0x09,                       /*  u8  bLength */
                     USB_DT_CS_INTERFACE,        /*  u8  bDescriptorType */
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 00f6fbb29b39..d0d46dd0a4a3 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1706,7 +1706,7 @@ static void usb_host_free_streams(USBDevice *udev, USBEndpoint **eps,
 /*
  * This is *NOT* about restoring state.  We have absolutely no idea
  * what state the host device is in at the moment and whenever it is
- * still present in the first place.  Attemping to contine where we
+ * still present in the first place.  Attempting to continue where we
  * left off is impossible.
  *
  * What we are going to do here is emulate a surprise removal of
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index 9151feb63d44..63cceaa5fc86 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -307,7 +307,7 @@ static void u2f_emulated_realize(U2FKeyState *base, Error **errp)
             rc = u2f_emulated_setup_vdev_manualy(key);
         } else {
             error_setg(errp, "%s: cert, priv, entropy and counter "
-                       "parameters must be provided to manualy configure "
+                       "parameters must be provided to manually configure "
                        "the emulated device", TYPE_U2F_EMULATED);
             return;
         }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PULL 0/2] Usb 20210901 patches
  2021-09-01  6:53 [PULL 0/2] Usb 20210901 patches Gerd Hoffmann
  2021-09-01  6:53 ` [PULL 1/2] uas: add stream number sanity checks Gerd Hoffmann
  2021-09-01  6:53 ` [PULL 2/2] hw/usb: Fix typo in comments and print Gerd Hoffmann
@ 2021-09-01 16:44 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2021-09-01 16:44 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On Wed, 1 Sept 2021 at 08:01, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit ad22d0583300df420819e6c89b1c022b998fac8a:
>
>   Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.2-20210827' into staging (2021-08-27 11:34:12 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/usb-20210901-pull-request
>
> for you to fetch changes up to ae420c957aff2871b8a1af9cf9ee1a7a75b3552b:
>
>   hw/usb: Fix typo in comments and print (2021-09-01 06:37:13 +0200)
>
> ----------------------------------------------------------------
> usb: bugfixes.
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-01 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01  6:53 [PULL 0/2] Usb 20210901 patches Gerd Hoffmann
2021-09-01  6:53 ` [PULL 1/2] uas: add stream number sanity checks Gerd Hoffmann
2021-09-01  6:53 ` [PULL 2/2] hw/usb: Fix typo in comments and print Gerd Hoffmann
2021-09-01 16:44 ` [PULL 0/2] Usb 20210901 patches Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.