1. 11 10月, 2017 1 次提交
    • 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
  2. 28 9月, 2017 3 次提交
    • A
      USB: dummy-hcd: Fix erroneous synchronization change · 7dbd8f4c
      Alan Stern 提交于
      A recent change to the synchronization in dummy-hcd was incorrect.
      The issue was that dummy_udc_stop() contained no locking and therefore
      could race with various gadget driver callbacks, and the fix was to
      add locking and issue the callbacks with the private spinlock held.
      
      UDC drivers aren't supposed to do this.  Gadget driver callback
      routines are allowed to invoke functions in the UDC driver, and these
      functions will generally try to acquire the private spinlock.  This
      would deadlock the driver.
      
      The correct solution is to drop the spinlock before issuing callbacks,
      and avoid races by emulating the synchronize_irq() call that all real
      UDC drivers must perform in their ->udc_stop() routines after
      disabling interrupts.  This involves adding a flag to dummy-hcd's
      private structure to keep track of whether interrupts are supposed to
      be enabled, and adding a counter to keep track of ongoing callbacks so
      that dummy_udc_stop() can wait for them all to finish.
      
      A real UDC driver won't receive disconnect, reset, suspend, resume, or
      setup events once it has disabled interrupts.  dummy-hcd will receive
      them but won't try to issue any gadget driver callbacks, which should
      be just as good.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Fixes: f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks")
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      7dbd8f4c
    • A
      USB: dummy-hcd: fix infinite-loop resubmission bug · 0173a68b
      Alan Stern 提交于
      The dummy-hcd HCD/UDC emulator tries not to do too much work during
      each timer interrupt.  But it doesn't try very hard; currently all
      it does is limit the total amount of bulk data transferred.  Other
      transfer types aren't limited, and URBs that transfer no data (because
      of an error, perhaps) don't count toward the limit, even though on a
      real USB bus they would consume at least a minimum overhead.
      
      This means it's possible to get the driver stuck in an infinite loop,
      for example, if the host class driver resubmits an URB every time it
      completes (which is common for interrupt URBs).  Each time the URB is
      resubmitted it gets added to the end of the pending-URBs list, and
      dummy-hcd doesn't stop until that list is empty.  Andrey Konovalov was
      able to trigger this failure mode using the syzkaller fuzzer.
      
      This patch fixes the infinite-loop problem by restricting the URBs
      handled during each timer interrupt to those that were already on the
      pending list when the interrupt routine started.  Newly added URBs
      won't be processed until the next timer interrupt.  The problem of
      properly accounting for non-bulk bandwidth (as well as packet and
      transaction overhead) is not addressed here.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      0173a68b
    • A
      USB: dummy-hcd: fix connection failures (wrong speed) · fe659bcc
      Alan Stern 提交于
      The dummy-hcd UDC driver is not careful about the way it handles
      connection speeds.  It ignores the module parameter that is supposed
      to govern the maximum connection speed and it doesn't set the HCD
      flags properly for the case where it ends up running at full speed.
      
      The result is that in many cases, gadget enumeration over dummy-hcd
      fails because the bMaxPacketSize byte in the device descriptor is set
      incorrectly.  For example, the default settings call for a high-speed
      connection, but the maxpacket value for ep0 ends up being set for a
      Super-Speed connection.
      
      This patch fixes the problem by initializing the gadget's max_speed
      and the HCD flags correctly.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      fe659bcc
  3. 20 9月, 2017 1 次提交
    • A
      usb: gadget: dummy: fix nonsensical comparisons · 7661ca09
      Arnd Bergmann 提交于
      gcc-8 points out two comparisons that are clearly bogus
      and almost certainly not what the author intended to write:
      
      drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed':
      drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
               USB_PORT_STAT_ENABLE) == 1 &&
                                     ^~
      drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
            USB_SS_PORT_LS_U0) == 1 &&
                               ^~
      
      I looked at the code for a bit and came up with a change that makes
      it look like what the author probably meant here. This makes it
      look reasonable to me and to gcc, shutting up the warning.
      
      It does of course change behavior as the two conditions are actually
      evaluated rather than being hardcoded to false, and I have made no
      attempt at verifying that the changed logic makes sense in the context
      of a USB HCD, so that part needs to be reviewed carefully.
      
      Fixes: 1cd8fd28 ("usb: gadget: dummy_hcd: add SuperSpeed support")
      Cc: Tatyana Brokhman <tlinder@codeaurora.org>
      Cc: Felipe Balbi <balbi@kernel.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      7661ca09
  4. 15 8月, 2017 1 次提交
  5. 16 6月, 2017 1 次提交
    • A
      USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks · f16443a0
      Alan Stern 提交于
      Using the syzkaller kernel fuzzer, Andrey Konovalov generated the
      following error in gadgetfs:
      
      > BUG: KASAN: use-after-free in __lock_acquire+0x3069/0x3690
      > kernel/locking/lockdep.c:3246
      > Read of size 8 at addr ffff88003a2bdaf8 by task kworker/3:1/903
      >
      > CPU: 3 PID: 903 Comm: kworker/3:1 Not tainted 4.12.0-rc4+ #35
      > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
      > Workqueue: usb_hub_wq hub_event
      > Call Trace:
      >  __dump_stack lib/dump_stack.c:16 [inline]
      >  dump_stack+0x292/0x395 lib/dump_stack.c:52
      >  print_address_description+0x78/0x280 mm/kasan/report.c:252
      >  kasan_report_error mm/kasan/report.c:351 [inline]
      >  kasan_report+0x230/0x340 mm/kasan/report.c:408
      >  __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:429
      >  __lock_acquire+0x3069/0x3690 kernel/locking/lockdep.c:3246
      >  lock_acquire+0x22d/0x560 kernel/locking/lockdep.c:3855
      >  __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
      >  _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151
      >  spin_lock include/linux/spinlock.h:299 [inline]
      >  gadgetfs_suspend+0x89/0x130 drivers/usb/gadget/legacy/inode.c:1682
      >  set_link_state+0x88e/0xae0 drivers/usb/gadget/udc/dummy_hcd.c:455
      >  dummy_hub_control+0xd7e/0x1fb0 drivers/usb/gadget/udc/dummy_hcd.c:2074
      >  rh_call_control drivers/usb/core/hcd.c:689 [inline]
      >  rh_urb_enqueue drivers/usb/core/hcd.c:846 [inline]
      >  usb_hcd_submit_urb+0x92f/0x20b0 drivers/usb/core/hcd.c:1650
      >  usb_submit_urb+0x8b2/0x12c0 drivers/usb/core/urb.c:542
      >  usb_start_wait_urb+0x148/0x5b0 drivers/usb/core/message.c:56
      >  usb_internal_control_msg drivers/usb/core/message.c:100 [inline]
      >  usb_control_msg+0x341/0x4d0 drivers/usb/core/message.c:151
      >  usb_clear_port_feature+0x74/0xa0 drivers/usb/core/hub.c:412
      >  hub_port_disable+0x123/0x510 drivers/usb/core/hub.c:4177
      >  hub_port_init+0x1ed/0x2940 drivers/usb/core/hub.c:4648
      >  hub_port_connect drivers/usb/core/hub.c:4826 [inline]
      >  hub_port_connect_change drivers/usb/core/hub.c:4999 [inline]
      >  port_event drivers/usb/core/hub.c:5105 [inline]
      >  hub_event+0x1ae1/0x3d40 drivers/usb/core/hub.c:5185
      >  process_one_work+0xc08/0x1bd0 kernel/workqueue.c:2097
      >  process_scheduled_works kernel/workqueue.c:2157 [inline]
      >  worker_thread+0xb2b/0x1860 kernel/workqueue.c:2233
      >  kthread+0x363/0x440 kernel/kthread.c:231
      >  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:424
      >
      > Allocated by task 9958:
      >  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
      >  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
      >  set_track mm/kasan/kasan.c:525 [inline]
      >  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:617
      >  kmem_cache_alloc_trace+0x87/0x280 mm/slub.c:2745
      >  kmalloc include/linux/slab.h:492 [inline]
      >  kzalloc include/linux/slab.h:665 [inline]
      >  dev_new drivers/usb/gadget/legacy/inode.c:170 [inline]
      >  gadgetfs_fill_super+0x24f/0x540 drivers/usb/gadget/legacy/inode.c:1993
      >  mount_single+0xf6/0x160 fs/super.c:1192
      >  gadgetfs_mount+0x31/0x40 drivers/usb/gadget/legacy/inode.c:2019
      >  mount_fs+0x9c/0x2d0 fs/super.c:1223
      >  vfs_kern_mount.part.25+0xcb/0x490 fs/namespace.c:976
      >  vfs_kern_mount fs/namespace.c:2509 [inline]
      >  do_new_mount fs/namespace.c:2512 [inline]
      >  do_mount+0x41b/0x2d90 fs/namespace.c:2834
      >  SYSC_mount fs/namespace.c:3050 [inline]
      >  SyS_mount+0xb0/0x120 fs/namespace.c:3027
      >  entry_SYSCALL_64_fastpath+0x1f/0xbe
      >
      > Freed by task 9960:
      >  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
      >  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
      >  set_track mm/kasan/kasan.c:525 [inline]
      >  kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:590
      >  slab_free_hook mm/slub.c:1357 [inline]
      >  slab_free_freelist_hook mm/slub.c:1379 [inline]
      >  slab_free mm/slub.c:2961 [inline]
      >  kfree+0xed/0x2b0 mm/slub.c:3882
      >  put_dev+0x124/0x160 drivers/usb/gadget/legacy/inode.c:163
      >  gadgetfs_kill_sb+0x33/0x60 drivers/usb/gadget/legacy/inode.c:2027
      >  deactivate_locked_super+0x8d/0xd0 fs/super.c:309
      >  deactivate_super+0x21e/0x310 fs/super.c:340
      >  cleanup_mnt+0xb7/0x150 fs/namespace.c:1112
      >  __cleanup_mnt+0x1b/0x20 fs/namespace.c:1119
      >  task_work_run+0x1a0/0x280 kernel/task_work.c:116
      >  exit_task_work include/linux/task_work.h:21 [inline]
      >  do_exit+0x18a8/0x2820 kernel/exit.c:878
      >  do_group_exit+0x14e/0x420 kernel/exit.c:982
      >  get_signal+0x784/0x1780 kernel/signal.c:2318
      >  do_signal+0xd7/0x2130 arch/x86/kernel/signal.c:808
      >  exit_to_usermode_loop+0x1ac/0x240 arch/x86/entry/common.c:157
      >  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
      >  syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263
      >  entry_SYSCALL_64_fastpath+0xbc/0xbe
      >
      > The buggy address belongs to the object at ffff88003a2bdae0
      >  which belongs to the cache kmalloc-1024 of size 1024
      > The buggy address is located 24 bytes inside of
      >  1024-byte region [ffff88003a2bdae0, ffff88003a2bdee0)
      > The buggy address belongs to the page:
      > page:ffffea0000e8ae00 count:1 mapcount:0 mapping:          (null)
      > index:0x0 compound_mapcount: 0
      > flags: 0x100000000008100(slab|head)
      > raw: 0100000000008100 0000000000000000 0000000000000000 0000000100170017
      > raw: ffffea0000ed3020 ffffea0000f5f820 ffff88003e80efc0 0000000000000000
      > page dumped because: kasan: bad access detected
      >
      > Memory state around the buggy address:
      >  ffff88003a2bd980: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >  ffff88003a2bda00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      > >ffff88003a2bda80: fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb fb
      >                                                                 ^
      >  ffff88003a2bdb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      >  ffff88003a2bdb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      > ==================================================================
      
      What this means is that the gadgetfs_suspend() routine was trying to
      access dev->lock after it had been deallocated.  The root cause is a
      race in the dummy_hcd driver; the dummy_udc_stop() routine can race
      with the rest of the driver because it contains no locking.  And even
      when proper locking is added, it can still race with the
      set_link_state() function because that function incorrectly drops the
      private spinlock before invoking any gadget driver callbacks.
      
      The result of this race, as seen above, is that set_link_state() can
      invoke a callback in gadgetfs even after gadgetfs has been unbound
      from dummy_hcd's UDC and its private data structures have been
      deallocated.
      
      include/linux/usb/gadget.h documents that the ->reset, ->disconnect,
      ->suspend, and ->resume callbacks may be invoked in interrupt context.
      In general this is necessary, to prevent races with gadget driver
      removal.  This patch fixes dummy_hcd to retain the spinlock across
      these calls, and it adds a spinlock acquisition to dummy_udc_stop() to
      prevent the race.
      
      The net2280 driver makes the same mistake of dropping the private
      spinlock for its ->disconnect and ->reset callback invocations.  The
      patch fixes it too.
      
      Lastly, since gadgetfs_suspend() may be invoked in interrupt context,
      it cannot assume that interrupts are enabled when it runs.  It must
      use spin_lock_irqsave() instead of spin_lock_irq().  The patch fixes
      that bug as well.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: NAndrey Konovalov <andreyknvl@google.com>
      CC: <stable@vger.kernel.org>
      Acked-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f16443a0
  6. 13 6月, 2017 1 次提交
  7. 17 5月, 2017 1 次提交
  8. 11 4月, 2017 1 次提交
  9. 06 3月, 2017 1 次提交
    • P
      usb: gadget: dummy_hcd: clear usb_gadget region before registration · 5bbc8526
      Peter Chen 提交于
      When the user does device unbind and rebind test, the kernel will
      show below dump due to usb_gadget memory region is dirty after unbind.
      Clear usb_gadget region for every new probe.
      
      root@imx6qdlsolo:/sys/bus/platform/drivers/dummy_udc# echo dummy_udc.0 > bind
      [  102.523312] kobject (eddd78b0): tried to init an initialized object, something is seriously wrong.
      [  102.532447] CPU: 0 PID: 734 Comm: sh Not tainted 4.10.0-rc7-00872-g1b2b8e9 #1298
      [  102.539866] Hardware name: Freescale i.MX6 SoloX (Device Tree)
      [  102.545717] Backtrace:
      [  102.548225] [<c010d090>] (dump_backtrace) from [<c010d338>] (show_stack+0x18/0x1c)
      [  102.555822]  r7:ede34000 r6:60010013 r5:00000000 r4:c0f29418
      [  102.561512] [<c010d320>] (show_stack) from [<c040c2a4>] (dump_stack+0xb4/0xe8)
      [  102.568764] [<c040c1f0>] (dump_stack) from [<c040e6d4>] (kobject_init+0x80/0x9c)
      [  102.576187]  r10:0000001f r9:eddd7000 r8:eeaf8c10 r7:eddd78a8 r6:c177891c r5:c0f3b060
      [  102.584036]  r4:eddd78b0 r3:00000000
      [  102.587641] [<c040e654>] (kobject_init) from [<c05359a4>] (device_initialize+0x28/0xf8)
      [  102.595665]  r5:eebc4800 r4:eddd78a8
      [  102.599268] [<c053597c>] (device_initialize) from [<c05382ac>] (device_register+0x14/0x20)
      [  102.607556]  r7:eddd78a8 r6:00000000 r5:eebc4800 r4:eddd78a8
      [  102.613256] [<c0538298>] (device_register) from [<c0668ef4>] (usb_add_gadget_udc_release+0x8c/0x1ec)
      [  102.622410]  r5:eebc4800 r4:eddd7860
      [  102.626015] [<c0668e68>] (usb_add_gadget_udc_release) from [<c0669068>] (usb_add_gadget_udc+0x14/0x18)
      [  102.635351]  r10:0000001f r9:eddd7000 r8:eddd788c r7:bf003770 r6:eddd77f8 r5:eddd7818
      [  102.643198]  r4:eddd785c r3:eddd7b24
      [  102.646834] [<c0669054>] (usb_add_gadget_udc) from [<bf003428>] (dummy_udc_probe+0x170/0x1c4 [dummy_hcd])
      [  102.656458] [<bf0032b8>] (dummy_udc_probe [dummy_hcd]) from [<c053d114>] (platform_drv_probe+0x54/0xb8)
      [  102.665881]  r10:00000008 r9:c1778960 r8:bf004128 r7:fffffdfb r6:bf004128 r5:eeaf8c10
      [  102.673727]  r4:eeaf8c10
      [  102.676293] [<c053d0c0>] (platform_drv_probe) from [<c053b160>] (driver_probe_device+0x264/0x474)
      [  102.685186]  r7:00000000 r6:00000000 r5:c1778960 r4:eeaf8c10
      [  102.690876] [<c053aefc>] (driver_probe_device) from [<c05397c4>] (bind_store+0xb8/0x14c)
      [  102.698994]  r10:eeb3bb4c r9:ede34000 r8:0000000c r7:eeaf8c44 r6:bf004128 r5:c0f3b668
      [  102.706840]  r4:eeaf8c10
      [  102.709402] [<c053970c>] (bind_store) from [<c0538ca8>] (drv_attr_store+0x28/0x34)
      [  102.716998]  r9:ede34000 r8:00000000 r7:ee3863c0 r6:ee3863c0 r5:c0538c80 r4:c053970c
      [  102.724776] [<c0538c80>] (drv_attr_store) from [<c029c930>] (sysfs_kf_write+0x50/0x54)
      [  102.732711]  r5:c0538c80 r4:0000000c
      [  102.736313] [<c029c8e0>] (sysfs_kf_write) from [<c029be84>] (kernfs_fop_write+0x100/0x214)
      [  102.744599]  r7:ee3863c0 r6:eeb3bb40 r5:00000000 r4:00000000
      [  102.750287] [<c029bd84>] (kernfs_fop_write) from [<c0222dd8>] (__vfs_write+0x34/0x120)
      [  102.758231]  r10:00000000 r9:ede34000 r8:c0108bc4 r7:0000000c r6:ede35f80 r5:c029bd84
      [  102.766077]  r4:ee223780
      [  102.768638] [<c0222da4>] (__vfs_write) from [<c0224678>] (vfs_write+0xa8/0x170)
      [  102.775974]  r9:ede34000 r8:c0108bc4 r7:ede35f80 r6:01861cb0 r5:ee223780 r4:0000000c
      [  102.783743] [<c02245d0>] (vfs_write) from [<c0225498>] (SyS_write+0x4c/0xa8)
      [  102.790818]  r9:ede34000 r8:c0108bc4 r7:0000000c r6:01861cb0 r5:ee223780 r4:ee223780
      [  102.798595] [<c022544c>] (SyS_write) from [<c0108a20>] (ret_fast_syscall+0x0/0x1c)
      [  102.806188]  r7:00000004 r6:b6e83d58 r5:01861cb0 r4:0000000c
      
      Fixes: 90fccb52 ("usb: gadget: Gadget directory cleanup - group UDC drivers")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      Tested-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Reported-by: NFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      5bbc8526
  10. 02 1月, 2017 1 次提交
    • A
      USB: dummy-hcd: fix bug in stop_activity (handle ep0) · bcdbeb84
      Alan Stern 提交于
      The stop_activity() routine in dummy-hcd is supposed to unlink all
      active requests for every endpoint, among other things.  But it
      doesn't handle ep0.  As a result, fuzz testing can generate a WARNING
      like the following:
      
      WARNING: CPU: 0 PID: 4410 at drivers/usb/gadget/udc/dummy_hcd.c:672 dummy_free_request+0x153/0x170
      Modules linked in:
      CPU: 0 PID: 4410 Comm: syz-executor Not tainted 4.9.0-rc7+ #32
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
       ffff88006a64ed10 ffffffff81f96b8a ffffffff41b58ab3 1ffff1000d4c9d35
       ffffed000d4c9d2d ffff880065f8ac00 0000000041b58ab3 ffffffff8598b510
       ffffffff81f968f8 0000000041b58ab3 ffffffff859410e0 ffffffff813f0590
      Call Trace:
       [<     inline     >] __dump_stack lib/dump_stack.c:15
       [<ffffffff81f96b8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51
       [<ffffffff812b808f>] __warn+0x19f/0x1e0 kernel/panic.c:550
       [<ffffffff812b831c>] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585
       [<ffffffff830fcb13>] dummy_free_request+0x153/0x170 drivers/usb/gadget/udc/dummy_hcd.c:672
       [<ffffffff830ed1b0>] usb_ep_free_request+0xc0/0x420 drivers/usb/gadget/udc/core.c:195
       [<ffffffff83225031>] gadgetfs_unbind+0x131/0x190 drivers/usb/gadget/legacy/inode.c:1612
       [<ffffffff830ebd8f>] usb_gadget_remove_driver+0x10f/0x2b0 drivers/usb/gadget/udc/core.c:1228
       [<ffffffff830ec084>] usb_gadget_unregister_driver+0x154/0x240 drivers/usb/gadget/udc/core.c:1357
      
      This patch fixes the problem by iterating over all the endpoints in
      the driver's ep array instead of iterating over the gadget's ep_list,
      which explicitly leaves out ep0.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      bcdbeb84
  11. 03 11月, 2016 2 次提交
  12. 21 6月, 2016 1 次提交
  13. 27 9月, 2015 1 次提交
  14. 22 9月, 2015 4 次提交
  15. 05 8月, 2015 1 次提交
  16. 04 4月, 2015 1 次提交
  17. 11 3月, 2015 1 次提交
  18. 30 1月, 2015 1 次提交
  19. 25 1月, 2015 1 次提交
  20. 20 1月, 2015 1 次提交
  21. 11 11月, 2014 1 次提交
  22. 04 11月, 2014 4 次提交
  23. 20 10月, 2014 1 次提交
  24. 25 9月, 2014 1 次提交
  25. 17 7月, 2014 1 次提交
  26. 28 5月, 2014 1 次提交
  27. 18 12月, 2013 1 次提交
    • R
      usb: gadget: add "maxpacket_limit" field to struct usb_ep · e117e742
      Robert Baldyga 提交于
      This patch adds "maxpacket_limit" to struct usb_ep. This field contains
      maximum value of maxpacket supported by driver, and is set in driver probe.
      This value should be used by autoconfig() function, because value of field
      "maxpacket" is set to value from endpoint descriptor when endpoint becomes
      enabled. So when autoconfig() function will be called again for this endpoint,
      "maxpacket" value will contain wMaxPacketSize from descriptior instead of
      maximum packet size for this endpoint.
      
      For this reason this patch adds new field "maxpacket_limit" which contains
      value of maximum packet size (which defines maximum endpoint capabilities).
      This value is used in ep_matches() function used by autoconfig().
      
      Value of "maxpacket_limit" should be set in UDC driver probe function, using
      usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function
      set choosen value to both "maxpacket_limit" and "maxpacket" fields.
      
      This patch modifies UDC drivers by adding support for maxpacket_limit.
      Signed-off-by: NRobert Baldyga <r.baldyga@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      e117e742
  28. 12 10月, 2013 1 次提交
  29. 17 9月, 2013 1 次提交
    • A
      usb: gadget: fix a bug and a WARN_ON in dummy-hcd · 5f5610f6
      Alan Stern 提交于
      This patch fixes a NULL pointer dereference and a WARN_ON in
      dummy-hcd.  These things were the result of moving to the UDC core
      framework, and possibly of changes to that framework.
      
      Now unloading a gadget driver causes the UDC to be stopped after the
      gadget driver is unbound, not before.  Therefore the "driver" argument
      to dummy_udc_stop() can be NULL, so we must not try to print the
      driver's name without checking first.
      
      Also, the UDC framework automatically unregisters the gadget when the
      UDC is deleted.  Therefore a sysfs attribute file attached to the
      gadget must be removed before the UDC is deleted, not after.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      5f5610f6
  30. 28 8月, 2013 1 次提交
    • G
      USB: gadget: audit sysfs attribute permissions · ce26bd23
      Greg Kroah-Hartman 提交于
      Convert all USB gadget sysfs attributes to use the _RO or _RW variants,
      to make them easier to audit and ensure that the permissions are
      correct.
      
      Note, two are left using the DEVICE_ATTR() macro, as there is no
      DEVICE_ATTR_WO() in Linus's tree, that will happen after 3.12-rc1 is
      out, a follow-on patch will be sent then.
      Reviewed-by: NFelipe Balbi <balbi@ti.com>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      --
       drivers/usb/gadget/composite.c      |    8 +++-----
       drivers/usb/gadget/dummy_hcd.c      |    8 ++++----
       drivers/usb/gadget/f_mass_storage.c |   14 ++++++--------
       drivers/usb/gadget/net2272.c        |    4 ++--
       drivers/usb/gadget/net2280.c        |   18 +++++++++---------
       drivers/usb/gadget/storage_common.c |   25 ++++++++++++-------------
       drivers/usb/gadget/udc-core.c       |   14 +++++++-------
       7 files changed, 43 insertions(+), 48 deletions(-)
      ce26bd23
  31. 15 5月, 2013 1 次提交