Skip to contentSkip to conversation

hw/usb/hcd-xhci: Turn guest-triggerable abort() into qemu_log_mask()

PATCH Superseded Thomas Huth 2 participants 3 messages Jul 10

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/usb/hcd-xhci: Turn guest-triggerable abort() into qemu_log_mask()

From: Thomas Huth <[email protected]>

The FIXME macros in xhci_alloc_device_streams() can be triggered by a (malicious) guest. Since the macro also contains an abort() statement, this terminates QEMU. Turn the FIXME statements into a qemu_log_mask() instead to avoid that a guest can shoot itself this way.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3784

---
 hw/usb/hcd-xhci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +4 -2
index 2cdab3ba0e4..9ff50d0b7f9 100644
@@ -965,11 +965,13 @@ static TRBCCode xhci_alloc_device_streams(XHCIState *xhci, unsigned int slotid,
          * together and make an usb_device_alloc_streams call per group.
          */
         if (epctxs[i]->nr_pstreams != req_nr_streams) {
-            FIXME("guest streams config not identical for all eps");
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "guest streams config not identical for all eps");
             return CC_RESOURCE_ERROR;
         }
         if (eps[i]->max_streams != dev_max_streams) {
-            FIXME("device streams config not identical for all eps");
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "device streams config not identical for all eps");
             return CC_RESOURCE_ERROR;
         }
     }
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The FIXME macros in xhci_alloc_device_streams() can be triggered by a (malicious) guest. Since the macro also contains an abort() statement, this terminates QEMU. Turn the FIXME statements into a qemu_log_mask() instead to avoid that a guest can shoot itself this way.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3784

---
  hw/usb/hcd-xhci.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +0 -0
index 2cdab3ba0e4..9ff50d0b7f9 100644

hw/usb/hcd-xhci.c static TRBCCode xhci_alloc_device_streams(XHCIState *xhci, unsigned int slotid, · line 969

Quoted 6 lines
hw/usb/hcd-xhci.c +2 -1
@@ -965,11 +965,13 @@ static TRBCCode xhci_alloc_device_streams(XHCIState *xhci, unsigned int slotid,
           * together and make an usb_device_alloc_streams call per group.
           */
          if (epctxs[i]->nr_pstreams != req_nr_streams) {
-            FIXME("guest streams config not identical for all eps");
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "guest streams config not identical for all eps");

With trailing \n:

Quoted 9 lines
hw/usb/hcd-xhci.c +2 -1
              return CC_RESOURCE_ERROR;
          }
          if (eps[i]->max_streams != dev_max_streams) {
-            FIXME("device streams config not identical for all eps");
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "device streams config not identical for all eps");
              return CC_RESOURCE_ERROR;
          }
      }
#2 lore raw
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The FIXME macros in xhci_alloc_device_streams() can be triggered by a (malicious) guest. Since the macro also contains an abort() statement, this terminates QEMU. Turn the FIXME statements into a qemu_log_mask() instead to avoid that a guest can shoot itself this way.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3784

---
  hw/usb/hcd-xhci.c | 6 ++++--

  1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 14 lines

hw/usb/hcd-xhci.c static TRBCCode xhci_alloc_device_streams(XHCIState · line 970

Quoted 12 lines
hw/usb/hcd-xhci.c +2 -1
index 2cdab3ba0e4..9ff50d0b7f9 100644
@@ -965,11 +965,13 @@ static TRBCCode xhci_alloc_device_streams(XHCIState 
 *xhci, unsigned int slotid,
            * together and make an usb_device_alloc_streams call per group.
            */
           if (epctxs[i]->nr_pstreams != req_nr_streams) {
-            FIXME("guest streams config not identical for all eps");
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "guest streams config not identical for all eps");

With trailing \n:

D'oh! Thanks!

I just noticed that I also forgot to add a "Reported-by" line to the description. I'll send a v2...

Quoted 1 line

Thanks!

Thomas