<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/tty, branch v4.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.3</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2015-10-18T04:24:46Z</updated>
<entry>
<title>Revert "serial: 8250_dma: don't bother DMA with small transfers"</title>
<updated>2015-10-18T04:24:46Z</updated>
<author>
<name>Frederic Danis</name>
<email>frederic.danis@linux.intel.com</email>
</author>
<published>2015-10-09T15:14:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f967fc8f165fadb72166f2bd4785094b3ca21307'/>
<id>urn:sha1:f967fc8f165fadb72166f2bd4785094b3ca21307</id>
<content type='text'>
This reverts commit 9119fba0cfeda6d415c9f068df66838a104b87cb.

This commit prevents from sending "big" file using Bluetooth.
When sending a lot of data quickly through the Bluetooth interface, and
after a variable amount of data sent, transfer fails with error:
    kernel: [  415.247453] Bluetooth: hci0 hardware error 0x00

Found on T100TA.

After reverting this commit, send works fine for any file size.

Signed-off-by: Frederic Danis &lt;frederic.danis@linux.intel.com&gt;
Fixes: 9119fba0cfed (serial: 8250_dma: don't bother DMA with small transfers)
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus &lt;heikki.krogerus@linux.intel.com&gt;
Acked-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers/tty: require read access for controlling terminal</title>
<updated>2015-10-04T18:20:30Z</updated>
<author>
<name>Jann Horn</name>
<email>jann@thejh.net</email>
</author>
<published>2015-10-04T17:29:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0c55627167870255158db1cde0d28366f91c8872'/>
<id>urn:sha1:0c55627167870255158db1cde0d28366f91c8872</id>
<content type='text'>
This is mostly a hardening fix, given that write-only access to other
users' ttys is usually only given through setgid tty executables.

Signed-off-by: Jann Horn &lt;jann@thejh.net&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>serial: 8250: add uart_config entry for PORT_RT2880</title>
<updated>2015-10-04T18:16:12Z</updated>
<author>
<name>Mans Rullgard</name>
<email>mans@mansr.com</email>
</author>
<published>2015-10-02T16:50:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3c5a0357fdb3a9116a48dbdb0abb91fd23fbff80'/>
<id>urn:sha1:3c5a0357fdb3a9116a48dbdb0abb91fd23fbff80</id>
<content type='text'>
This adds an entry to the uart_config table for PORT_RT2880
enabling rx/tx FIFOs.  The UART is actually a Palmchip BK-3103
which is found in several devices from Alchemy/RMI, Ralink, and
Sigma Designs.

Signed-off-by: Mans Rullgard &lt;mans@mansr.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: fix data race on tty_buffer.commit</title>
<updated>2015-10-04T18:03:40Z</updated>
<author>
<name>Dmitry Vyukov</name>
<email>dvyukov@google.com</email>
</author>
<published>2015-09-17T15:17:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=facd885c75067c2a88b72622dfb0fa4b9510da5e'/>
<id>urn:sha1:facd885c75067c2a88b72622dfb0fa4b9510da5e</id>
<content type='text'>
Race on buffer data happens when newly committed data is
picked up by an old flush work in the following scenario:
__tty_buffer_request_room does a plain write of tail-&gt;commit,
no barriers were executed before that.
At this point flush_to_ldisc reads this new value of commit,
and reads buffer data, no barriers in between.
The committed buffer data is not necessary visible to flush_to_ldisc.

Similar bug happens when tty_schedule_flip commits data.

Update commit with smp_store_release and read commit with
smp_load_acquire, as it is commit that signals data readiness.
This is orthogonal to the existing synchronization on tty_buffer.next,
which is required to not dismiss a buffer with unconsumed data.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: fix data race in tty_buffer_flush</title>
<updated>2015-10-04T18:03:40Z</updated>
<author>
<name>Dmitry Vyukov</name>
<email>dvyukov@google.com</email>
</author>
<published>2015-09-17T15:17:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9e6b7cd7e77d4ca43b57c726d9bfa86d06e0567f'/>
<id>urn:sha1:9e6b7cd7e77d4ca43b57c726d9bfa86d06e0567f</id>
<content type='text'>
tty_buffer_flush frees not acquired buffers.
As the result, for example, read of b-&gt;size in tty_buffer_free
can return garbage value which will lead to a huge buffer
hanging in the freelist. This is just the benignest
manifestation of freeing of a not acquired object.
If the object is passed to kfree, heap can be corrupted.

Acquire visibility over the buffer before freeing it.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: fix data race in flush_to_ldisc</title>
<updated>2015-10-04T18:03:40Z</updated>
<author>
<name>Dmitry Vyukov</name>
<email>dvyukov@google.com</email>
</author>
<published>2015-09-17T15:17:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7098296a362a96051fa120abf48f0095818b99cd'/>
<id>urn:sha1:7098296a362a96051fa120abf48f0095818b99cd</id>
<content type='text'>
flush_to_ldisc reads port-&gt;itty and checks that it is not NULL,
concurrently release_tty sets port-&gt;itty to NULL. It is possible
that flush_to_ldisc loads port-&gt;itty once, ensures that it is
not NULL, but then reloads it again and uses. The second load
can already return NULL, which will cause a crash.

Use READ_ONCE to read port-&gt;itty.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c</title>
<updated>2015-10-04T18:03:40Z</updated>
<author>
<name>Kosuke Tatsukawa</name>
<email>tatsu@ab.jp.nec.com</email>
</author>
<published>2015-10-02T08:27:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e81107d4c6bd098878af9796b24edc8d4a9524fd'/>
<id>urn:sha1:e81107d4c6bd098878af9796b24edc8d4a9524fd</id>
<content type='text'>
My colleague ran into a program stall on a x86_64 server, where
n_tty_read() was waiting for data even if there was data in the buffer
in the pty.  kernel stack for the stuck process looks like below.
 #0 [ffff88303d107b58] __schedule at ffffffff815c4b20
 #1 [ffff88303d107bd0] schedule at ffffffff815c513e
 #2 [ffff88303d107bf0] schedule_timeout at ffffffff815c7818
 #3 [ffff88303d107ca0] wait_woken at ffffffff81096bd2
 #4 [ffff88303d107ce0] n_tty_read at ffffffff8136fa23
 #5 [ffff88303d107dd0] tty_read at ffffffff81368013
 #6 [ffff88303d107e20] __vfs_read at ffffffff811a3704
 #7 [ffff88303d107ec0] vfs_read at ffffffff811a3a57
 #8 [ffff88303d107f00] sys_read at ffffffff811a4306
 #9 [ffff88303d107f50] entry_SYSCALL_64_fastpath at ffffffff815c86d7

There seems to be two problems causing this issue.

First, in drivers/tty/n_tty.c, __receive_buf() stores the data and
updates ldata-&gt;commit_head using smp_store_release() and then checks
the wait queue using waitqueue_active().  However, since there is no
memory barrier, __receive_buf() could return without calling
wake_up_interactive_poll(), and at the same time, n_tty_read() could
start to wait in wait_woken() as in the following chart.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
if (waitqueue_active(&amp;tty-&gt;read_wait))
/* Memory operations issued after the
   RELEASE may be completed before the
   RELEASE operation has completed */
                                        add_wait_queue(&amp;tty-&gt;read_wait, &amp;wait);
                                        ...
                                        if (!input_available_p(tty, 0)) {
smp_store_release(&amp;ldata-&gt;commit_head,
                  ldata-&gt;read_head);
                                        ...
                                        timeout = wait_woken(&amp;wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

The second problem is that n_tty_read() also lacks a memory barrier
call and could also cause __receive_buf() to return without calling
wake_up_interactive_poll(), and n_tty_read() to wait in wait_woken()
as in the chart below.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
                                        spin_lock_irqsave(&amp;q-&gt;lock, flags);
                                        /* from add_wait_queue() */
                                        ...
                                        if (!input_available_p(tty, 0)) {
                                        /* Memory operations issued after the
                                           RELEASE may be completed before the
                                           RELEASE operation has completed */
smp_store_release(&amp;ldata-&gt;commit_head,
                  ldata-&gt;read_head);
if (waitqueue_active(&amp;tty-&gt;read_wait))
                                        __add_wait_queue(q, wait);
                                        spin_unlock_irqrestore(&amp;q-&gt;lock,flags);
                                        /* from add_wait_queue() */
                                        ...
                                        timeout = wait_woken(&amp;wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

There are also other places in drivers/tty/n_tty.c which have similar
calls to waitqueue_active(), so instead of adding many memory barrier
calls, this patch simply removes the call to waitqueue_active(),
leaving just wake_up*() behind.

This fixes both problems because, even though the memory access before
or after the spinlocks in both wake_up*() and add_wait_queue() can
sneak into the critical section, it cannot go past it and the critical
section assures that they will be serialized (please see "INTER-CPU
ACQUIRING BARRIER EFFECTS" in Documentation/memory-barriers.txt for a
better explanation).  Moreover, the resulting code is much simpler.

Latency measurement using a ping-pong test over a pty doesn't show any
visible performance drop.

Signed-off-by: Kosuke Tatsukawa &lt;tatsu@ab.jp.nec.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>serial: atmel: fix error path of probe function</title>
<updated>2015-10-04T17:51:42Z</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2015-09-23T06:57:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8f1bd8f2ad2358d6a88c115481ff3e69817d1bde'/>
<id>urn:sha1:8f1bd8f2ad2358d6a88c115481ff3e69817d1bde</id>
<content type='text'>
If atmel_init_gpios fails the port has already been marked as busy (in
line 2629), so this must be undone in the error path.

This bug was introduced because I created the patch that finally
became 722ccf416ac2 ("serial: atmel: fix error handling when
mctrl_gpio_init fails") on top of 3.19 which didn't have commit
6fbb9bdf0f3f ("tty/serial: at91: fix error handling in
atmel_serial_probe()") yet.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Fixes: 722ccf416ac2 ("serial: atmel: fix error handling when mctrl_gpio_init fails")
Acked-by: Nicolas Ferre &lt;nicolas.ferre@atmel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: don't leak cdev in tty_cdev_add()</title>
<updated>2015-10-04T17:51:42Z</updated>
<author>
<name>Leon Yu</name>
<email>chianglungyu@gmail.com</email>
</author>
<published>2015-09-07T13:08:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c1a752ba2d6b8a52879c7ab637cff38359ea9827'/>
<id>urn:sha1:c1a752ba2d6b8a52879c7ab637cff38359ea9827</id>
<content type='text'>
Commit a3a10ce3429e ("Avoid usb reset crashes by making tty_io cdevs truly
dynamic") which mixes using cdev_alloc() and cdev_init() is problematic.
Subsequent call to cdev_init() after cdev_alloc() sets kobj release method
from cdev_dynamic_release() to cdev_default_release() and thus makes it
impossible to free allocated cdev.

This patch also consolidates error path of cdev_add() as cdev can also leak
here if things went wrong.

Signed-off-by: Leon Yu &lt;chianglungyu@gmail.com&gt;
Fixes: a3a10ce3429e ("Avoid usb reset crashes by making tty_io cdevs truly dynamic")
Acked-by: Richard Watts &lt;rrw@kynesim.co.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Revert "serial: imx: remove unbalanced clk_prepare"</title>
<updated>2015-10-04T17:51:42Z</updated>
<author>
<name>Fabio Estevam</name>
<email>fabio.estevam@freescale.com</email>
</author>
<published>2015-08-18T15:43:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0c727a42043f79db210cdde0366f9137b9c6bf5a'/>
<id>urn:sha1:0c727a42043f79db210cdde0366f9137b9c6bf5a</id>
<content type='text'>
This reverts commit 9e7b399d6528eac33a6fbfceb2b92af209c3454d.

Commit ("9e7b399d6528ea") causes the following warning and sometimes
also hangs the system:

------------[ cut here ]------------
 WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
 DEBUG_LOCKS_WARN_ON(in_interrupt())
 Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
Backtrace:
[&lt;80012f08&gt;] (dump_backtrace) from [&lt;800130a4&gt;] (show_stack+0x18/0x1c)
r6:00000364 r5:00000000 r4:00000000 r3:00000000
[&lt;8001308c&gt;] (show_stack) from [&lt;807902b8&gt;] (dump_stack+0x88/0xa4)
[&lt;80790230&gt;] (dump_stack) from [&lt;8002a604&gt;] (warn_slowpath_common+0x80/0xbc)
r5:807945c4 r4:80ab3b50
[&lt;8002a584&gt;] (warn_slowpath_common) from [&lt;8002a6e4&gt;] (warn_slowpath_fmt+0x38/0x40)
r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
[&lt;8002a6b0&gt;] (warn_slowpath_fmt) from [&lt;807945c4&gt;] (mutex_trylock+0x20c/0x22c)
r3:8095d0d8 r2:8095ab28
[&lt;807943b8&gt;] (mutex_trylock) from [&lt;8054c3cc&gt;] (clk_prepare_lock+0x14/0xf4)
r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
[&lt;8054c3b8&gt;] (clk_prepare_lock) from [&lt;8054dbfc&gt;] (clk_prepare+0x18/0x30)
r5:00000037 r4:be3f0c80
[&lt;8054dbe4&gt;] (clk_prepare) from [&lt;8036a600&gt;] (imx_console_write+0x30/0x244)
r4:812d0bc8 r3:8132b9a4

To reproduce the problem we only need to let the board idle for something
like 30 seconds.

Tested on a imx6q-sabresd.

Signed-off-by: Fabio Estevam &lt;fabio.estevam@freescale.com&gt;
Reviewed-by: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
