<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/tty, branch v4.12</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>Revert "tty: fix port buffer locking"</title>
<updated>2017-06-04T08:23:25+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-06-04T08:23:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=fc098af16b9ff6d470d779d8ddcfb2d91869045a'/>
<id>fc098af16b9ff6d470d779d8ddcfb2d91869045a</id>
<content type='text'>
This reverts commit 925bb1ce47f429f69aad35876df7ecd8c53deb7e.

It causes lots of warnings and problems so for now, let's just revert
it.

Reported-by: &lt;valdis.kletnieks@vt.edu&gt;
Reported-by: Russell King &lt;linux@armlinux.org.uk&gt;
Reported-by: Sergey Senozhatsky &lt;sergey.senozhatsky.work@gmail.com&gt;
Reported-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Reported-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Acked-by: Vegard Nossum &lt;vegard.nossum@oracle.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>
This reverts commit 925bb1ce47f429f69aad35876df7ecd8c53deb7e.

It causes lots of warnings and problems so for now, let's just revert
it.

Reported-by: &lt;valdis.kletnieks@vt.edu&gt;
Reported-by: Russell King &lt;linux@armlinux.org.uk&gt;
Reported-by: Sergey Senozhatsky &lt;sergey.senozhatsky.work@gmail.com&gt;
Reported-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Reported-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Acked-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>serial: altera_uart: call iounmap() at driver remove</title>
<updated>2017-05-25T12:36:37+00:00</updated>
<author>
<name>Tobias Klauser</name>
<email>tklauser@distanz.ch</email>
</author>
<published>2017-05-19T11:59:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=59fe2cc8b1c32dd139da80fc8222b5b3290b7a09'/>
<id>59fe2cc8b1c32dd139da80fc8222b5b3290b7a09</id>
<content type='text'>
The driver calls ioremap() in the probe function but doesn't call
iounmap() in the remove function correspondingly. Do so now.

Follow commit 5c9d6abed9e0 ("serial: altera_jtaguart: adding iounmap()")

Cc: Alexey Khoroshilov &lt;khoroshilov@ispras.ru&gt;
Signed-off-by: Tobias Klauser &lt;tklauser@distanz.ch&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>
The driver calls ioremap() in the probe function but doesn't call
iounmap() in the remove function correspondingly. Do so now.

Follow commit 5c9d6abed9e0 ("serial: altera_jtaguart: adding iounmap()")

Cc: Alexey Khoroshilov &lt;khoroshilov@ispras.ru&gt;
Signed-off-by: Tobias Klauser &lt;tklauser@distanz.ch&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>serial: imx: ensure UCR3 and UFCR are setup correctly</title>
<updated>2017-05-25T12:35:53+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2017-05-24T19:38:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6df765dca378bddf994cfd2044acafa501bd800f'/>
<id>6df765dca378bddf994cfd2044acafa501bd800f</id>
<content type='text'>
Commit e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and
RI irqs to be off") has a flaw: While UCR3 and UFCR were modified using
read-modify-write before it switched to write register values
independent of the previous state. That's a good idea in principle (and
that's why I did it) but needs more care.

This patch reinstates read-modify-write for UFCR and for UCR3 ensures
that RXDMUXSEL and ADNIMP are set for post imx1.

Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Acked-by: Mika Penttilä &lt;mika.penttila@nextfour.com&gt;
Tested-by: Mika Penttilä &lt;mika.penttila@nextfour.com&gt;
Acked-by: Steve Twiss &lt;stwiss.opensource@diasemi.com&gt;
Tested-by: Steve Twiss &lt;stwiss.opensource@diasemi.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>
Commit e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and
RI irqs to be off") has a flaw: While UCR3 and UFCR were modified using
read-modify-write before it switched to write register values
independent of the previous state. That's a good idea in principle (and
that's why I did it) but needs more care.

This patch reinstates read-modify-write for UFCR and for UCR3 ensures
that RXDMUXSEL and ADNIMP are set for post imx1.

Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Acked-by: Mika Penttilä &lt;mika.penttila@nextfour.com&gt;
Tested-by: Mika Penttilä &lt;mika.penttila@nextfour.com&gt;
Acked-by: Steve Twiss &lt;stwiss.opensource@diasemi.com&gt;
Tested-by: Steve Twiss &lt;stwiss.opensource@diasemi.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>serial: enable serdev support</title>
<updated>2017-05-18T15:38:25+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-05-18T15:33:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=da4c279942b05727088774df224c0734688b4cbc'/>
<id>da4c279942b05727088774df224c0734688b4cbc</id>
<content type='text'>
Enable serdev support by using the new device-registration helpers.

Reviewed-by: Rob Herring &lt;robh@kernel.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>
Enable serdev support by using the new device-registration helpers.

Reviewed-by: Rob Herring &lt;robh@kernel.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/serdev: add serdev registration interface</title>
<updated>2017-05-18T15:38:24+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-05-18T15:33:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=8cde11b2baa1d02eb2eb955dfd47d9f2a12f12cf'/>
<id>8cde11b2baa1d02eb2eb955dfd47d9f2a12f12cf</id>
<content type='text'>
Add a new interface for registering a serdev controller and clients, and
a helper function to deregister serdev devices (or a tty device) that
were previously registered using the new interface.

Once every driver currently using the tty_port_register_device() helpers
have been vetted and converted to use the new serdev registration
interface (at least for deregistration), we can move serdev registration
to the current helpers and get rid of the serdev-specific functions.

Reviewed-by: Rob Herring &lt;robh@kernel.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>
Add a new interface for registering a serdev controller and clients, and
a helper function to deregister serdev devices (or a tty device) that
were previously registered using the new interface.

Once every driver currently using the tty_port_register_device() helpers
have been vetted and converted to use the new serdev registration
interface (at least for deregistration), we can move serdev registration
to the current helpers and get rid of the serdev-specific functions.

Reviewed-by: Rob Herring &lt;robh@kernel.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>serdev: Restore serdev_device_write_buf for atomic context</title>
<updated>2017-05-18T14:45:53+00:00</updated>
<author>
<name>Stefan Wahren</name>
<email>stefan.wahren@i2se.com</email>
</author>
<published>2017-04-28T11:47:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6bdc00d01e202ae11fa1cae0dacbef895434483d'/>
<id>6bdc00d01e202ae11fa1cae0dacbef895434483d</id>
<content type='text'>
Starting with commit 6fe729c4bdae ("serdev: Add serdev_device_write
subroutine") the function serdev_device_write_buf cannot be used in
atomic context anymore (mutex_lock is sleeping). So restore the old
behavior.

Signed-off-by: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
Fixes: 6fe729c4bdae ("serdev: Add serdev_device_write subroutine")
Acked-by: Rob Herring &lt;robh@kernel.org&gt;
Reviewed-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>
Starting with commit 6fe729c4bdae ("serdev: Add serdev_device_write
subroutine") the function serdev_device_write_buf cannot be used in
atomic context anymore (mutex_lock is sleeping). So restore the old
behavior.

Signed-off-by: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
Fixes: 6fe729c4bdae ("serdev: Add serdev_device_write subroutine")
Acked-by: Rob Herring &lt;robh@kernel.org&gt;
Reviewed-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>serial: core: fix crash in uart_suspend_port</title>
<updated>2017-05-18T14:43:55+00:00</updated>
<author>
<name>Lucas Stach</name>
<email>l.stach@pengutronix.de</email>
</author>
<published>2017-05-11T10:56:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=88e2582e90bb89fe895ff0dceeb5d5ab65d07997'/>
<id>88e2582e90bb89fe895ff0dceeb5d5ab65d07997</id>
<content type='text'>
With serdev we might end up with serial ports that have no cdev exported
to userspace, as they are used as the bus interface to other devices. In
that case serial_match_port() won't be able to find a matching tty_dev.

Skip the irq wakeup enabling in that case, as serdev will make sure to
keep the port active, as long as there are devices depending on it.

Fixes: 8ee3fde04758 (tty_port: register tty ports with serdev bus)
Signed-off-by: Lucas Stach &lt;l.stach@pengutronix.de&gt;
Cc: stable &lt;stable@vger.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>
With serdev we might end up with serial ports that have no cdev exported
to userspace, as they are used as the bus interface to other devices. In
that case serial_match_port() won't be able to find a matching tty_dev.

Skip the irq wakeup enabling in that case, as serdev will make sure to
keep the port active, as long as there are devices depending on it.

Fixes: 8ee3fde04758 (tty_port: register tty ports with serdev bus)
Signed-off-by: Lucas Stach &lt;l.stach@pengutronix.de&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: fix port buffer locking</title>
<updated>2017-05-18T14:43:55+00:00</updated>
<author>
<name>Vegard Nossum</name>
<email>vegard.nossum@oracle.com</email>
</author>
<published>2017-05-11T10:18:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=925bb1ce47f429f69aad35876df7ecd8c53deb7e'/>
<id>925bb1ce47f429f69aad35876df7ecd8c53deb7e</id>
<content type='text'>
tty_insert_flip_string_fixed_flag() is racy against itself when called
from the ioctl(TCXONC, TCION/TCIOFF) path [1] and the flush_to_ldisc()
workqueue path [2].

The problem is that port-&gt;buf.tail-&gt;used is modified without consistent
locking; the ioctl path takes tty-&gt;atomic_write_lock, whereas the workqueue
path takes ldata-&gt;output_lock.

We cannot simply take ldata-&gt;output_lock, since that is specific to the
N_TTY line discipline.

It might seem natural to try to take port-&gt;buf.lock inside
tty_insert_flip_string_fixed_flag() and friends (where port-&gt;buf is
actually used/modified), but this creates problems for flush_to_ldisc()
which takes it before grabbing tty-&gt;ldisc_sem, o_tty-&gt;termios_rwsem,
and ldata-&gt;output_lock.

Therefore, the simplest solution for now seems to be to take
tty-&gt;atomic_write_lock inside tty_port_default_receive_buf(). This lock
is also used in the write path [3] with a consistent ordering.

[1]: Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 tty_send_xchar                     // down_read(&amp;o_tty-&gt;termios_rwsem)
                                    // mutex_lock(&amp;tty-&gt;atomic_write_lock)
 n_tty_ioctl_helper
 n_tty_ioctl
 tty_ioctl                          // down_read(&amp;tty-&gt;ldisc_sem)
 do_vfs_ioctl
 SyS_ioctl

[2]: Workqueue: events_unbound flush_to_ldisc
Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 tty_put_char
 __process_echoes
 commit_echoes                      // mutex_lock(&amp;ldata-&gt;output_lock)
 n_tty_receive_buf_common
 n_tty_receive_buf2
 tty_ldisc_receive_buf              // down_read(&amp;o_tty-&gt;termios_rwsem)
 tty_port_default_receive_buf       // down_read(&amp;tty-&gt;ldisc_sem)
 flush_to_ldisc                     // mutex_lock(&amp;port-&gt;buf.lock)
 process_one_work

[3]: Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 n_tty_write                        // mutex_lock(&amp;ldata-&gt;output_lock)
                                    // down_read(&amp;tty-&gt;termios_rwsem)
 do_tty_write (inline)              // mutex_lock(&amp;tty-&gt;atomic_write_lock)
 tty_write                          // down_read(&amp;tty-&gt;ldisc_sem)
 __vfs_write
 vfs_write
 SyS_write

The bug can result in about a dozen different crashes depending on what
exactly gets corrupted when port-&gt;buf.tail-&gt;used points outside the
buffer.

The patch passes my LOCKDEP/PROVE_LOCKING testing but more testing is
always welcome.

Found using syzkaller.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.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>
tty_insert_flip_string_fixed_flag() is racy against itself when called
from the ioctl(TCXONC, TCION/TCIOFF) path [1] and the flush_to_ldisc()
workqueue path [2].

The problem is that port-&gt;buf.tail-&gt;used is modified without consistent
locking; the ioctl path takes tty-&gt;atomic_write_lock, whereas the workqueue
path takes ldata-&gt;output_lock.

We cannot simply take ldata-&gt;output_lock, since that is specific to the
N_TTY line discipline.

It might seem natural to try to take port-&gt;buf.lock inside
tty_insert_flip_string_fixed_flag() and friends (where port-&gt;buf is
actually used/modified), but this creates problems for flush_to_ldisc()
which takes it before grabbing tty-&gt;ldisc_sem, o_tty-&gt;termios_rwsem,
and ldata-&gt;output_lock.

Therefore, the simplest solution for now seems to be to take
tty-&gt;atomic_write_lock inside tty_port_default_receive_buf(). This lock
is also used in the write path [3] with a consistent ordering.

[1]: Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 tty_send_xchar                     // down_read(&amp;o_tty-&gt;termios_rwsem)
                                    // mutex_lock(&amp;tty-&gt;atomic_write_lock)
 n_tty_ioctl_helper
 n_tty_ioctl
 tty_ioctl                          // down_read(&amp;tty-&gt;ldisc_sem)
 do_vfs_ioctl
 SyS_ioctl

[2]: Workqueue: events_unbound flush_to_ldisc
Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 tty_put_char
 __process_echoes
 commit_echoes                      // mutex_lock(&amp;ldata-&gt;output_lock)
 n_tty_receive_buf_common
 n_tty_receive_buf2
 tty_ldisc_receive_buf              // down_read(&amp;o_tty-&gt;termios_rwsem)
 tty_port_default_receive_buf       // down_read(&amp;tty-&gt;ldisc_sem)
 flush_to_ldisc                     // mutex_lock(&amp;port-&gt;buf.lock)
 process_one_work

[3]: Call Trace:
 tty_insert_flip_string_fixed_flag
 pty_write
 n_tty_write                        // mutex_lock(&amp;ldata-&gt;output_lock)
                                    // down_read(&amp;tty-&gt;termios_rwsem)
 do_tty_write (inline)              // mutex_lock(&amp;tty-&gt;atomic_write_lock)
 tty_write                          // down_read(&amp;tty-&gt;ldisc_sem)
 __vfs_write
 vfs_write
 SyS_write

The bug can result in about a dozen different crashes depending on what
exactly gets corrupted when port-&gt;buf.tail-&gt;used points outside the
buffer.

The patch passes my LOCKDEP/PROVE_LOCKING testing but more testing is
always welcome.

Found using syzkaller.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: ehv_bytechan: clean up init error handling</title>
<updated>2017-05-18T14:43:55+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-04-26T10:30:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=11d4d32158eeaf36fe1073a4a260193d7a19ccf1'/>
<id>11d4d32158eeaf36fe1073a4a260193d7a19ccf1</id>
<content type='text'>
Straighten out the initcall error handling to avoid deregistering a
never-registered tty driver (something which would lead to a
NULL-pointer dereference) in the most unlikely event that driver
registration fails (e.g. we've run out of major numbers).

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>
Straighten out the initcall error handling to avoid deregistering a
never-registered tty driver (something which would lead to a
NULL-pointer dereference) in the most unlikely event that driver
registration fails (e.g. we've run out of major numbers).

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>serial: ifx6x60: fix use-after-free on module unload</title>
<updated>2017-05-18T14:43:55+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-04-26T10:24:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=1e948479b3d63e3ac0ecca13cbf4921c7d17c168'/>
<id>1e948479b3d63e3ac0ecca13cbf4921c7d17c168</id>
<content type='text'>
Make sure to deregister the SPI driver before releasing the tty driver
to avoid use-after-free in the SPI remove callback where the tty
devices are deregistered.

Fixes: 72d4724ea54c ("serial: ifx6x60: Add modem power off function in the platform reboot process")
Cc: stable &lt;stable@vger.kernel.org&gt;     # 3.8
Cc: Jun Chen &lt;jun.d.chen@intel.com&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>
Make sure to deregister the SPI driver before releasing the tty driver
to avoid use-after-free in the SPI remove callback where the tty
devices are deregistered.

Fixes: 72d4724ea54c ("serial: ifx6x60: Add modem power off function in the platform reboot process")
Cc: stable &lt;stable@vger.kernel.org&gt;     # 3.8
Cc: Jun Chen &lt;jun.d.chen@intel.com&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>
</feed>
