Skip to content
Snippets Groups Projects
  1. May 12, 2021
  2. May 05, 2021
    • Gerd Hoffmann's avatar
      usb: limit combined packets to 1 MiB (CVE-2021-3527) · 05a40b17
      Gerd Hoffmann authored
      
      usb-host and usb-redirect try to batch bulk transfers by combining many
      small usb packets into a single, large transfer request, to reduce the
      overhead and improve performance.
      
      This patch adds a size limit of 1 MiB for those combined packets to
      restrict the host resources the guest can bind that way.
      
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Message-Id: <20210503132915.2335822-6-kraxel@redhat.com>
      05a40b17
  3. May 04, 2021
  4. May 02, 2021
  5. Mar 26, 2021
    • Thomas Huth's avatar
      hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices · db0b0341
      Thomas Huth authored
      
      QEMU crashes with certain targets when trying to show the help
      output of EHCI devices:
      
      $ ./qemu-system-aarch64 -device ich9-usb-ehci1,help
      qemu-system-aarch64: ../../devel/qemu/softmmu/physmem.c:1154: phys_section_add:
       Assertion `map->sections_nb < TARGET_PAGE_SIZE' failed.
      Aborted (core dumped)
      
      This happens because the device is doing things at "instance_init" time
      that should be done at "realize" time instead. So move the related code
      to the realize() function instead. (NB: This now also matches the
      memory_region_del_subregion() calls which are done in usb_ehci_unrealize(),
      and not during finalize()).
      
      Suggested-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20210326095155.1994604-1-thuth@redhat.com>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      db0b0341
    • Philippe Mathieu-Daudé's avatar
      hw/usb/hcd-ehci-sysbus: Free USBPacket on instance finalize() · 2da6e36b
      Philippe Mathieu-Daudé authored
      
      When building with --enable-sanitizers we get:
      
        Direct leak of 32 byte(s) in 2 object(s) allocated from:
            #0 0x5618479ec7cf in malloc (qemu-system-aarch64+0x233b7cf)
            #1 0x7f675745f958 in g_malloc (/lib64/libglib-2.0.so.0+0x58958)
            #2 0x561847f02ca2 in usb_packet_init hw/usb/core.c:531:5
            #3 0x561848df4df4 in usb_ehci_init hw/usb/hcd-ehci.c:2575:5
            #4 0x561847c119ac in ehci_sysbus_init hw/usb/hcd-ehci-sysbus.c:73:5
            #5 0x56184a5bdab8 in object_init_with_type qom/object.c:375:9
            #6 0x56184a5bd955 in object_init_with_type qom/object.c:371:9
            #7 0x56184a5a2bda in object_initialize_with_type qom/object.c:517:5
            #8 0x56184a5a24d5 in object_initialize qom/object.c:536:5
            #9 0x56184a5a2f6c in object_initialize_child_with_propsv qom/object.c:566:5
            #10 0x56184a5a2e60 in object_initialize_child_with_props qom/object.c:549:10
            #11 0x56184a5a3a1e in object_initialize_child_internal qom/object.c:603:5
            #12 0x561849542d18 in npcm7xx_init hw/arm/npcm7xx.c:427:5
      
      Similarly to commit d710e1e7 ("usb: ehci: fix memory leak in
      ehci"), fix by calling usb_ehci_finalize() to free the USBPacket.
      
      Fixes: 7341ea07
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20210323183701.281152-1-f4bug@amsat.org>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      2da6e36b
    • Thomas Huth's avatar
      usb: Remove "-usbdevice ccid" · d2aea775
      Thomas Huth authored
      
      "-usbdevice ccid" was not documented and -usbdevice itself was marked
      as deprecated before QEMU v6.0. And searching for "-usbdevice ccid"
      in the internet does not show any useful results, so likely nobody
      was using the ccid device via the -usbdevice option. Remove it now.
      
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20210311092829.1479051-1-thuth@redhat.com>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      d2aea775
  6. Mar 15, 2021
  7. Mar 09, 2021
  8. Feb 25, 2021
  9. Feb 20, 2021
  10. Feb 17, 2021
    • Gerd Hoffmann's avatar
      usb/pcap: set flag_setup · 6ba5a437
      Gerd Hoffmann authored
      
      Without that wireshark complains about invalid control setup data
      for non-control transfers.
      
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Message-Id: <20210216144939.841873-1-kraxel@redhat.com>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      6ba5a437
    • Nick Rosbrook's avatar
      usb-host: use correct altsetting in usb_host_ep_update · 0dbe4768
      Nick Rosbrook authored
      
      In order to keep track of the alternate setting that should be used for
      a given interface, the USBDevice struct keeps an array of alternate
      setting values, which is indexed by the interface number. In
      usb_host_set_interface, when this array is updated, usb_host_ep_update
      is called as a result. However, when usb_host_ep_update accesses the
      active libusb_config_descriptor, it indexes udev->altsetting with the
      loop variable, rather than the interface number.
      
      With the simple trace backend enable, this behavior can be seen:
      
        [...]
      
        usb_xhci_xfer_start 0.440 pid=1215 xfer=0x5596a4b85930 slotid=0x1 epid=0x1 streamid=0x0
        usb_packet_state_change 1.703 pid=1215 bus=0x1 port=b'1' ep=0x0 p=0x5596a4b85938 o=b'undef' n=b'setup'
        usb_host_req_control 2.269 pid=1215 bus=0x1 addr=0x5 p=0x5596a4b85938 req=0x10b value=0x1 index=0xd
        usb_host_set_interface 0.449 pid=1215 bus=0x1 addr=0x5 interface=0xd alt=0x1
        usb_host_parse_config 2542.648 pid=1215 bus=0x1 addr=0x5 value=0x2 active=0x1
        usb_host_parse_interface 1.804 pid=1215 bus=0x1 addr=0x5 num=0xc alt=0x0 active=0x1
        usb_host_parse_endpoint 2.012 pid=1215 bus=0x1 addr=0x5 ep=0x2 dir=b'in' type=b'int' active=0x1
        usb_host_parse_interface 1.598 pid=1215 bus=0x1 addr=0x5 num=0xd alt=0x0 active=0x1
        usb_host_req_emulated 3.593 pid=1215 bus=0x1 addr=0x5 p=0x5596a4b85938 status=0x0
        usb_packet_state_change 2.550 pid=1215 bus=0x1 port=b'1' ep=0x0 p=0x5596a4b85938 o=b'setup' n=b'complete'
        usb_xhci_xfer_success 4.298 pid=1215 xfer=0x5596a4b85930 bytes=0x0
      
        [...]
      
      In particular, it is seen that although usb_host_set_interface sets the
      alternate setting of interface 0xd to 0x1, usb_host_ep_update uses 0x0
      as the alternate setting due to using the incorrect index to
      udev->altsetting.
      
      Fix this problem by getting the interface number from the active
      libusb_config_descriptor, and then using that as the index to
      udev->altsetting.
      
      Signed-off-by: default avatarNick Rosbrook <rosbrookn@ainfosec.com>
      Message-Id: <20210201213021.500277-1-rosbrookn@ainfosec.com>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      0dbe4768
  11. Jan 27, 2021
    • Kevin Wolf's avatar
      block: Separate blk_is_writable() and blk_supports_write_perm() · 86b1cf32
      Kevin Wolf authored
      Currently, blk_is_read_only() tells whether a given BlockBackend can
      only be used in read-only mode because its root node is read-only. Some
      callers actually try to answer a slightly different question: Is the
      BlockBackend configured to be writable, by taking write permissions on
      the root node?
      
      This can differ, for example, for CD-ROM devices which don't take write
      permissions, but may be backed by a writable image file. scsi-cd allows
      write requests to the drive if blk_is_read_only() returns false.
      However, the write request will immediately run into an assertion
      failure because the write permission is missing.
      
      This patch introduces separate functions for both questions.
      blk_supports_write_perm() answers the question whether the block
      node/image file can support writable devices, whereas blk_is_writable()
      tells whether the BlockBackend is currently configured to be writable.
      
      All calls of blk_is_read_only() are converted to one of the two new
      functions.
      
      Fixes: https://bugs.launchpad.net/bugs/1906693
      
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20210118123448.307825-2-kwolf@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      86b1cf32
  12. Jan 22, 2021
  13. Jan 08, 2021
Loading