1. 17 10月, 2017 4 次提交
  2. 11 10月, 2017 7 次提交
    • A
      usb: usbtest: fix NULL pointer dereference · 7c80f9e4
      Alan Stern 提交于
      If the usbtest driver encounters a device with an IN bulk endpoint but
      no OUT bulk endpoint, it will try to dereference a NULL pointer
      (out->desc.bEndpointAddress).  The problem can be solved by adding a
      missing test.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      7c80f9e4
    • A
      usb: gadget: configfs: Fix memory leak of interface directory data · ff74745e
      Andrew Gabbasov 提交于
      Kmemleak checking configuration reports a memory leak in
      usb_os_desc_prepare_interf_dir function when rndis function
      instance is freed and then allocated again. For example, this
      happens with FunctionFS driver with RNDIS function enabled
      when "ffs-test" test application is run several times in a row.
      
      The data for intermediate "os_desc" group for interface directories
      is allocated as a single VLA chunk and (after a change of default
      groups handling) is not ever freed and actually not stored anywhere
      besides inside a list of default groups of a parent group.
      
      The fix is to make usb_os_desc_prepare_interf_dir function return
      a pointer to allocated data (as a pointer to the first VLA item)
      instead of (an unused) integer and to make the caller component
      (currently the only one is RNDIS function) responsible for storing
      the pointer and freeing the memory when appropriate.
      
      Fixes: 1ae1602d ("configfs: switch ->default groups to a linked list")
      Cc: stable@vger.kernel.org
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      ff74745e
    • A
      usb: gadget: composite: Fix use-after-free in usb_composite_overwrite_options · aec17e1e
      Andrew Gabbasov 提交于
      KASAN enabled configuration reports an error
      
          BUG: KASAN: use-after-free in usb_composite_overwrite_options+...
                      [libcomposite] at addr ...
          Read of size 1 by task ...
      
      when some driver is un-bound and then bound again.
      For example, this happens with FunctionFS driver when "ffs-test"
      test application is run several times in a row.
      
      If the driver has empty manufacturer ID string in initial static data,
      it is then replaced with generated string. After driver unbinding
      the generated string is freed, but the driver data still keep that
      pointer. And if the driver is then bound again, that pointer
      is re-used for string emptiness check.
      
      The fix is to clean up the driver string data upon its unbinding
      to drop the pointer to freed memory.
      
      Fixes: cc2683c3 ("usb: gadget: Provide a default implementation of default manufacturer string")
      Cc: stable@vger.kernel.org
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      aec17e1e
    • D
      usb: misc: usbtest: Fix overflow in usbtest_do_ioctl() · cb84f568
      Dan Carpenter 提交于
      There used to be a test against "if (param->sglen > MAX_SGLEN)" but it
      was removed during a refactor.  It leads to an integer overflow and a
      stack overflow in test_queue() if we try to create a too large urbs[]
      array on the stack.
      
      There is a second integer overflow in test_queue() as well if
      "param->iterations" is too high.  I don't immediately see that it's
      harmful but I've added a check to prevent it and silence the static
      checker warning.
      
      Fixes: 18fc4ebd ("usb: misc: usbtest: Remove timeval usage")
      Acked-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      cb84f568
    • K
      usb: renesas_usbhs: Fix DMAC sequence for receiving zero-length packet · 29c7f3e6
      Kazuya Mizuguchi 提交于
      The DREQE bit of the DnFIFOSEL should be set to 1 after the DE bit of
      USB-DMAC on R-Car SoCs is set to 1 after the USB-DMAC received a
      zero-length packet. Otherwise, a transfer completion interruption
      of USB-DMAC doesn't happen. Even if the driver changes the sequence,
      normal operations (transmit/receive without zero-length packet) will
      not cause any side-effects. So, this patch fixes the sequence anyway.
      Signed-off-by: NKazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
      [shimoda: revise the commit log]
      Fixes: e73a9891 ("usb: renesas_usbhs: add DMAEngine support")
      Cc: <stable@vger.kernel.org> # v3.1+
      Signed-off-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      29c7f3e6
    • A
      USB: dummy-hcd: Fix deadlock caused by disconnect detection · ab219221
      Alan Stern 提交于
      The dummy-hcd driver calls the gadget driver's disconnect callback
      under the wrong conditions.  It should invoke the callback when Vbus
      power is turned off, but instead it does so when the D+ pullup is
      turned off.
      
      This can cause a deadlock in the composite core when a gadget driver
      is unregistered:
      
      [   88.361471] ============================================
      [   88.362014] WARNING: possible recursive locking detected
      [   88.362580] 4.14.0-rc2+ #9 Not tainted
      [   88.363010] --------------------------------------------
      [   88.363561] v4l_id/526 is trying to acquire lock:
      [   88.364062]  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547e03>] composite_disconnect+0x43/0x100 [libcomposite]
      [   88.365051]
      [   88.365051] but task is already holding lock:
      [   88.365826]  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
      [   88.366858]
      [   88.366858] other info that might help us debug this:
      [   88.368301]  Possible unsafe locking scenario:
      [   88.368301]
      [   88.369304]        CPU0
      [   88.369701]        ----
      [   88.370101]   lock(&(&cdev->lock)->rlock);
      [   88.370623]   lock(&(&cdev->lock)->rlock);
      [   88.371145]
      [   88.371145]  *** DEADLOCK ***
      [   88.371145]
      [   88.372211]  May be due to missing lock nesting notation
      [   88.372211]
      [   88.373191] 2 locks held by v4l_id/526:
      [   88.373715]  #0:  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
      [   88.374814]  #1:  (&(&dum_hcd->dum->lock)->rlock){....}, at: [<ffffffffa05bd48d>] dummy_pullup+0x7d/0xf0 [dummy_hcd]
      [   88.376289]
      [   88.376289] stack backtrace:
      [   88.377726] CPU: 0 PID: 526 Comm: v4l_id Not tainted 4.14.0-rc2+ #9
      [   88.378557] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
      [   88.379504] Call Trace:
      [   88.380019]  dump_stack+0x86/0xc7
      [   88.380605]  __lock_acquire+0x841/0x1120
      [   88.381252]  lock_acquire+0xd5/0x1c0
      [   88.381865]  ? composite_disconnect+0x43/0x100 [libcomposite]
      [   88.382668]  _raw_spin_lock_irqsave+0x40/0x54
      [   88.383357]  ? composite_disconnect+0x43/0x100 [libcomposite]
      [   88.384290]  composite_disconnect+0x43/0x100 [libcomposite]
      [   88.385490]  set_link_state+0x2d4/0x3c0 [dummy_hcd]
      [   88.386436]  dummy_pullup+0xa7/0xf0 [dummy_hcd]
      [   88.387195]  usb_gadget_disconnect+0xd8/0x160 [udc_core]
      [   88.387990]  usb_gadget_deactivate+0xd3/0x160 [udc_core]
      [   88.388793]  usb_function_deactivate+0x64/0x80 [libcomposite]
      [   88.389628]  uvc_function_disconnect+0x1e/0x40 [usb_f_uvc]
      
      This patch changes the code to test the port-power status bit rather
      than the port-connect status bit when deciding whether to isue the
      callback.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NDavid Tulloh <david@tulloh.id.au>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      ab219221
    • J
      usb: phy: tegra: Fix phy suspend for UDC · 203f44c4
      Jon Hunter 提交于
      Commit dfebb5f4 ("usb: chipidea: Add support for Tegra20/30/114/124")
      added UDC support for Tegra but with UDC support enabled, is was found
      that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.
      
      The hang occurred during the suspend of the USB PHY when the Tegra PHY
      driver attempted to disable the PHY clock. The problem is that before
      the Tegra PHY driver is suspended, the chipidea driver already disabled
      the PHY clock and when the Tegra PHY driver suspended, it could not read
      DEVLC register and caused the device to hang.
      
      The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
      the chipidea UDC driver and so simply removing the disabling of the PHY
      clock from the USB PHY driver would not work for the Tegra EHCI driver.
      Fortunately, the status of the USB PHY clock can be read from the
      USB_SUSP_CTRL register and therefore, to workaround this issue, simply
      poll the register prior to disabling the clock in USB PHY driver to see
      if clock gating has already been initiated. Please note that it can take
      a few uS for the clock to disable and so simply reading this status
      register once on entry is not sufficient.
      
      Similarly when turning on the PHY clock, it is possible that the clock
      is already enabled or in the process of being enabled, and so check for
      this when enabling the PHY.
      
      Please note that no issues are seen with Tegra20 because it has a slightly
      different PHY to Tegra30/114/124.
      
      Fixes: dfebb5f4 ("usb: chipidea: Add support for Tegra20/30/114/124")
      Reviewed-by: NDmitry Osipenko <digetx@gmail.com>
      Tested-by: NDmitry Osipenko <digetx@gmail.com>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      203f44c4
  3. 09 10月, 2017 2 次提交
  4. 05 10月, 2017 13 次提交
  5. 04 10月, 2017 14 次提交