1. 20 3月, 2019 4 次提交
    • R
      USB: gadget: f_hid: fix deadlock in f_hidg_write() · 072684e8
      Radoslav Gerganov 提交于
      In f_hidg_write() the write_spinlock is acquired before calling
      usb_ep_queue() which causes a deadlock when dummy_hcd is being used.
      This is because dummy_queue() callbacks into f_hidg_req_complete() which
      tries to acquire the same spinlock. This is (part of) the backtrace when
      the deadlock occurs:
      
        0xffffffffc06b1410 in f_hidg_req_complete
        0xffffffffc06a590a in usb_gadget_giveback_request
        0xffffffffc06cfff2 in dummy_queue
        0xffffffffc06a4b96 in usb_ep_queue
        0xffffffffc06b1eb6 in f_hidg_write
        0xffffffff8127730b in __vfs_write
        0xffffffff812774d1 in vfs_write
        0xffffffff81277725 in SYSC_write
      
      Fix this by releasing the write_spinlock before calling usb_ep_queue()
      Reviewed-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      Tested-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: stable@vger.kernel.org # 4.11+
      Fixes: 749494b6 ("usb: gadget: f_hid: fix: Move IN request allocation to set_alt()")
      Signed-off-by: NRadoslav Gerganov <rgerganov@vmware.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      072684e8
    • G
      usb: gadget: net2272: Fix net2272_dequeue() · 091dacc3
      Guido Kiener 提交于
      Restore the status of ep->stopped in function net2272_dequeue().
      
      When the given request is not found in the endpoint queue
      the function returns -EINVAL without restoring the state of
      ep->stopped. Thus the endpoint keeps blocked and does not transfer
      any data anymore.
      
      This fix is only compile-tested, since we do not have a
      corresponding hardware. An analogous fix was tested in the sibling
      driver. See "usb: gadget: net2280: Fix net2280_dequeue()"
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGuido Kiener <guido.kiener@rohde-schwarz.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      091dacc3
    • G
      usb: gadget: net2280: Fix net2280_dequeue() · f1d3fba1
      Guido Kiener 提交于
      When a request must be dequeued with net2280_dequeue() e.g. due
      to a device clear action and the same request is finished by the
      function scan_dma_completions() then the function net2280_dequeue()
      does not find the request in the following search loop and
      returns the error -EINVAL without restoring the status ep->stopped.
      Thus the endpoint keeps blocked and does not receive any data
      anymore.
      This fix restores the status and does not issue an error message.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGuido Kiener <guido.kiener@rohde-schwarz.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      f1d3fba1
    • G
      usb: gadget: net2280: Fix overrun of OUT messages · 9d6a54c1
      Guido Kiener 提交于
      The OUT endpoint normally blocks (NAK) subsequent packets when a
      short packet was received and returns an incomplete queue entry to
      the gadget driver. Thereby the gadget driver can detect a short packet
      when reading queue entries with a length that is not equal to a
      multiple of packet size.
      
      The start_queue() function enables receiving OUT packets regardless of
      the content of the OUT FIFO. This results in a race: With the current
      code, it's possible that the "!ep->is_in && (readl(&ep->regs->ep_stat)
      & BIT(NAK_OUT_PACKETS))" test in start_dma() will fail, then a short
      packet will be received, and then start_queue() will call
      stop_out_naking(). That's what we don't want (OUT naking gets turned
      off while there is data in the FIFO) because then the next driver
      request might receive a mixture of old and new packets.
      
      With the patch, this race can't occur because the FIFO's state is
      tested after we know that OUT naking is already turned on, and OUT
      naking is stopped only when both of the conditions are met.  This
      ensures that all received data is delivered to the gadget driver,
      which can detect a short packet now before new packets are appended
      to the last short packet.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGuido Kiener <guido.kiener@rohde-schwarz.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      9d6a54c1
  2. 11 2月, 2019 4 次提交
    • C
      fotg210-udc: pass struct device to DMA API functions · e26bdb01
      Christoph Hellwig 提交于
      The DMA API generally relies on a struct device to work properly, and
      only barely works without one for legacy reasons.  Pass the easily
      available struct device from the platform_device to remedy this.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      e26bdb01
    • C
      fotg210-udc: remove a bogus dma_sync_single_for_device call · 8c7ffa5e
      Christoph Hellwig 提交于
      dma_map_single already transfers ownership to the device.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      8c7ffa5e
    • A
      usb: gadget: Change Andrzej Pietrasiewicz's e-mail address · 1b4a3b51
      Andrzej Pietrasiewicz 提交于
      My @samusung.com address is going to cease existing soon, so change it to
      an address which can actually be used to contact me.
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      1b4a3b51
    • J
      usb: f_fs: Avoid crash due to out-of-scope stack ptr access · 54f64d5c
      John Stultz 提交于
      Since the 5.0 merge window opened, I've been seeing frequent
      crashes on suspend and reboot with the trace:
      
      [   36.911170] Unable to handle kernel paging request at virtual address ffffff801153d660
      [   36.912769] Unable to handle kernel paging request at virtual address ffffff800004b564
      ...
      [   36.950666] Call trace:
      [   36.950670]  queued_spin_lock_slowpath+0x1cc/0x2c8
      [   36.950681]  _raw_spin_lock_irqsave+0x64/0x78
      [   36.950692]  complete+0x28/0x70
      [   36.950703]  ffs_epfile_io_complete+0x3c/0x50
      [   36.950713]  usb_gadget_giveback_request+0x34/0x108
      [   36.950721]  dwc3_gadget_giveback+0x50/0x68
      [   36.950723]  dwc3_thread_interrupt+0x358/0x1488
      [   36.950731]  irq_thread_fn+0x30/0x88
      [   36.950734]  irq_thread+0x114/0x1b0
      [   36.950739]  kthread+0x104/0x130
      [   36.950747]  ret_from_fork+0x10/0x1c
      
      I isolated this down to in ffs_epfile_io():
      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/function/f_fs.c#n1065
      
      Where the completion done is setup on the stack:
        DECLARE_COMPLETION_ONSTACK(done);
      
      Then later we setup a request and queue it, and wait for it:
        if (unlikely(wait_for_completion_interruptible(&done))) {
          /*
          * To avoid race condition with ffs_epfile_io_complete,
          * dequeue the request first then check
          * status. usb_ep_dequeue API should guarantee no race
          * condition with req->complete callback.
          */
          usb_ep_dequeue(ep->ep, req);
          interrupted = ep->status < 0;
        }
      
      The problem is, that we end up being interrupted, dequeue the
      request, and exit.
      
      But then the irq triggers and we try calling complete() on the
      context pointer which points to now random stack space, which
      results in the panic.
      
      Alan Stern pointed out there is a bug here, in that the snippet
      above "assumes that usb_ep_dequeue() waits until the request has
      been completed." And that:
      
          wait_for_completion(&done);
      
      Is needed right after the usb_ep_dequeue().
      
      Thus this patch implements that change. With it I no longer see
      the crashes on suspend or reboot.
      
      This issue seems to have been uncovered by behavioral changes in
      the dwc3 driver in commit fec9095b ("usb: dwc3: gadget:
      remove wait_end_transfer").
      
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Zeng Tao <prime.zeng@hisilicon.com>
      Cc: Jack Pham <jackp@codeaurora.org>
      Cc: Thinh Nguyen <thinh.nguyen@synopsys.com>
      Cc: Chen Yu <chenyu56@huawei.com>
      Cc: Jerry Zhang <zhangjerry@google.com>
      Cc: Lars-Peter Clausen <lars@metafoo.de>
      Cc: Vincent Pelletier <plr.vincent@gmail.com>
      Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linux USB List <linux-usb@vger.kernel.org>
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      54f64d5c
  3. 07 2月, 2019 4 次提交
  4. 06 2月, 2019 2 次提交
  5. 05 2月, 2019 1 次提交
  6. 02 2月, 2019 1 次提交
  7. 28 1月, 2019 7 次提交
  8. 22 1月, 2019 1 次提交
  9. 14 1月, 2019 1 次提交
  10. 08 1月, 2019 2 次提交
  11. 04 1月, 2019 1 次提交
    • L
      Remove 'type' argument from access_ok() function · 96d4f267
      Linus Torvalds 提交于
      Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
      of the user address range verification function since we got rid of the
      old racy i386-only code to walk page tables by hand.
      
      It existed because the original 80386 would not honor the write protect
      bit when in kernel mode, so you had to do COW by hand before doing any
      user access.  But we haven't supported that in a long time, and these
      days the 'type' argument is a purely historical artifact.
      
      A discussion about extending 'user_access_begin()' to do the range
      checking resulted this patch, because there is no way we're going to
      move the old VERIFY_xyz interface to that model.  And it's best done at
      the end of the merge window when I've done most of my merges, so let's
      just get this done once and for all.
      
      This patch was mostly done with a sed-script, with manual fix-ups for
      the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
      
      There were a couple of notable cases:
      
       - csky still had the old "verify_area()" name as an alias.
      
       - the iter_iov code had magical hardcoded knowledge of the actual
         values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
         really used it)
      
       - microblaze used the type argument for a debug printout
      
      but other than those oddities this should be a total no-op patch.
      
      I tried to fix up all architectures, did fairly extensive grepping for
      access_ok() uses, and the changes are trivial, but I may have missed
      something.  Any missed conversion should be trivially fixable, though.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      96d4f267
  12. 14 12月, 2018 1 次提交
  13. 07 12月, 2018 1 次提交
  14. 29 11月, 2018 2 次提交
  15. 28 11月, 2018 1 次提交
    • M
      usb: gadget: u_ether: fix unsafe list iteration · c9287fa6
      Marek Szyprowski 提交于
      list_for_each_entry_safe() is not safe for deleting entries from the
      list if the spin lock, which protects it, is released and reacquired during
      the list iteration. Fix this issue by replacing this construction with
      a simple check if list is empty and removing the first entry in each
      iteration. This is almost equivalent to a revert of the commit mentioned in
      the Fixes: tag.
      
      This patch fixes following issue:
      --->8---
      Unable to handle kernel NULL pointer dereference at virtual address 00000104
      pgd = (ptrval)
      [00000104] *pgd=00000000
      Internal error: Oops: 817 [#1] PREEMPT SMP ARM
      Modules linked in:
      CPU: 1 PID: 84 Comm: kworker/1:1 Not tainted 4.20.0-rc2-next-20181114-00009-g8266b35ec404 #1061
      Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      Workqueue: events eth_work
      PC is at rx_fill+0x60/0xac
      LR is at _raw_spin_lock_irqsave+0x50/0x5c
      pc : [<c065fee0>]    lr : [<c0a056b8>]    psr: 80000093
      sp : ee7fbee8  ip : 00000100  fp : 00000000
      r10: 006000c0  r9 : c10b0ab0  r8 : ee7eb5c0
      r7 : ee7eb614  r6 : ee7eb5ec  r5 : 000000dc  r4 : ee12ac00
      r3 : ee12ac24  r2 : 00000200  r1 : 60000013  r0 : ee7eb5ec
      Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
      Control: 10c5387d  Table: 6d5dc04a  DAC: 00000051
      Process kworker/1:1 (pid: 84, stack limit = 0x(ptrval))
      Stack: (0xee7fbee8 to 0xee7fc000)
      ...
      [<c065fee0>] (rx_fill) from [<c0143b7c>] (process_one_work+0x200/0x738)
      [<c0143b7c>] (process_one_work) from [<c0144118>] (worker_thread+0x2c/0x4c8)
      [<c0144118>] (worker_thread) from [<c014a8a4>] (kthread+0x128/0x164)
      [<c014a8a4>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
      Exception stack(0xee7fbfb0 to 0xee7fbff8)
      ...
      ---[ end trace 64480bc835eba7d6 ]---
      
      Fixes: fea14e68 ("usb: gadget: u_ether: use better list accessors")
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      c9287fa6
  16. 26 11月, 2018 7 次提交