<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/usb/serial/console.c, branch linux-4.9.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>USB: serial: console: fix use-after-free after failed setup</title>
<updated>2017-10-18T07:35:41+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-10-04T09:01:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=063b57d556181c796294b1cdf4d649cebc12678a'/>
<id>063b57d556181c796294b1cdf4d649cebc12678a</id>
<content type='text'>
commit 299d7572e46f98534033a9e65973f13ad1ce9047 upstream.

Make sure to reset the USB-console port pointer when console setup fails
in order to avoid having the struct usb_serial be prematurely freed by
the console code when the device is later disconnected.

Fixes: 73e487fdb75f ("[PATCH] USB console: fix disconnection issues")
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&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>
commit 299d7572e46f98534033a9e65973f13ad1ce9047 upstream.

Make sure to reset the USB-console port pointer when console setup fails
in order to avoid having the struct usb_serial be prematurely freed by
the console code when the device is later disconnected.

Fixes: 73e487fdb75f ("[PATCH] USB console: fix disconnection issues")
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>USB: serial: console: fix uninitialised spinlock</title>
<updated>2017-02-26T10:10:52+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-02-08T17:53:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=fef3fdf2d83cd0ca3bc0052ab58baab010929434'/>
<id>fef3fdf2d83cd0ca3bc0052ab58baab010929434</id>
<content type='text'>
commit 14816b16fa0adac24f82492f18fa62c55acabbbe upstream.

Since commit 4a510969374a ("tty: Make tty_files_lock per-tty") a new
tty_struct spin lock is taken in the tty release path, but the
USB-serial-console hack was never updated hence leaving the lock of its
"fake" tty uninitialised. This was eventually detected by lockdep.

Make sure to initialise the new lock also for the fake tty to address
this regression.

Yes, this code is a mess, but cleaning it up is left for another day.

Fixes: 4a510969374a ("tty: Make tty_files_lock per-tty")
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&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>
commit 14816b16fa0adac24f82492f18fa62c55acabbbe upstream.

Since commit 4a510969374a ("tty: Make tty_files_lock per-tty") a new
tty_struct spin lock is taken in the tty release path, but the
USB-serial-console hack was never updated hence leaving the lock of its
"fake" tty uninitialised. This was eventually detected by lockdep.

Make sure to initialise the new lock also for the fake tty to address
this regression.

Yes, this code is a mess, but cleaning it up is left for another day.

Fixes: 4a510969374a ("tty: Make tty_files_lock per-tty")
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Replace ASYNC_INITIALIZED bit and update atomically</title>
<updated>2016-04-30T16:26:55+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2016-04-10T00:53:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d41861ca19c9e96f12a4f1ebbc8255d00909a232'/>
<id>d41861ca19c9e96f12a4f1ebbc8255d00909a232</id>
<content type='text'>
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with
TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers
tty_port_set_initialized() and tty_port_initialized() to abstract
atomic bit ops.

Note: the transforms for test_and_set_bit() and test_and_clear_bit()
are unnecessary as the state transitions are already mutually exclusive;
the tty lock prevents concurrent open/close/hangup.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.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>
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with
TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers
tty_port_set_initialized() and tty_port_initialized() to abstract
atomic bit ops.

Note: the transforms for test_and_set_bit() and test_and_clear_bit()
are unnecessary as the state transitions are already mutually exclusive;
the tty lock prevents concurrent open/close/hangup.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Fix tty_init_termios() declaration</title>
<updated>2016-01-27T22:28:20+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2016-01-10T05:13:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a3123fd0a4a5f9d71afa0ffa82e2086281d81822'/>
<id>a3123fd0a4a5f9d71afa0ffa82e2086281d81822</id>
<content type='text'>
tty_init_termios() never returns an error; re-declare as void. Remove
unnecessary error handling from callers. Remove extern declarations
of tty_free_termios() and free_tty_struct() and re-declare in file
scope.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Acked-by: Johan Hovold &lt;johan@kernel.org&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>
tty_init_termios() never returns an error; re-declare as void. Remove
unnecessary error handling from callers. Remove extern declarations
of tty_free_termios() and free_tty_struct() and re-declare in file
scope.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Acked-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: console: add dummy __module_get</title>
<updated>2015-02-26T16:06:39+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-02-16T06:17:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5ee0089b1f7057d8f783db37b2a8116cd114f6e5'/>
<id>5ee0089b1f7057d8f783db37b2a8116cd114f6e5</id>
<content type='text'>
Add call to __module_get when initialising the fake tty in
usb_console_setup to match the module_put in release_one_tty.

Note that the tty-driver (i.e. usb-serial core) must be compiled-in to
enable the usb console so the __module_get is essentially a noop as
driver-&gt;owner will be null.

Reported-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add call to __module_get when initialising the fake tty in
usb_console_setup to match the module_put in release_one_tty.

Note that the tty-driver (i.e. usb-serial core) must be compiled-in to
enable the usb console so the __module_get is essentially a noop as
driver-&gt;owner will be null.

Reported-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: console: fix potential use after free</title>
<updated>2015-01-10T11:48:21+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-05T15:04:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=32a4bf2e81ec378e5925d4e069e0677a6c86a6ad'/>
<id>32a4bf2e81ec378e5925d4e069e0677a6c86a6ad</id>
<content type='text'>
Use tty kref to release the fake tty in usb_console_setup to avoid use
after free if the underlying serial driver has acquired a reference.

Note that using the tty destructor release_one_tty requires some more
state to be initialised.

Fixes: 4a90f09b20f4 ("tty: usb-serial krefs")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use tty kref to release the fake tty in usb_console_setup to avoid use
after free if the underlying serial driver has acquired a reference.

Note that using the tty destructor release_one_tty requires some more
state to be initialised.

Fixes: 4a90f09b20f4 ("tty: usb-serial krefs")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: console: fix uninitialised ldisc semaphore</title>
<updated>2015-01-10T11:48:15+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-05T15:04:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d269d4434c72ed0da3a9b1230c30da82c4918c63'/>
<id>d269d4434c72ed0da3a9b1230c30da82c4918c63</id>
<content type='text'>
The USB console currently allocates a temporary fake tty which is used
to pass terminal settings to the underlying serial driver.

The tty struct is not fully initialised, something which can lead to a
lockdep warning (or worse) if a serial driver tries to acquire a
line-discipline reference:

	usbserial: USB Serial support registered for pl2303
	pl2303 1-2.1:1.0: pl2303 converter detected
	usb 1-2.1: pl2303 converter now attached to ttyUSB0
	INFO: trying to register non-static key.
	the code is fine but needs lockdep annotation.
	turning off the locking correctness validator.
	CPU: 0 PID: 68 Comm: udevd Tainted: G        W      3.18.0-rc5 #10
	[&lt;c0016f04&gt;] (unwind_backtrace) from [&lt;c0013978&gt;] (show_stack+0x20/0x24)
	[&lt;c0013978&gt;] (show_stack) from [&lt;c0449794&gt;] (dump_stack+0x24/0x28)
	[&lt;c0449794&gt;] (dump_stack) from [&lt;c006f730&gt;] (__lock_acquire+0x1e50/0x2004)
	[&lt;c006f730&gt;] (__lock_acquire) from [&lt;c0070128&gt;] (lock_acquire+0xe4/0x18c)
	[&lt;c0070128&gt;] (lock_acquire) from [&lt;c027c6f8&gt;] (ldsem_down_read_trylock+0x78/0x90)
	[&lt;c027c6f8&gt;] (ldsem_down_read_trylock) from [&lt;c027a1cc&gt;] (tty_ldisc_ref+0x24/0x58)
	[&lt;c027a1cc&gt;] (tty_ldisc_ref) from [&lt;c0340760&gt;] (usb_serial_handle_dcd_change+0x48/0xe8)
	[&lt;c0340760&gt;] (usb_serial_handle_dcd_change) from [&lt;bf000484&gt;] (pl2303_read_int_callback+0x210/0x220 [pl2303])
	[&lt;bf000484&gt;] (pl2303_read_int_callback [pl2303]) from [&lt;c031624c&gt;] (__usb_hcd_giveback_urb+0x80/0x140)
	[&lt;c031624c&gt;] (__usb_hcd_giveback_urb) from [&lt;c0316fc0&gt;] (usb_giveback_urb_bh+0x98/0xd4)
	[&lt;c0316fc0&gt;] (usb_giveback_urb_bh) from [&lt;c0042e44&gt;] (tasklet_hi_action+0x9c/0x108)
	[&lt;c0042e44&gt;] (tasklet_hi_action) from [&lt;c0042380&gt;] (__do_softirq+0x148/0x42c)
	[&lt;c0042380&gt;] (__do_softirq) from [&lt;c00429cc&gt;] (irq_exit+0xd8/0x114)
	[&lt;c00429cc&gt;] (irq_exit) from [&lt;c007ae58&gt;] (__handle_domain_irq+0x84/0xdc)
	[&lt;c007ae58&gt;] (__handle_domain_irq) from [&lt;c000879c&gt;] (omap_intc_handle_irq+0xd8/0xe0)
	[&lt;c000879c&gt;] (omap_intc_handle_irq) from [&lt;c0014544&gt;] (__irq_svc+0x44/0x7c)
	Exception stack(0xdf4e7f08 to 0xdf4e7f50)
	7f00:                   debc0b80 df4e7f5c 00000000 00000000 debc0b80 be8da96c
	7f20: 00000000 00000128 c000fc84 df4e6000 00000000 df4e7f94 00000004 df4e7f50
	7f40: c038ebc0 c038d74c 600f0013 ffffffff
	[&lt;c0014544&gt;] (__irq_svc) from [&lt;c038d74c&gt;] (___sys_sendmsg.part.29+0x0/0x2e0)
	[&lt;c038d74c&gt;] (___sys_sendmsg.part.29) from [&lt;c038ec08&gt;] (SyS_sendmsg+0x18/0x1c)
	[&lt;c038ec08&gt;] (SyS_sendmsg) from [&lt;c000fa00&gt;] (ret_fast_syscall+0x0/0x48)
	console [ttyUSB0] enabled

Fixes: 36697529b5bb ("tty: Replace ldisc locking with ldisc_sem")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The USB console currently allocates a temporary fake tty which is used
to pass terminal settings to the underlying serial driver.

The tty struct is not fully initialised, something which can lead to a
lockdep warning (or worse) if a serial driver tries to acquire a
line-discipline reference:

	usbserial: USB Serial support registered for pl2303
	pl2303 1-2.1:1.0: pl2303 converter detected
	usb 1-2.1: pl2303 converter now attached to ttyUSB0
	INFO: trying to register non-static key.
	the code is fine but needs lockdep annotation.
	turning off the locking correctness validator.
	CPU: 0 PID: 68 Comm: udevd Tainted: G        W      3.18.0-rc5 #10
	[&lt;c0016f04&gt;] (unwind_backtrace) from [&lt;c0013978&gt;] (show_stack+0x20/0x24)
	[&lt;c0013978&gt;] (show_stack) from [&lt;c0449794&gt;] (dump_stack+0x24/0x28)
	[&lt;c0449794&gt;] (dump_stack) from [&lt;c006f730&gt;] (__lock_acquire+0x1e50/0x2004)
	[&lt;c006f730&gt;] (__lock_acquire) from [&lt;c0070128&gt;] (lock_acquire+0xe4/0x18c)
	[&lt;c0070128&gt;] (lock_acquire) from [&lt;c027c6f8&gt;] (ldsem_down_read_trylock+0x78/0x90)
	[&lt;c027c6f8&gt;] (ldsem_down_read_trylock) from [&lt;c027a1cc&gt;] (tty_ldisc_ref+0x24/0x58)
	[&lt;c027a1cc&gt;] (tty_ldisc_ref) from [&lt;c0340760&gt;] (usb_serial_handle_dcd_change+0x48/0xe8)
	[&lt;c0340760&gt;] (usb_serial_handle_dcd_change) from [&lt;bf000484&gt;] (pl2303_read_int_callback+0x210/0x220 [pl2303])
	[&lt;bf000484&gt;] (pl2303_read_int_callback [pl2303]) from [&lt;c031624c&gt;] (__usb_hcd_giveback_urb+0x80/0x140)
	[&lt;c031624c&gt;] (__usb_hcd_giveback_urb) from [&lt;c0316fc0&gt;] (usb_giveback_urb_bh+0x98/0xd4)
	[&lt;c0316fc0&gt;] (usb_giveback_urb_bh) from [&lt;c0042e44&gt;] (tasklet_hi_action+0x9c/0x108)
	[&lt;c0042e44&gt;] (tasklet_hi_action) from [&lt;c0042380&gt;] (__do_softirq+0x148/0x42c)
	[&lt;c0042380&gt;] (__do_softirq) from [&lt;c00429cc&gt;] (irq_exit+0xd8/0x114)
	[&lt;c00429cc&gt;] (irq_exit) from [&lt;c007ae58&gt;] (__handle_domain_irq+0x84/0xdc)
	[&lt;c007ae58&gt;] (__handle_domain_irq) from [&lt;c000879c&gt;] (omap_intc_handle_irq+0xd8/0xe0)
	[&lt;c000879c&gt;] (omap_intc_handle_irq) from [&lt;c0014544&gt;] (__irq_svc+0x44/0x7c)
	Exception stack(0xdf4e7f08 to 0xdf4e7f50)
	7f00:                   debc0b80 df4e7f5c 00000000 00000000 debc0b80 be8da96c
	7f20: 00000000 00000128 c000fc84 df4e6000 00000000 df4e7f94 00000004 df4e7f50
	7f40: c038ebc0 c038d74c 600f0013 ffffffff
	[&lt;c0014544&gt;] (__irq_svc) from [&lt;c038d74c&gt;] (___sys_sendmsg.part.29+0x0/0x2e0)
	[&lt;c038d74c&gt;] (___sys_sendmsg.part.29) from [&lt;c038ec08&gt;] (SyS_sendmsg+0x18/0x1c)
	[&lt;c038ec08&gt;] (SyS_sendmsg) from [&lt;c000fa00&gt;] (ret_fast_syscall+0x0/0x48)
	console [ttyUSB0] enabled

Fixes: 36697529b5bb ("tty: Replace ldisc locking with ldisc_sem")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: delete non-required instances of include &lt;linux/init.h&gt;</title>
<updated>2014-01-08T23:01:39+00:00</updated>
<author>
<name>Paul Gortmaker</name>
<email>paul.gortmaker@windriver.com</email>
</author>
<published>2014-01-08T16:08:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=803a536243b3a1ed2289f41897b11b72bd083309'/>
<id>803a536243b3a1ed2289f41897b11b72bd083309</id>
<content type='text'>
None of these files are actually using any __init type directives
and hence don't need to include &lt;linux/init.h&gt;.  Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.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>
None of these files are actually using any __init type directives
and hence don't need to include &lt;linux/init.h&gt;.  Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: serial: remove redundant OOM messages</title>
<updated>2014-01-03T20:31:46+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2013-12-29T18:22:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=10c642d0772ac1391ae4f9fdeb13217ab019117a'/>
<id>10c642d0772ac1391ae4f9fdeb13217ab019117a</id>
<content type='text'>
Remove redundant error messages on allocation failures, which have
already been logged.

Cc: Joe Perches &lt;joe@perches.com&gt;
Signed-off-by: Johan Hovold &lt;jhovold@gmail.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>
Remove redundant error messages on allocation failures, which have
already been logged.

Cc: Joe Perches &lt;joe@perches.com&gt;
Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: console: remove unnecessary operations test</title>
<updated>2013-07-23T23:24:32+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2013-06-26T14:47:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=c7b13475b4466adcdcd8378f12b4ee416ef9b98b'/>
<id>c7b13475b4466adcdcd8378f12b4ee416ef9b98b</id>
<content type='text'>
Remove unnecessary tests for open and write operations as these are set
to the generic implementations by usb-serial core if left unset by a
subdriver.

Signed-off-by: Johan Hovold &lt;jhovold@gmail.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>
Remove unnecessary tests for open and write operations as these are set
to the generic implementations by usb-serial core if left unset by a
subdriver.

Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
