<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/usb/core/devio.c, branch v4.4.94</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.94</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.94'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2017-10-12T09:27:32Z</updated>
<entry>
<title>USB: devio: Don't corrupt user memory</title>
<updated>2017-10-12T09:27:32Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2017-09-22T20:43:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b74a45450f80a56a3aca515dd147bd95b18394bf'/>
<id>urn:sha1:b74a45450f80a56a3aca515dd147bd95b18394bf</id>
<content type='text'>
commit fa1ed74eb1c233be6131ec92df21ab46499a15b6 upstream.

The user buffer has "uurb-&gt;buffer_length" bytes.  If the kernel has more
information than that, we should truncate it instead of writing past
the end of the user's buffer.  I added a WARN_ONCE() to help the user
debug the issue.

Reported-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: core: Avoid race of async_completed() w/ usbdev_release()</title>
<updated>2017-09-13T21:09:44Z</updated>
<author>
<name>Douglas Anderson</name>
<email>dianders@chromium.org</email>
</author>
<published>2017-08-10T22:42:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=812e484133fb71f937d04e21096d6b6ba55c2f7b'/>
<id>urn:sha1:812e484133fb71f937d04e21096d6b6ba55c2f7b</id>
<content type='text'>
commit ed62ca2f4f51c17841ea39d98c0c409cb53a3e10 upstream.

While running reboot tests w/ a specific set of USB devices (and
slub_debug enabled), I found that once every few hours my device would
be crashed with a stack that looked like this:

[   14.012445] BUG: spinlock bad magic on CPU#0, modprobe/2091
[   14.012460]  lock: 0xffffffc0cb055978, .magic: ffffffc0, .owner: cryption contexts: %lu/%lu
[   14.012460] /1025536097, .owner_cpu: 0
[   14.012466] CPU: 0 PID: 2091 Comm: modprobe Not tainted 4.4.79 #352
[   14.012468] Hardware name: Google Kevin (DT)
[   14.012471] Call trace:
[   14.012483] [&lt;....&gt;] dump_backtrace+0x0/0x160
[   14.012487] [&lt;....&gt;] show_stack+0x20/0x28
[   14.012494] [&lt;....&gt;] dump_stack+0xb4/0xf0
[   14.012500] [&lt;....&gt;] spin_dump+0x8c/0x98
[   14.012504] [&lt;....&gt;] spin_bug+0x30/0x3c
[   14.012508] [&lt;....&gt;] do_raw_spin_lock+0x40/0x164
[   14.012515] [&lt;....&gt;] _raw_spin_lock_irqsave+0x64/0x74
[   14.012521] [&lt;....&gt;] __wake_up+0x2c/0x60
[   14.012528] [&lt;....&gt;] async_completed+0x2d0/0x300
[   14.012534] [&lt;....&gt;] __usb_hcd_giveback_urb+0xc4/0x138
[   14.012538] [&lt;....&gt;] usb_hcd_giveback_urb+0x54/0xf0
[   14.012544] [&lt;....&gt;] xhci_irq+0x1314/0x1348
[   14.012548] [&lt;....&gt;] usb_hcd_irq+0x40/0x50
[   14.012553] [&lt;....&gt;] handle_irq_event_percpu+0x1b4/0x3f0
[   14.012556] [&lt;....&gt;] handle_irq_event+0x4c/0x7c
[   14.012561] [&lt;....&gt;] handle_fasteoi_irq+0x158/0x1c8
[   14.012564] [&lt;....&gt;] generic_handle_irq+0x30/0x44
[   14.012568] [&lt;....&gt;] __handle_domain_irq+0x90/0xbc
[   14.012572] [&lt;....&gt;] gic_handle_irq+0xcc/0x18c

Investigation using kgdb() found that the wait queue that was passed
into wake_up() had been freed (it was filled with slub_debug poison).

I analyzed and instrumented the code and reproduced.  My current
belief is that this is happening:

1. async_completed() is called (from IRQ).  Moves "as" onto the
   completed list.
2. On another CPU, proc_reapurbnonblock_compat() calls
   async_getcompleted().  Blocks on spinlock.
3. async_completed() releases the lock; keeps running; gets blocked
   midway through wake_up().
4. proc_reapurbnonblock_compat() =&gt; async_getcompleted() gets the
   lock; removes "as" from completed list and frees it.
5. usbdev_release() is called.  Frees "ps".
6. async_completed() finally continues running wake_up().  ...but
   wake_up() has a pointer to the freed "ps".

The instrumentation that led me to believe this was based on adding
some trace_printk() calls in a select few functions and then using
kdb's "ftdump" at crash time.  The trace follows (NOTE: in the trace
below I cheated a little bit and added a udelay(1000) in
async_completed() after releasing the spinlock because I wanted it to
trigger quicker):

&lt;...&gt;-2104   0d.h2 13759034us!: async_completed at start: as=ffffffc0cc638200
mtpd-2055    3.... 13759356us : async_getcompleted before spin_lock_irqsave
mtpd-2055    3d..1 13759362us : async_getcompleted after list_del_init: as=ffffffc0cc638200
mtpd-2055    3.... 13759371us+: proc_reapurbnonblock_compat: free_async(ffffffc0cc638200)
mtpd-2055    3.... 13759422us+: async_getcompleted before spin_lock_irqsave
mtpd-2055    3.... 13759479us : usbdev_release at start: ps=ffffffc0cc042080
mtpd-2055    3.... 13759487us : async_getcompleted before spin_lock_irqsave
mtpd-2055    3.... 13759497us!: usbdev_release after kfree(ps): ps=ffffffc0cc042080
&lt;...&gt;-2104   0d.h2 13760294us : async_completed before wake_up(): as=ffffffc0cc638200

To fix this problem we can just move the wake_up() under the ps-&gt;lock.
There should be no issues there that I'm aware of.

Signed-off-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: core: replace %p with %pK</title>
<updated>2017-05-25T12:30:07Z</updated>
<author>
<name>Vamsi Krishna Samavedam</name>
<email>vskrishn@codeaurora.org</email>
</author>
<published>2017-05-16T12:38:08Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b171ce6c5e4106bd54e7b9108da58cdabb0cf111'/>
<id>urn:sha1:b171ce6c5e4106bd54e7b9108da58cdabb0cf111</id>
<content type='text'>
commit 2f964780c03b73de269b08d12aff96a9618d13f3 upstream.

Format specifier %p can leak kernel addresses while not valuing the
kptr_restrict system settings. When kptr_restrict is set to (1), kernel
pointers printed using the %pK format specifier will be replaced with
Zeros. Debugging Note : &amp;pK prints only Zeros as address. If you need
actual address information, write 0 to kptr_restrict.

echo 0 &gt; /proc/sys/kernel/kptr_restrict

[Found by poking around in a random vendor kernel tree, it would be nice
if someone would actually send these types of patches upstream - gkh]

Signed-off-by: Vamsi Krishna Samavedam &lt;vskrishn@codeaurora.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: avoid left shift by -1</title>
<updated>2016-09-07T06:32:44Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2016-08-23T19:32:51Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5ab968f27aee23f03ddd0401a77c2ba81dc73ad0'/>
<id>urn:sha1:5ab968f27aee23f03ddd0401a77c2ba81dc73ad0</id>
<content type='text'>
commit 53e5f36fbd2453ad69a3369a1db62dc06c30a4aa upstream.

UBSAN complains about a left shift by -1 in proc_do_submiturb().  This
can occur when an URB is submitted for a bulk or control endpoint on
a high-speed device, since the code doesn't bother to check the
endpoint type; normally only interrupt or isochronous endpoints have
a nonzero bInterval value.

Aside from the fact that the operation is illegal, it shouldn't matter
because the result isn't used.  Still, in theory it could cause a
hardware exception or other problem, so we should work around it.
This patch avoids doing the left shift unless the shift amount is &gt;= 0.

The same piece of code has another problem.  When checking the device
speed (the exponential encoding for interrupt endpoints is used only
by high-speed or faster devices), we need to look for speed &gt;=
USB_SPEED_SUPER as well as speed == USB_SPEED HIGH.  The patch adds
this check.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-by: Vittorio Zecca &lt;zeccav@gmail.com&gt;
Tested-by: Vittorio Zecca &lt;zeccav@gmail.com&gt;
Suggested-by: Bjørn Mork &lt;bjorn@mork.no&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: usbfs: fix potential infoleak in devio</title>
<updated>2016-08-20T16:09:16Z</updated>
<author>
<name>Kangjie Lu</name>
<email>kangjielu@gmail.com</email>
</author>
<published>2016-05-03T20:32:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4077ef4797a8ff007a2de091c9befee4882c4790'/>
<id>urn:sha1:4077ef4797a8ff007a2de091c9befee4882c4790</id>
<content type='text'>
commit 681fef8380eb818c0b845fca5d2ab1dcbab114ee upstream.

The stack object “ci” has a total size of 8 bytes. Its last 3 bytes
are padding bytes which are not initialized and leaked to userland
via “copy_to_user”.

Signed-off-by: Kangjie Lu &lt;kjlu@gatech.edu&gt;
Signed-off-by: Chas Williams &lt;ciwillia@brocade.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>usb: devio: fix spacing</title>
<updated>2015-08-08T22:17:17Z</updated>
<author>
<name>Kris Borer</name>
<email>kborer@gmail.com</email>
</author>
<published>2015-08-07T11:22:44Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f355e830a54ebe1601613d78a8d5b85eeafde358'/>
<id>urn:sha1:f355e830a54ebe1601613d78a8d5b85eeafde358</id>
<content type='text'>
Fix two occurrences of the checkpatch.pl error:

ERROR: space prohibited before that ',' (ctx:WxW)

Fix one occurrence of the checkpatch error:

ERROR: space required before the open parenthesis '('

Signed-off-by: Kris Borer &lt;kborer@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: devio: remove assignment from if condition</title>
<updated>2015-08-05T19:29:19Z</updated>
<author>
<name>Kris Borer</name>
<email>kborer@gmail.com</email>
</author>
<published>2015-08-04T12:39:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=135551ea1abd5038d14825514df7e259fd500033'/>
<id>urn:sha1:135551ea1abd5038d14825514df7e259fd500033</id>
<content type='text'>
Fix five occurrences of the checkpatch.pl error:

ERROR: do not use assignment in if condition

The semantic patch that makes this change is:

// &lt;smpl&gt;
@@
identifier i;
expression E;
statement S1, S2;
@@

+ i = E;
  if (
- (i = E)
+ i
  ) S1 else S2

@@
identifier i;
expression E;
statement S;
constant c;
binary operator b;
@@

+ i = E;
  if (
- (i = E)
+ i
  b
  c ) S
// &lt;/smpl&gt;

Signed-off-by: Kris Borer &lt;kborer@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: devio: fix a condition in async_completed()</title>
<updated>2015-05-24T16:29:36Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2015-05-18T12:29:51Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=83ed07c5db71bc02bd646d6eb60b48908235cdf9'/>
<id>urn:sha1:83ed07c5db71bc02bd646d6eb60b48908235cdf9</id>
<content type='text'>
Static checkers complain that the current condition is never true.  It
seems pretty likely that it's a typo and "URB" was intended instead of
"USB".

Fixes: 3d97ff63f899 ('usbdevfs: Use scatter-gather lists for large bulk transfers')
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers/usb/core: devio.c: Removed an uneeded space before tab</title>
<updated>2015-04-10T12:00:22Z</updated>
<author>
<name>Chase Metzger</name>
<email>chasemetzger15@gmail.com</email>
</author>
<published>2015-04-10T04:41:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=00fe52deb45b1a5ef42b0aa82e632e2df012eddc'/>
<id>urn:sha1:00fe52deb45b1a5ef42b0aa82e632e2df012eddc</id>
<content type='text'>
Ran checkpatch.pl on file and removed a warning about an unwanted space before
a tab.

Signed-off-by: Chase Metzger &lt;chasemetzger15@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usbfs: don't leak kernel data in siginfo</title>
<updated>2015-02-24T16:38:46Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2015-02-13T15:54:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f0c2b68198589249afd2b1f2c4e8de8c03e19c16'/>
<id>urn:sha1:f0c2b68198589249afd2b1f2c4e8de8c03e19c16</id>
<content type='text'>
When a signal is delivered, the information in the siginfo structure
is copied to userspace.  Good security practice dicatates that the
unused fields in this structure should be initialized to 0 so that
random kernel stack data isn't exposed to the user.  This patch adds
such an initialization to the two places where usbfs raises signals.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Reported-by: Dave Mielke &lt;dave@mielke.cc&gt;
CC: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
