<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/tty/tty_port.c, branch linux-5.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2019-03-27T16:21:21Z</updated>
<entry>
<title>tty: fix NULL pointer issue when tty_port ops is not set</title>
<updated>2019-03-27T16:21:21Z</updated>
<author>
<name>Fabien Dessenne</name>
<email>fabien.dessenne@st.com</email>
</author>
<published>2019-03-21T15:43:26Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f4e68d58cf2b20a581759bbc7228052534652673'/>
<id>urn:sha1:f4e68d58cf2b20a581759bbc7228052534652673</id>
<content type='text'>
Unlike 'client_ops' which is initialized to 'default_client_ops', the
port operations 'ops' may be left to NULL.
Check the 'ops' value before checking the 'ops-&gt;x' value.

Signed-off-by: Fabien Dessenne &lt;fabien.dessenne@st.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: do not set TTY_IO_ERROR flag if console port</title>
<updated>2018-11-27T08:58:11Z</updated>
<author>
<name>Chanho Park</name>
<email>parkch98@gmail.com</email>
</author>
<published>2018-11-22T09:23:47Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2a48602615e0a2f563549c7d5c8d507f904cf96e'/>
<id>urn:sha1:2a48602615e0a2f563549c7d5c8d507f904cf96e</id>
<content type='text'>
Since Commit 761ed4a94582 ('tty: serial_core: convert uart_close to use
tty_port_close') and Commit 4dda864d7307 ('tty: serial_core: Fix serial
console crash on port shutdown), a serial port which is used as
console can be stuck when logging out if there is a remained process.
After logged out, agetty will try to grab the serial port but it will
be failed because the previous process did not release the port
correctly. To fix this, TTY_IO_ERROR bit should not be enabled of
tty_port_close if the port is console port.

Reproduce step:
- Run background processes from serial console
$ while true; do sleep 10; done &amp;

- Log out
$ logout
-&gt; Stuck

- Read journal log by journalctl | tail
Jan 28 16:07:01 ubuntu systemd[1]: Stopped Serial Getty on ttyAMA0.
Jan 28 16:07:01 ubuntu systemd[1]: Started Serial Getty on ttyAMA0.
Jan 28 16:07:02 ubuntu agetty[1643]: /dev/ttyAMA0: not a tty

Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Cc: Geert Uytterhoeven &lt;geert+renesas@glider.be&gt;
Cc: Rob Herring &lt;robh@kernel.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.com&gt;
Signed-off-by: Chanho Park &lt;parkch98@gmail.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty_port: Remove incorrect whitespace after comments</title>
<updated>2018-09-18T14:07:25Z</updated>
<author>
<name>Tobin C. Harding</name>
<email>me@tobin.cc</email>
</author>
<published>2018-09-12T07:50:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=863299001b39280b3be9f5c627d23debe66aa71b'/>
<id>urn:sha1:863299001b39280b3be9f5c627d23debe66aa71b</id>
<content type='text'>
Currently there are a bunch of kernel-doc function comments that have a
line of whitespace after the comment and before the function they
comment - this is incorrect, there should be no whitespace here.

Remove incorrect whitespace between comment and associated function.

Signed-off-by: Tobin C. Harding &lt;me@tobin.cc&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: add SPDX identifiers to all remaining files in drivers/tty/</title>
<updated>2017-11-08T12:08:12Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-11-06T17:11:51Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e3b3d0f549c1d19b94e6ac55c66643166ea649ef'/>
<id>urn:sha1:e3b3d0f549c1d19b94e6ac55c66643166ea649ef</id>
<content type='text'>
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/tty files files with the correct SPDX license
identifier based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Jiri Slaby &lt;jslaby@suse.com&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Cc: Chris Metcalf &lt;cmetcalf@mellanox.com&gt;
Cc: Jiri Kosina &lt;jikos@kernel.org&gt;
Cc: David Sterba &lt;dsterba@suse.com&gt;
Cc: James Hogan &lt;jhogan@kernel.org&gt;
Cc: Rob Herring &lt;robh@kernel.org&gt;
Cc: Eric Anholt &lt;eric@anholt.net&gt;
Cc: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
Cc: Florian Fainelli &lt;f.fainelli@gmail.com&gt;
Cc: Ray Jui &lt;rjui@broadcom.com&gt;
Cc: Scott Branden &lt;sbranden@broadcom.com&gt;
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: "James E.J. Bottomley" &lt;jejb@parisc-linux.org&gt;
Cc: Helge Deller &lt;deller@gmx.de&gt;
Cc: Joachim Eastwood &lt;manabian@gmail.com&gt;
Cc: Matthias Brugger &lt;matthias.bgg@gmail.com&gt;
Cc: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
Cc: Tobias Klauser &lt;tklauser@distanz.ch&gt;
Cc: Russell King &lt;linux@armlinux.org.uk&gt;
Cc: Vineet Gupta &lt;vgupta@synopsys.com&gt;
Cc: Richard Genoud &lt;richard.genoud@gmail.com&gt;
Cc: Alexander Shiyan &lt;shc_work@mail.ru&gt;
Cc: Baruch Siach &lt;baruch@tkos.co.il&gt;
Cc: "Maciej W. Rozycki" &lt;macro@linux-mips.org&gt;
Cc: "Uwe Kleine-König" &lt;kernel@pengutronix.de&gt;
Cc: Pat Gefre &lt;pfg@sgi.com&gt;
Cc: "Guilherme G. Piccoli" &lt;gpiccoli@linux.vnet.ibm.com&gt;
Cc: Jason Wessel &lt;jason.wessel@windriver.com&gt;
Cc: Vladimir Zapolskiy &lt;vz@mleia.com&gt;
Cc: Sylvain Lemieux &lt;slemieux.tyco@gmail.com&gt;
Cc: Carlo Caione &lt;carlo@caione.org&gt;
Cc: Kevin Hilman &lt;khilman@baylibre.com&gt;
Cc: Liviu Dudau &lt;liviu.dudau@arm.com&gt;
Cc: Sudeep Holla &lt;sudeep.holla@arm.com&gt;
Cc: Lorenzo Pieralisi &lt;lorenzo.pieralisi@arm.com&gt;
Cc: Andy Gross &lt;andy.gross@linaro.org&gt;
Cc: David Brown &lt;david.brown@linaro.org&gt;
Cc: "Andreas Färber" &lt;afaerber@suse.de&gt;
Cc: Kevin Cernekee &lt;cernekee@gmail.com&gt;
Cc: Laxman Dewangan &lt;ldewangan@nvidia.com&gt;
Cc: Thierry Reding &lt;thierry.reding@gmail.com&gt;
Cc: Jonathan Hunter &lt;jonathanh@nvidia.com&gt;
Cc: Barry Song &lt;baohua@kernel.org&gt;
Cc: Patrice Chotard &lt;patrice.chotard@st.com&gt;
Cc: Maxime Coquelin &lt;mcoquelin.stm32@gmail.com&gt;
Cc: Alexandre Torgue &lt;alexandre.torgue@st.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Peter Korsgaard &lt;jacmet@sunsite.dk&gt;
Cc: Timur Tabi &lt;timur@tabi.org&gt;
Cc: Tony Prisk &lt;linux@prisktech.co.nz&gt;
Cc: Michal Simek &lt;michal.simek@xilinx.com&gt;
Cc: "Sören Brinkmann" &lt;soren.brinkmann@xilinx.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Kate Stewart &lt;kstewart@linuxfoundation.org&gt;
Cc: Philippe Ombredanne &lt;pombredanne@nexb.com&gt;
Cc: Jiri Slaby &lt;jslaby@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ttyport: trivial fix for some typo in comments</title>
<updated>2017-09-18T16:31:48Z</updated>
<author>
<name>Antonio Borneo</name>
<email>borneo.antonio@gmail.com</email>
</author>
<published>2017-09-08T06:59:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1926e5d37bf8488e9b129abfdfab4c49598c9ee9'/>
<id>urn:sha1:1926e5d37bf8488e9b129abfdfab4c49598c9ee9</id>
<content type='text'>
Fix some minor typo spotted in comments:
- s/wit ha/with a/
- s/doestroyed/destroyed/

Signed-off-by: Antonio Borneo &lt;borneo.antonio@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Revert "tty: fix port buffer locking"</title>
<updated>2017-06-04T08:23:25Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-06-04T08:23:25Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=fc098af16b9ff6d470d779d8ddcfb2d91869045a'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>tty/serdev: add serdev registration interface</title>
<updated>2017-05-18T15:38:24Z</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-05-18T15:33:00Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=8cde11b2baa1d02eb2eb955dfd47d9f2a12f12cf'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>tty: fix port buffer locking</title>
<updated>2017-05-18T14:43:55Z</updated>
<author>
<name>Vegard Nossum</name>
<email>vegard.nossum@oracle.com</email>
</author>
<published>2017-05-11T10:18:52Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=925bb1ce47f429f69aad35876df7ecd8c53deb7e'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>Revert "tty_port: register tty ports with serdev bus"</title>
<updated>2017-05-18T14:41:49Z</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-04-11T17:07:28Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d3ba126a226a6b6da021ebfea444a2a807cde945'/>
<id>urn:sha1:d3ba126a226a6b6da021ebfea444a2a807cde945</id>
<content type='text'>
This reverts commit 8ee3fde047589dc9c201251f07d0ca1dc776feca.

The new serdev bus hooked into the tty layer in
tty_port_register_device() by registering a serdev controller instead of
a tty device whenever a serdev client is present, and by deregistering
the controller in the tty-port destructor. This is broken in several
ways:

Firstly, it leads to a NULL-pointer dereference whenever a tty driver
later deregisters its devices as no corresponding character device will
exist.

Secondly, far from every tty driver uses tty-port refcounting (e.g.
serial core) so the serdev devices might never be deregistered or
deallocated.

Thirdly, deregistering at tty-port destruction is too late as the
underlying device and structures may be long gone by then. A port is not
released before an open tty device is closed, something which a
registered serdev client can prevent from ever happening. A driver
callback while the device is gone typically also leads to crashes.

Many tty drivers even keep their ports around until the driver is
unloaded (e.g. serial core), something which even if a late callback
never happens, leads to leaks if a device is unbound from its driver and
is later rebound.

The right solution here is to add a new tty_port_unregister_device()
helper and to never call tty_device_unregister() whenever the port has
been claimed by serdev, but since this requires modifying just about
every tty driver (and multiple subsystems) it will need to be done
incrementally.

Reverting the offending patch is the first step in fixing the broken
lifetime assumptions. A follow-up patch will add a new pair of
tty-device registration helpers, which a vetted tty driver can use to
support serdev (initially serial core). When every tty driver uses the
serdev helpers (at least for deregistration), we can add serdev
registration to tty_port_register_device() again.

Note that this also fixes another issue with serdev, which currently
allocates and registers a serdev controller for every tty device
registered using tty_port_device_register() only to immediately
deregister and deallocate it when the corresponding OF node or serdev
child node is missing. This should be addressed before enabling serdev
for hot-pluggable buses.

Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Reviewed-by: Rob Herring &lt;robh@kernel.org&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sched/headers: Prepare to move signal wakeup &amp; sigpending methods from &lt;linux/sched.h&gt; into &lt;linux/sched/signal.h&gt;</title>
<updated>2017-03-02T07:42:32Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@kernel.org</email>
</author>
<published>2017-02-02T18:15:33Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=174cd4b1e5fbd0d74c68cf3a74f5bd4923485512'/>
<id>urn:sha1:174cd4b1e5fbd0d74c68cf3a74f5bd4923485512</id>
<content type='text'>
Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Mike Galbraith &lt;efault@gmx.de&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
</feed>
