<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/usb, branch v4.12</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge tag 'usb-4.12-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb</title>
<updated>2017-06-17T23:39:54+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2017-06-17T23:39:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=19ea9d668a1f9f1e5e6752549150795a6693e6ad'/>
<id>19ea9d668a1f9f1e5e6752549150795a6693e6ad</id>
<content type='text'>
Pull USB fixes from Greg KH:
 "Here are some small gadget and xhci USB fixes for 4.12-rc6.

  Nothing major, but one of the gadget patches does fix a reported oops,
  and the xhci ones resolve reported problems. All have been in
  linux-next with no reported issues"

* tag 'usb-4.12-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk
  usb: xhci: Fix USB 3.1 supported protocol parsing
  USB: gadget: fix GPF in gadgetfs
  usb: gadget: composite: make sure to reactivate function on unbind
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull USB fixes from Greg KH:
 "Here are some small gadget and xhci USB fixes for 4.12-rc6.

  Nothing major, but one of the gadget patches does fix a reported oops,
  and the xhci ones resolve reported problems. All have been in
  linux-next with no reported issues"

* tag 'usb-4.12-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk
  usb: xhci: Fix USB 3.1 supported protocol parsing
  USB: gadget: fix GPF in gadgetfs
  usb: gadget: composite: make sure to reactivate function on unbind
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks</title>
<updated>2017-06-15T20:02:56+00:00</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2017-06-13T19:23:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f16443a034c7aa359ddf6f0f9bc40d01ca31faea'/>
<id>f16443a034c7aa359ddf6f0f9bc40d01ca31faea</id>
<content type='text'>
Using the syzkaller kernel fuzzer, Andrey Konovalov generated the
following error in gadgetfs:

&gt; BUG: KASAN: use-after-free in __lock_acquire+0x3069/0x3690
&gt; kernel/locking/lockdep.c:3246
&gt; Read of size 8 at addr ffff88003a2bdaf8 by task kworker/3:1/903
&gt;
&gt; CPU: 3 PID: 903 Comm: kworker/3:1 Not tainted 4.12.0-rc4+ #35
&gt; Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
&gt; Workqueue: usb_hub_wq hub_event
&gt; Call Trace:
&gt;  __dump_stack lib/dump_stack.c:16 [inline]
&gt;  dump_stack+0x292/0x395 lib/dump_stack.c:52
&gt;  print_address_description+0x78/0x280 mm/kasan/report.c:252
&gt;  kasan_report_error mm/kasan/report.c:351 [inline]
&gt;  kasan_report+0x230/0x340 mm/kasan/report.c:408
&gt;  __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:429
&gt;  __lock_acquire+0x3069/0x3690 kernel/locking/lockdep.c:3246
&gt;  lock_acquire+0x22d/0x560 kernel/locking/lockdep.c:3855
&gt;  __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
&gt;  _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151
&gt;  spin_lock include/linux/spinlock.h:299 [inline]
&gt;  gadgetfs_suspend+0x89/0x130 drivers/usb/gadget/legacy/inode.c:1682
&gt;  set_link_state+0x88e/0xae0 drivers/usb/gadget/udc/dummy_hcd.c:455
&gt;  dummy_hub_control+0xd7e/0x1fb0 drivers/usb/gadget/udc/dummy_hcd.c:2074
&gt;  rh_call_control drivers/usb/core/hcd.c:689 [inline]
&gt;  rh_urb_enqueue drivers/usb/core/hcd.c:846 [inline]
&gt;  usb_hcd_submit_urb+0x92f/0x20b0 drivers/usb/core/hcd.c:1650
&gt;  usb_submit_urb+0x8b2/0x12c0 drivers/usb/core/urb.c:542
&gt;  usb_start_wait_urb+0x148/0x5b0 drivers/usb/core/message.c:56
&gt;  usb_internal_control_msg drivers/usb/core/message.c:100 [inline]
&gt;  usb_control_msg+0x341/0x4d0 drivers/usb/core/message.c:151
&gt;  usb_clear_port_feature+0x74/0xa0 drivers/usb/core/hub.c:412
&gt;  hub_port_disable+0x123/0x510 drivers/usb/core/hub.c:4177
&gt;  hub_port_init+0x1ed/0x2940 drivers/usb/core/hub.c:4648
&gt;  hub_port_connect drivers/usb/core/hub.c:4826 [inline]
&gt;  hub_port_connect_change drivers/usb/core/hub.c:4999 [inline]
&gt;  port_event drivers/usb/core/hub.c:5105 [inline]
&gt;  hub_event+0x1ae1/0x3d40 drivers/usb/core/hub.c:5185
&gt;  process_one_work+0xc08/0x1bd0 kernel/workqueue.c:2097
&gt;  process_scheduled_works kernel/workqueue.c:2157 [inline]
&gt;  worker_thread+0xb2b/0x1860 kernel/workqueue.c:2233
&gt;  kthread+0x363/0x440 kernel/kthread.c:231
&gt;  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:424
&gt;
&gt; Allocated by task 9958:
&gt;  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
&gt;  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
&gt;  set_track mm/kasan/kasan.c:525 [inline]
&gt;  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:617
&gt;  kmem_cache_alloc_trace+0x87/0x280 mm/slub.c:2745
&gt;  kmalloc include/linux/slab.h:492 [inline]
&gt;  kzalloc include/linux/slab.h:665 [inline]
&gt;  dev_new drivers/usb/gadget/legacy/inode.c:170 [inline]
&gt;  gadgetfs_fill_super+0x24f/0x540 drivers/usb/gadget/legacy/inode.c:1993
&gt;  mount_single+0xf6/0x160 fs/super.c:1192
&gt;  gadgetfs_mount+0x31/0x40 drivers/usb/gadget/legacy/inode.c:2019
&gt;  mount_fs+0x9c/0x2d0 fs/super.c:1223
&gt;  vfs_kern_mount.part.25+0xcb/0x490 fs/namespace.c:976
&gt;  vfs_kern_mount fs/namespace.c:2509 [inline]
&gt;  do_new_mount fs/namespace.c:2512 [inline]
&gt;  do_mount+0x41b/0x2d90 fs/namespace.c:2834
&gt;  SYSC_mount fs/namespace.c:3050 [inline]
&gt;  SyS_mount+0xb0/0x120 fs/namespace.c:3027
&gt;  entry_SYSCALL_64_fastpath+0x1f/0xbe
&gt;
&gt; Freed by task 9960:
&gt;  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
&gt;  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
&gt;  set_track mm/kasan/kasan.c:525 [inline]
&gt;  kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:590
&gt;  slab_free_hook mm/slub.c:1357 [inline]
&gt;  slab_free_freelist_hook mm/slub.c:1379 [inline]
&gt;  slab_free mm/slub.c:2961 [inline]
&gt;  kfree+0xed/0x2b0 mm/slub.c:3882
&gt;  put_dev+0x124/0x160 drivers/usb/gadget/legacy/inode.c:163
&gt;  gadgetfs_kill_sb+0x33/0x60 drivers/usb/gadget/legacy/inode.c:2027
&gt;  deactivate_locked_super+0x8d/0xd0 fs/super.c:309
&gt;  deactivate_super+0x21e/0x310 fs/super.c:340
&gt;  cleanup_mnt+0xb7/0x150 fs/namespace.c:1112
&gt;  __cleanup_mnt+0x1b/0x20 fs/namespace.c:1119
&gt;  task_work_run+0x1a0/0x280 kernel/task_work.c:116
&gt;  exit_task_work include/linux/task_work.h:21 [inline]
&gt;  do_exit+0x18a8/0x2820 kernel/exit.c:878
&gt;  do_group_exit+0x14e/0x420 kernel/exit.c:982
&gt;  get_signal+0x784/0x1780 kernel/signal.c:2318
&gt;  do_signal+0xd7/0x2130 arch/x86/kernel/signal.c:808
&gt;  exit_to_usermode_loop+0x1ac/0x240 arch/x86/entry/common.c:157
&gt;  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
&gt;  syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263
&gt;  entry_SYSCALL_64_fastpath+0xbc/0xbe
&gt;
&gt; The buggy address belongs to the object at ffff88003a2bdae0
&gt;  which belongs to the cache kmalloc-1024 of size 1024
&gt; The buggy address is located 24 bytes inside of
&gt;  1024-byte region [ffff88003a2bdae0, ffff88003a2bdee0)
&gt; The buggy address belongs to the page:
&gt; page:ffffea0000e8ae00 count:1 mapcount:0 mapping:          (null)
&gt; index:0x0 compound_mapcount: 0
&gt; flags: 0x100000000008100(slab|head)
&gt; raw: 0100000000008100 0000000000000000 0000000000000000 0000000100170017
&gt; raw: ffffea0000ed3020 ffffea0000f5f820 ffff88003e80efc0 0000000000000000
&gt; page dumped because: kasan: bad access detected
&gt;
&gt; Memory state around the buggy address:
&gt;  ffff88003a2bd980: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt;  ffff88003a2bda00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt; &gt;ffff88003a2bda80: fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb fb
&gt;                                                                 ^
&gt;  ffff88003a2bdb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
&gt;  ffff88003a2bdb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
&gt; ==================================================================

What this means is that the gadgetfs_suspend() routine was trying to
access dev-&gt;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 -&gt;reset, -&gt;disconnect,
-&gt;suspend, and -&gt;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 -&gt;disconnect and -&gt;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: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-and-tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
CC: &lt;stable@vger.kernel.org&gt;
Acked-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Using the syzkaller kernel fuzzer, Andrey Konovalov generated the
following error in gadgetfs:

&gt; BUG: KASAN: use-after-free in __lock_acquire+0x3069/0x3690
&gt; kernel/locking/lockdep.c:3246
&gt; Read of size 8 at addr ffff88003a2bdaf8 by task kworker/3:1/903
&gt;
&gt; CPU: 3 PID: 903 Comm: kworker/3:1 Not tainted 4.12.0-rc4+ #35
&gt; Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
&gt; Workqueue: usb_hub_wq hub_event
&gt; Call Trace:
&gt;  __dump_stack lib/dump_stack.c:16 [inline]
&gt;  dump_stack+0x292/0x395 lib/dump_stack.c:52
&gt;  print_address_description+0x78/0x280 mm/kasan/report.c:252
&gt;  kasan_report_error mm/kasan/report.c:351 [inline]
&gt;  kasan_report+0x230/0x340 mm/kasan/report.c:408
&gt;  __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:429
&gt;  __lock_acquire+0x3069/0x3690 kernel/locking/lockdep.c:3246
&gt;  lock_acquire+0x22d/0x560 kernel/locking/lockdep.c:3855
&gt;  __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
&gt;  _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151
&gt;  spin_lock include/linux/spinlock.h:299 [inline]
&gt;  gadgetfs_suspend+0x89/0x130 drivers/usb/gadget/legacy/inode.c:1682
&gt;  set_link_state+0x88e/0xae0 drivers/usb/gadget/udc/dummy_hcd.c:455
&gt;  dummy_hub_control+0xd7e/0x1fb0 drivers/usb/gadget/udc/dummy_hcd.c:2074
&gt;  rh_call_control drivers/usb/core/hcd.c:689 [inline]
&gt;  rh_urb_enqueue drivers/usb/core/hcd.c:846 [inline]
&gt;  usb_hcd_submit_urb+0x92f/0x20b0 drivers/usb/core/hcd.c:1650
&gt;  usb_submit_urb+0x8b2/0x12c0 drivers/usb/core/urb.c:542
&gt;  usb_start_wait_urb+0x148/0x5b0 drivers/usb/core/message.c:56
&gt;  usb_internal_control_msg drivers/usb/core/message.c:100 [inline]
&gt;  usb_control_msg+0x341/0x4d0 drivers/usb/core/message.c:151
&gt;  usb_clear_port_feature+0x74/0xa0 drivers/usb/core/hub.c:412
&gt;  hub_port_disable+0x123/0x510 drivers/usb/core/hub.c:4177
&gt;  hub_port_init+0x1ed/0x2940 drivers/usb/core/hub.c:4648
&gt;  hub_port_connect drivers/usb/core/hub.c:4826 [inline]
&gt;  hub_port_connect_change drivers/usb/core/hub.c:4999 [inline]
&gt;  port_event drivers/usb/core/hub.c:5105 [inline]
&gt;  hub_event+0x1ae1/0x3d40 drivers/usb/core/hub.c:5185
&gt;  process_one_work+0xc08/0x1bd0 kernel/workqueue.c:2097
&gt;  process_scheduled_works kernel/workqueue.c:2157 [inline]
&gt;  worker_thread+0xb2b/0x1860 kernel/workqueue.c:2233
&gt;  kthread+0x363/0x440 kernel/kthread.c:231
&gt;  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:424
&gt;
&gt; Allocated by task 9958:
&gt;  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
&gt;  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
&gt;  set_track mm/kasan/kasan.c:525 [inline]
&gt;  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:617
&gt;  kmem_cache_alloc_trace+0x87/0x280 mm/slub.c:2745
&gt;  kmalloc include/linux/slab.h:492 [inline]
&gt;  kzalloc include/linux/slab.h:665 [inline]
&gt;  dev_new drivers/usb/gadget/legacy/inode.c:170 [inline]
&gt;  gadgetfs_fill_super+0x24f/0x540 drivers/usb/gadget/legacy/inode.c:1993
&gt;  mount_single+0xf6/0x160 fs/super.c:1192
&gt;  gadgetfs_mount+0x31/0x40 drivers/usb/gadget/legacy/inode.c:2019
&gt;  mount_fs+0x9c/0x2d0 fs/super.c:1223
&gt;  vfs_kern_mount.part.25+0xcb/0x490 fs/namespace.c:976
&gt;  vfs_kern_mount fs/namespace.c:2509 [inline]
&gt;  do_new_mount fs/namespace.c:2512 [inline]
&gt;  do_mount+0x41b/0x2d90 fs/namespace.c:2834
&gt;  SYSC_mount fs/namespace.c:3050 [inline]
&gt;  SyS_mount+0xb0/0x120 fs/namespace.c:3027
&gt;  entry_SYSCALL_64_fastpath+0x1f/0xbe
&gt;
&gt; Freed by task 9960:
&gt;  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
&gt;  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
&gt;  set_track mm/kasan/kasan.c:525 [inline]
&gt;  kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:590
&gt;  slab_free_hook mm/slub.c:1357 [inline]
&gt;  slab_free_freelist_hook mm/slub.c:1379 [inline]
&gt;  slab_free mm/slub.c:2961 [inline]
&gt;  kfree+0xed/0x2b0 mm/slub.c:3882
&gt;  put_dev+0x124/0x160 drivers/usb/gadget/legacy/inode.c:163
&gt;  gadgetfs_kill_sb+0x33/0x60 drivers/usb/gadget/legacy/inode.c:2027
&gt;  deactivate_locked_super+0x8d/0xd0 fs/super.c:309
&gt;  deactivate_super+0x21e/0x310 fs/super.c:340
&gt;  cleanup_mnt+0xb7/0x150 fs/namespace.c:1112
&gt;  __cleanup_mnt+0x1b/0x20 fs/namespace.c:1119
&gt;  task_work_run+0x1a0/0x280 kernel/task_work.c:116
&gt;  exit_task_work include/linux/task_work.h:21 [inline]
&gt;  do_exit+0x18a8/0x2820 kernel/exit.c:878
&gt;  do_group_exit+0x14e/0x420 kernel/exit.c:982
&gt;  get_signal+0x784/0x1780 kernel/signal.c:2318
&gt;  do_signal+0xd7/0x2130 arch/x86/kernel/signal.c:808
&gt;  exit_to_usermode_loop+0x1ac/0x240 arch/x86/entry/common.c:157
&gt;  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
&gt;  syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263
&gt;  entry_SYSCALL_64_fastpath+0xbc/0xbe
&gt;
&gt; The buggy address belongs to the object at ffff88003a2bdae0
&gt;  which belongs to the cache kmalloc-1024 of size 1024
&gt; The buggy address is located 24 bytes inside of
&gt;  1024-byte region [ffff88003a2bdae0, ffff88003a2bdee0)
&gt; The buggy address belongs to the page:
&gt; page:ffffea0000e8ae00 count:1 mapcount:0 mapping:          (null)
&gt; index:0x0 compound_mapcount: 0
&gt; flags: 0x100000000008100(slab|head)
&gt; raw: 0100000000008100 0000000000000000 0000000000000000 0000000100170017
&gt; raw: ffffea0000ed3020 ffffea0000f5f820 ffff88003e80efc0 0000000000000000
&gt; page dumped because: kasan: bad access detected
&gt;
&gt; Memory state around the buggy address:
&gt;  ffff88003a2bd980: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt;  ffff88003a2bda00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt; &gt;ffff88003a2bda80: fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb fb
&gt;                                                                 ^
&gt;  ffff88003a2bdb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
&gt;  ffff88003a2bdb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
&gt; ==================================================================

What this means is that the gadgetfs_suspend() routine was trying to
access dev-&gt;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 -&gt;reset, -&gt;disconnect,
-&gt;suspend, and -&gt;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 -&gt;disconnect and -&gt;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: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-and-tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
CC: &lt;stable@vger.kernel.org&gt;
Acked-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net</title>
<updated>2017-06-15T09:09:47+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2017-06-15T09:09:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a090bd4ff8387c409732a8e059fbf264ea0bdd56'/>
<id>a090bd4ff8387c409732a8e059fbf264ea0bdd56</id>
<content type='text'>
Pull networking fixes from David Miller:

 1) The netlink attribute passed in to dev_set_alias() is not
    necessarily NULL terminated, don't use strlcpy() on it. From
    Alexander Potapenko.

 2) Fix implementation of atomics in arm64 bpf JIT, from Daniel
    Borkmann.

 3) Correct the release of netdevs and driver private data in certain
    circumstances.

 4) Sanitize netlink message length properly in decnet, from Mateusz
    Jurczyk.

 5) Don't leak kernel data in rtnl_fill_vfinfo() netlink blobs. From
    Yuval Mintz.

 6) Hash secret is never initialized in ipv6 ILA translation code, from
    Arnd Bergmann. I guess those clang warnings about unused inline
    functions are useful for something!

 7) Fix endian selection in bpf_endian.h, from Daniel Borkmann.

 8) Sanitize sockaddr length before dereferncing any fields in AF_UNIX
    and CAIF. From Mateusz Jurczyk.

 9) Fix timestamping for GMAC3 chips in stmmac driver, from Mario
    Molitor.

10) Do not leak netdev on dev_alloc_name() errors in mac80211, from
    Johannes Berg.

11) Fix locking in sctp_for_each_endpoint(), from Xin Long.

12) Fix wrong memset size on 32-bit in snmp6, from Christian Perle.

13) Fix use after free in ip_mc_clear_src(), from WANG Cong.

14) Fix regressions caused by ICMP rate limiting changes in 4.11, from
    Jesper Dangaard Brouer.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (91 commits)
  i40e: Fix a sleep-in-atomic bug
  net: don't global ICMP rate limit packets originating from loopback
  net/act_pedit: fix an error code
  net: update undefined -&gt;ndo_change_mtu() comment
  net_sched: move tcf_lock down after gen_replace_estimator()
  caif: Add sockaddr length check before accessing sa_family in connect handler
  qed: fix dump of context data
  qmi_wwan: new Telewell and Sierra device IDs
  net: phy: Fix MDIO_THUNDER dependencies
  netconsole: Remove duplicate "netconsole: " logging prefix
  igmp: acquire pmc lock for ip_mc_clear_src()
  r8152: give the device version
  net: rps: fix uninitialized symbol warning
  mac80211: don't send SMPS action frame in AP mode when not needed
  mac80211/wpa: use constant time memory comparison for MACs
  mac80211: set bss_info data before configuring the channel
  mac80211: remove 5/10 MHz rate code from station MLME
  mac80211: Fix incorrect condition when checking rx timestamp
  mac80211: don't look at the PM bit of BAR frames
  i40e: fix handling of HW ATR eviction
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull networking fixes from David Miller:

 1) The netlink attribute passed in to dev_set_alias() is not
    necessarily NULL terminated, don't use strlcpy() on it. From
    Alexander Potapenko.

 2) Fix implementation of atomics in arm64 bpf JIT, from Daniel
    Borkmann.

 3) Correct the release of netdevs and driver private data in certain
    circumstances.

 4) Sanitize netlink message length properly in decnet, from Mateusz
    Jurczyk.

 5) Don't leak kernel data in rtnl_fill_vfinfo() netlink blobs. From
    Yuval Mintz.

 6) Hash secret is never initialized in ipv6 ILA translation code, from
    Arnd Bergmann. I guess those clang warnings about unused inline
    functions are useful for something!

 7) Fix endian selection in bpf_endian.h, from Daniel Borkmann.

 8) Sanitize sockaddr length before dereferncing any fields in AF_UNIX
    and CAIF. From Mateusz Jurczyk.

 9) Fix timestamping for GMAC3 chips in stmmac driver, from Mario
    Molitor.

10) Do not leak netdev on dev_alloc_name() errors in mac80211, from
    Johannes Berg.

11) Fix locking in sctp_for_each_endpoint(), from Xin Long.

12) Fix wrong memset size on 32-bit in snmp6, from Christian Perle.

13) Fix use after free in ip_mc_clear_src(), from WANG Cong.

14) Fix regressions caused by ICMP rate limiting changes in 4.11, from
    Jesper Dangaard Brouer.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (91 commits)
  i40e: Fix a sleep-in-atomic bug
  net: don't global ICMP rate limit packets originating from loopback
  net/act_pedit: fix an error code
  net: update undefined -&gt;ndo_change_mtu() comment
  net_sched: move tcf_lock down after gen_replace_estimator()
  caif: Add sockaddr length check before accessing sa_family in connect handler
  qed: fix dump of context data
  qmi_wwan: new Telewell and Sierra device IDs
  net: phy: Fix MDIO_THUNDER dependencies
  netconsole: Remove duplicate "netconsole: " logging prefix
  igmp: acquire pmc lock for ip_mc_clear_src()
  r8152: give the device version
  net: rps: fix uninitialized symbol warning
  mac80211: don't send SMPS action frame in AP mode when not needed
  mac80211/wpa: use constant time memory comparison for MACs
  mac80211: set bss_info data before configuring the channel
  mac80211: remove 5/10 MHz rate code from station MLME
  mac80211: Fix incorrect condition when checking rx timestamp
  mac80211: don't look at the PM bit of BAR frames
  i40e: fix handling of HW ATR eviction
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk</title>
<updated>2017-06-12T14:04:53+00:00</updated>
<author>
<name>Corentin Labbe</name>
<email>clabbe.montjoie@gmail.com</email>
</author>
<published>2017-06-09T11:48:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d2f48f05cd2a2a0a708fbfa45f1a00a87660d937'/>
<id>d2f48f05cd2a2a0a708fbfa45f1a00a87660d937</id>
<content type='text'>
When plugging an USB webcam I see the following message:
[106385.615559] xhci_hcd 0000:04:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[106390.583860] handle_tx_event: 913 callbacks suppressed

With this patch applied, I get no more printing of this message.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Corentin Labbe &lt;clabbe.montjoie@gmail.com&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When plugging an USB webcam I see the following message:
[106385.615559] xhci_hcd 0000:04:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[106390.583860] handle_tx_event: 913 callbacks suppressed

With this patch applied, I get no more printing of this message.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Corentin Labbe &lt;clabbe.montjoie@gmail.com&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: xhci: Fix USB 3.1 supported protocol parsing</title>
<updated>2017-06-12T14:04:53+00:00</updated>
<author>
<name>YD Tseng</name>
<email>yd_tseng@asmedia.com.tw</email>
</author>
<published>2017-06-09T11:48:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b72eb8435b25be3a1880264cf32ac91e626ba5ba'/>
<id>b72eb8435b25be3a1880264cf32ac91e626ba5ba</id>
<content type='text'>
xHCI host controllers can have both USB 3.1 and 3.0 extended speed
protocol lists. If the USB3.1 speed is parsed first and 3.0 second then
the minor revision supported will be overwritten by the 3.0 speeds and
the USB3 roothub will only show support for USB 3.0 speeds.

This was the case with a xhci controller with the supported protocol
capability listed below.
In xhci-mem.c, the USB 3.1 speed is parsed first, the min_rev of usb3_rhub
is set as 0x10.  And then USB 3.0 is parsed.  However, the min_rev of
usb3_rhub will be changed to 0x00. If USB 3.1 device is connected behind
this host controller, the speed of USB 3.1 device just reports 5G speed
using lsusb.

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  00 01 08 00 00 00 00 00 40 00 00 00 00 00 00 00 00
  10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  20 02 08 10 03 55 53 42 20 01 02 00 00 00 00 00 00     //USB 3.1
  30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  40 02 08 00 03 55 53 42 20 03 06 00 00 00 00 00 00     //USB 3.0
  50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  60 02 08 00 02 55 53 42 20 09 0E 19 00 00 00 00 00     //USB 2.0
  70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This patch fixes the issue by only owerwriting the minor revision if
it is higher than the existing one.

[reword commit message -Mathias]
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: YD Tseng &lt;yd_tseng@asmedia.com.tw&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
xHCI host controllers can have both USB 3.1 and 3.0 extended speed
protocol lists. If the USB3.1 speed is parsed first and 3.0 second then
the minor revision supported will be overwritten by the 3.0 speeds and
the USB3 roothub will only show support for USB 3.0 speeds.

This was the case with a xhci controller with the supported protocol
capability listed below.
In xhci-mem.c, the USB 3.1 speed is parsed first, the min_rev of usb3_rhub
is set as 0x10.  And then USB 3.0 is parsed.  However, the min_rev of
usb3_rhub will be changed to 0x00. If USB 3.1 device is connected behind
this host controller, the speed of USB 3.1 device just reports 5G speed
using lsusb.

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  00 01 08 00 00 00 00 00 40 00 00 00 00 00 00 00 00
  10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  20 02 08 10 03 55 53 42 20 01 02 00 00 00 00 00 00     //USB 3.1
  30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  40 02 08 00 03 55 53 42 20 03 06 00 00 00 00 00 00     //USB 3.0
  50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  60 02 08 00 02 55 53 42 20 09 0E 19 00 00 00 00 00     //USB 2.0
  70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This patch fixes the issue by only owerwriting the minor revision if
it is higher than the existing one.

[reword commit message -Mathias]
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: YD Tseng &lt;yd_tseng@asmedia.com.tw&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'fixes-for-v4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus</title>
<updated>2017-06-12T14:02:19+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-06-12T14:02:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8ada5f3ae96b0336145e453740b9168a56a0fc1d'/>
<id>8ada5f3ae96b0336145e453740b9168a56a0fc1d</id>
<content type='text'>
Felipe writes:

usb: fixes for v4.12-rc5

Alan Stern fixed a GPF in gadgetfs found by the kernel fuzzying project

composite.c learned that if it deactivates a function during bind, it
must reactivate it during unbind.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Felipe writes:

usb: fixes for v4.12-rc5

Alan Stern fixed a GPF in gadgetfs found by the kernel fuzzying project

composite.c learned that if it deactivates a function during bind, it
must reactivate it during unbind.
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: gadget: fix GPF in gadgetfs</title>
<updated>2017-06-09T13:02:20+00:00</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2017-06-08T17:55:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f50b878fed33e360d01dcdc31a8eeb1815d033d5'/>
<id>f50b878fed33e360d01dcdc31a8eeb1815d033d5</id>
<content type='text'>
A NULL-pointer dereference bug in gadgetfs was uncovered by syzkaller:

&gt; kasan: GPF could be caused by NULL-ptr deref or user memory access
&gt; general protection fault: 0000 [#1] SMP KASAN
&gt; Dumping ftrace buffer:
&gt;    (ftrace buffer empty)
&gt; Modules linked in:
&gt; CPU: 2 PID: 4820 Comm: syz-executor0 Not tainted 4.12.0-rc4+ #5
&gt; Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
&gt; task: ffff880039542dc0 task.stack: ffff88003bdd0000
&gt; RIP: 0010:__list_del_entry_valid+0x7e/0x170 lib/list_debug.c:51
&gt; RSP: 0018:ffff88003bdd6e50 EFLAGS: 00010246
&gt; RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000010000
&gt; RDX: 0000000000000000 RSI: ffffffff86504948 RDI: ffffffff86504950
&gt; RBP: ffff88003bdd6e68 R08: ffff880039542dc0 R09: ffffffff8778ce00
&gt; R10: ffff88003bdd6e68 R11: dffffc0000000000 R12: 0000000000000000
&gt; R13: dffffc0000000000 R14: 1ffff100077badd2 R15: ffffffff864d2e40
&gt; FS:  0000000000000000(0000) GS:ffff88006dc00000(0000) knlGS:0000000000000000
&gt; CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
&gt; CR2: 000000002014aff9 CR3: 0000000006022000 CR4: 00000000000006e0
&gt; Call Trace:
&gt;  __list_del_entry include/linux/list.h:116 [inline]
&gt;  list_del include/linux/list.h:124 [inline]
&gt;  usb_gadget_unregister_driver+0x166/0x4c0 drivers/usb/gadget/udc/core.c:1387
&gt;  dev_release+0x80/0x160 drivers/usb/gadget/legacy/inode.c:1187
&gt;  __fput+0x332/0x7f0 fs/file_table.c:209
&gt;  ____fput+0x15/0x20 fs/file_table.c:245
&gt;  task_work_run+0x19b/0x270 kernel/task_work.c:116
&gt;  exit_task_work include/linux/task_work.h:21 [inline]
&gt;  do_exit+0x18a3/0x2820 kernel/exit.c:878
&gt;  do_group_exit+0x149/0x420 kernel/exit.c:982
&gt;  get_signal+0x77f/0x1780 kernel/signal.c:2318
&gt;  do_signal+0xd2/0x2130 arch/x86/kernel/signal.c:808
&gt;  exit_to_usermode_loop+0x1a7/0x240 arch/x86/entry/common.c:157
&gt;  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
&gt;  syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263
&gt;  entry_SYSCALL_64_fastpath+0xbc/0xbe
&gt; RIP: 0033:0x4461f9
&gt; RSP: 002b:00007fdac2b1ecf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
&gt; RAX: fffffffffffffe00 RBX: 00000000007080c8 RCX: 00000000004461f9
&gt; RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000007080c8
&gt; RBP: 00000000007080a8 R08: 0000000000000000 R09: 0000000000000000
&gt; R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
&gt; R13: 0000000000000000 R14: 00007fdac2b1f9c0 R15: 00007fdac2b1f700
&gt; Code: 00 00 00 00 ad de 49 39 c4 74 6a 48 b8 00 02 00 00 00 00 ad de
&gt; 48 89 da 48 39 c3 74 74 48 c1 ea 03 48 b8 00 00 00 00 00 fc ff df &lt;80&gt;
&gt; 3c 02 00 0f 85 92 00 00 00 48 8b 13 48 39 f2 75 66 49 8d 7c
&gt; RIP: __list_del_entry_valid+0x7e/0x170 lib/list_debug.c:51 RSP: ffff88003bdd6e50
&gt; ---[ end trace 30e94b1eec4831c8 ]---
&gt; Kernel panic - not syncing: Fatal exception

The bug was caused by dev_release() failing to turn off its
gadget_registered flag after unregistering the gadget driver.  As a
result, when a later user closed the device file before writing a
valid set of descriptors, dev_release() thought the gadget had been
registered and tried to unregister it, even though it had not been.
This led to the NULL pointer dereference.

The fix is simple: turn off the flag when the gadget is unregistered.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-and-tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
CC: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A NULL-pointer dereference bug in gadgetfs was uncovered by syzkaller:

&gt; kasan: GPF could be caused by NULL-ptr deref or user memory access
&gt; general protection fault: 0000 [#1] SMP KASAN
&gt; Dumping ftrace buffer:
&gt;    (ftrace buffer empty)
&gt; Modules linked in:
&gt; CPU: 2 PID: 4820 Comm: syz-executor0 Not tainted 4.12.0-rc4+ #5
&gt; Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
&gt; task: ffff880039542dc0 task.stack: ffff88003bdd0000
&gt; RIP: 0010:__list_del_entry_valid+0x7e/0x170 lib/list_debug.c:51
&gt; RSP: 0018:ffff88003bdd6e50 EFLAGS: 00010246
&gt; RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000010000
&gt; RDX: 0000000000000000 RSI: ffffffff86504948 RDI: ffffffff86504950
&gt; RBP: ffff88003bdd6e68 R08: ffff880039542dc0 R09: ffffffff8778ce00
&gt; R10: ffff88003bdd6e68 R11: dffffc0000000000 R12: 0000000000000000
&gt; R13: dffffc0000000000 R14: 1ffff100077badd2 R15: ffffffff864d2e40
&gt; FS:  0000000000000000(0000) GS:ffff88006dc00000(0000) knlGS:0000000000000000
&gt; CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
&gt; CR2: 000000002014aff9 CR3: 0000000006022000 CR4: 00000000000006e0
&gt; Call Trace:
&gt;  __list_del_entry include/linux/list.h:116 [inline]
&gt;  list_del include/linux/list.h:124 [inline]
&gt;  usb_gadget_unregister_driver+0x166/0x4c0 drivers/usb/gadget/udc/core.c:1387
&gt;  dev_release+0x80/0x160 drivers/usb/gadget/legacy/inode.c:1187
&gt;  __fput+0x332/0x7f0 fs/file_table.c:209
&gt;  ____fput+0x15/0x20 fs/file_table.c:245
&gt;  task_work_run+0x19b/0x270 kernel/task_work.c:116
&gt;  exit_task_work include/linux/task_work.h:21 [inline]
&gt;  do_exit+0x18a3/0x2820 kernel/exit.c:878
&gt;  do_group_exit+0x149/0x420 kernel/exit.c:982
&gt;  get_signal+0x77f/0x1780 kernel/signal.c:2318
&gt;  do_signal+0xd2/0x2130 arch/x86/kernel/signal.c:808
&gt;  exit_to_usermode_loop+0x1a7/0x240 arch/x86/entry/common.c:157
&gt;  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
&gt;  syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263
&gt;  entry_SYSCALL_64_fastpath+0xbc/0xbe
&gt; RIP: 0033:0x4461f9
&gt; RSP: 002b:00007fdac2b1ecf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
&gt; RAX: fffffffffffffe00 RBX: 00000000007080c8 RCX: 00000000004461f9
&gt; RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000007080c8
&gt; RBP: 00000000007080a8 R08: 0000000000000000 R09: 0000000000000000
&gt; R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
&gt; R13: 0000000000000000 R14: 00007fdac2b1f9c0 R15: 00007fdac2b1f700
&gt; Code: 00 00 00 00 ad de 49 39 c4 74 6a 48 b8 00 02 00 00 00 00 ad de
&gt; 48 89 da 48 39 c3 74 74 48 c1 ea 03 48 b8 00 00 00 00 00 fc ff df &lt;80&gt;
&gt; 3c 02 00 0f 85 92 00 00 00 48 8b 13 48 39 f2 75 66 49 8d 7c
&gt; RIP: __list_del_entry_valid+0x7e/0x170 lib/list_debug.c:51 RSP: ffff88003bdd6e50
&gt; ---[ end trace 30e94b1eec4831c8 ]---
&gt; Kernel panic - not syncing: Fatal exception

The bug was caused by dev_release() failing to turn off its
gadget_registered flag after unregistering the gadget driver.  As a
result, when a later user closed the device file before writing a
valid set of descriptors, dev_release() thought the gadget had been
registered and tried to unregister it, even though it had not been.
This led to the NULL pointer dereference.

The fix is simple: turn off the flag when the gadget is unregistered.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-and-tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
CC: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>net: Fix inconsistent teardown and release of private netdev state.</title>
<updated>2017-06-07T19:53:24+00:00</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2017-05-08T16:52:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=cf124db566e6b036b8bcbe8decbed740bdfac8c6'/>
<id>cf124db566e6b036b8bcbe8decbed740bdfac8c6</id>
<content type='text'>
Network devices can allocate reasources and private memory using
netdev_ops-&gt;ndo_init().  However, the release of these resources
can occur in one of two different places.

Either netdev_ops-&gt;ndo_uninit() or netdev-&gt;destructor().

The decision of which operation frees the resources depends upon
whether it is necessary for all netdev refs to be released before it
is safe to perform the freeing.

netdev_ops-&gt;ndo_uninit() presumably can occur right after the
NETDEV_UNREGISTER notifier completes and the unicast and multicast
address lists are flushed.

netdev-&gt;destructor(), on the other hand, does not run until the
netdev references all go away.

Further complicating the situation is that netdev-&gt;destructor()
almost universally does also a free_netdev().

This creates a problem for the logic in register_netdevice().
Because all callers of register_netdevice() manage the freeing
of the netdev, and invoke free_netdev(dev) if register_netdevice()
fails.

If netdev_ops-&gt;ndo_init() succeeds, but something else fails inside
of register_netdevice(), it does call ndo_ops-&gt;ndo_uninit().  But
it is not able to invoke netdev-&gt;destructor().

This is because netdev-&gt;destructor() will do a free_netdev() and
then the caller of register_netdevice() will do the same.

However, this means that the resources that would normally be released
by netdev-&gt;destructor() will not be.

Over the years drivers have added local hacks to deal with this, by
invoking their destructor parts by hand when register_netdevice()
fails.

Many drivers do not try to deal with this, and instead we have leaks.

Let's close this hole by formalizing the distinction between what
private things need to be freed up by netdev-&gt;destructor() and whether
the driver needs unregister_netdevice() to perform the free_netdev().

netdev-&gt;priv_destructor() performs all actions to free up the private
resources that used to be freed by netdev-&gt;destructor(), except for
free_netdev().

netdev-&gt;needs_free_netdev is a boolean that indicates whether
free_netdev() should be done at the end of unregister_netdevice().

Now, register_netdevice() can sanely release all resources after
ndo_ops-&gt;ndo_init() succeeds, by invoking both ndo_ops-&gt;ndo_uninit()
and netdev-&gt;priv_destructor().

And at the end of unregister_netdevice(), we invoke
netdev-&gt;priv_destructor() and optionally call free_netdev().

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Network devices can allocate reasources and private memory using
netdev_ops-&gt;ndo_init().  However, the release of these resources
can occur in one of two different places.

Either netdev_ops-&gt;ndo_uninit() or netdev-&gt;destructor().

The decision of which operation frees the resources depends upon
whether it is necessary for all netdev refs to be released before it
is safe to perform the freeing.

netdev_ops-&gt;ndo_uninit() presumably can occur right after the
NETDEV_UNREGISTER notifier completes and the unicast and multicast
address lists are flushed.

netdev-&gt;destructor(), on the other hand, does not run until the
netdev references all go away.

Further complicating the situation is that netdev-&gt;destructor()
almost universally does also a free_netdev().

This creates a problem for the logic in register_netdevice().
Because all callers of register_netdevice() manage the freeing
of the netdev, and invoke free_netdev(dev) if register_netdevice()
fails.

If netdev_ops-&gt;ndo_init() succeeds, but something else fails inside
of register_netdevice(), it does call ndo_ops-&gt;ndo_uninit().  But
it is not able to invoke netdev-&gt;destructor().

This is because netdev-&gt;destructor() will do a free_netdev() and
then the caller of register_netdevice() will do the same.

However, this means that the resources that would normally be released
by netdev-&gt;destructor() will not be.

Over the years drivers have added local hacks to deal with this, by
invoking their destructor parts by hand when register_netdevice()
fails.

Many drivers do not try to deal with this, and instead we have leaks.

Let's close this hole by formalizing the distinction between what
private things need to be freed up by netdev-&gt;destructor() and whether
the driver needs unregister_netdevice() to perform the free_netdev().

netdev-&gt;priv_destructor() performs all actions to free up the private
resources that used to be freed by netdev-&gt;destructor(), except for
free_netdev().

netdev-&gt;needs_free_netdev is a boolean that indicates whether
free_netdev() should be done at the end of unregister_netdevice().

Now, register_netdevice() can sanely release all resources after
ndo_ops-&gt;ndo_init() succeeds, by invoking both ndo_ops-&gt;ndo_uninit()
and netdev-&gt;priv_destructor().

And at the end of unregister_netdevice(), we invoke
netdev-&gt;priv_destructor() and optionally call free_netdev().

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: make sure to reactivate function on unbind</title>
<updated>2017-06-06T11:50:54+00:00</updated>
<author>
<name>Felipe Balbi</name>
<email>felipe.balbi@linux.intel.com</email>
</author>
<published>2017-06-06T11:47:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0e3e97526a850f97c9fe8b646937b3a2bef58290'/>
<id>0e3e97526a850f97c9fe8b646937b3a2bef58290</id>
<content type='text'>
If a function sets bind_deactivated flag, upon removal we will be left
with an unbalanced deactivation. Let's make sure that we conditionally
call usb_function_activate() from usb_remove_function() and make sure
usb_remove_function() is called from remove_config().

Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a function sets bind_deactivated flag, upon removal we will be left
with an unbalanced deactivation. Let's make sure that we conditionally
call usb_function_activate() from usb_remove_function() and make sure
usb_remove_function() is called from remove_config().

Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'fixes-for-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus</title>
<updated>2017-06-03T00:47:16+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-06-03T00:47:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b132e4a25dccf5d5857e6ce2d96541be51aa9c5e'/>
<id>b132e4a25dccf5d5857e6ce2d96541be51aa9c5e</id>
<content type='text'>
Felipe writes:

usb: fixes for v4.12-rc4

A fix to a really old synchronization bug on mass storage gadget.

Support for Meson8 SoCs on dwc2

Synchronization fixes on renesas USB driver.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Felipe writes:

usb: fixes for v4.12-rc4

A fix to a really old synchronization bug on mass storage gadget.

Support for Meson8 SoCs on dwc2

Synchronization fixes on renesas USB driver.
</pre>
</div>
</content>
</entry>
</feed>
