<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/tty/tty_io.c, branch linux-3.13.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>tty: Set correct tty name in 'active' sysfs attribute</title>
<updated>2014-04-22T23:49:20+00:00</updated>
<author>
<name>Hannes Reinecke</name>
<email>hare@suse.de</email>
</author>
<published>2014-02-27T11:30:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=f97254211de168ebd5ac77032dc25d08647e81c9'/>
<id>f97254211de168ebd5ac77032dc25d08647e81c9</id>
<content type='text'>
commit 723abd87f6e536f1353c8f64f621520bc29523a3 upstream.

The 'active' sysfs attribute should refer to the currently active tty
devices the console is running on, not the currently active console. The
console structure doesn't refer to any device in sysfs, only the tty the
console is running on has. So we need to print out the tty names in
'active', not the console names.

There is one special-case, which is tty0. If the console is directed to
it, we want 'tty0' to show up in the file, so user-space knows that the
messages get forwarded to the active VT. The -&gt;device() callback would
resolve tty0, though. Hence, treat it special and don't call into the VT
layer to resolve it (plymouth is known to depend on it).

Cc: Lennart Poettering &lt;lennart@poettering.net&gt;
Cc: Kay Sievers &lt;kay@vrfy.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&gt;
Signed-off-by: Werner Fink &lt;werner@suse.de&gt;
Signed-off-by: Hannes Reinecke &lt;hare@suse.de&gt;
Signed-off-by: David Herrmann &lt;dh.herrmann@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>
commit 723abd87f6e536f1353c8f64f621520bc29523a3 upstream.

The 'active' sysfs attribute should refer to the currently active tty
devices the console is running on, not the currently active console. The
console structure doesn't refer to any device in sysfs, only the tty the
console is running on has. So we need to print out the tty names in
'active', not the console names.

There is one special-case, which is tty0. If the console is directed to
it, we want 'tty0' to show up in the file, so user-space knows that the
messages get forwarded to the active VT. The -&gt;device() callback would
resolve tty0, though. Hence, treat it special and don't call into the VT
layer to resolve it (plymouth is known to depend on it).

Cc: Lennart Poettering &lt;lennart@poettering.net&gt;
Cc: Kay Sievers &lt;kay@vrfy.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&gt;
Signed-off-by: Werner Fink &lt;werner@suse.de&gt;
Signed-off-by: Hannes Reinecke &lt;hare@suse.de&gt;
Signed-off-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Reset hupped state on open</title>
<updated>2013-11-25T16:56:49+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-11-19T13:46:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d4855e1fc03c2bb32dd64badf51cec5a2a26ab2a'/>
<id>d4855e1fc03c2bb32dd64badf51cec5a2a26ab2a</id>
<content type='text'>
A common security idiom is to hangup the current tty (via vhangup())
after forking but before execing a root shell. This hangs up any
existing opens which other processes may have and ensures subsequent
opens have the necessary permissions to open the root shell tty/pty.

Reset the TTY_HUPPED state after the driver has successfully
returned the opened tty (perform the reset while the tty is locked
to avoid racing with concurrent hangups).

Reported-by: Heorhi Valakhanovich &lt;valahanovich@tut.by&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.12
Tested-by: Heorhi Valakhanovich &lt;valahanovich@tut.by&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>
A common security idiom is to hangup the current tty (via vhangup())
after forking but before execing a root shell. This hangs up any
existing opens which other processes may have and ensures subsequent
opens have the necessary permissions to open the root shell tty/pty.

Reset the TTY_HUPPED state after the driver has successfully
returned the opened tty (perform the reset while the tty is locked
to avoid racing with concurrent hangups).

Reported-by: Heorhi Valakhanovich &lt;valahanovich@tut.by&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.12
Tested-by: Heorhi Valakhanovich &lt;valahanovich@tut.by&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: disassociate_ctty() sends the extra SIGCONT</title>
<updated>2013-09-18T01:53:32+00:00</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-09-15T15:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=03e1261778cca782d41a3d8e3945ca88cf93e01e'/>
<id>03e1261778cca782d41a3d8e3945ca88cf93e01e</id>
<content type='text'>
Starting from v3.10 (probably commit f91e2590410b: "tty: Signal
foreground group processes in hangup") disassociate_ctty() sends SIGCONT
if tty &amp;&amp; on_exit.  This breaks LSB test-suite, in particular test8 in
_exit.c and test40 in sigcon5.c.

Put the "!on_exit" check back to restore the old behaviour.

Review by Peter Hurley:
 "Yes, this regression was introduced by me in that commit.  The effect
  of the regression is that ptys will receive a SIGCONT when, in similar
  circumstances, ttys would not.

  The fact that two test vectors accidentally tripped over this
  regression suggests that some other apps may as well.

  Thanks for catching this"

Cc: stable@vger.kernel.org # v3.10+
Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Reported-by: Karel Srot &lt;ksrot@redhat.com&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Starting from v3.10 (probably commit f91e2590410b: "tty: Signal
foreground group processes in hangup") disassociate_ctty() sends SIGCONT
if tty &amp;&amp; on_exit.  This breaks LSB test-suite, in particular test8 in
_exit.c and test40 in sigcon5.c.

Put the "!on_exit" check back to restore the old behaviour.

Review by Peter Hurley:
 "Yes, this regression was introduced by me in that commit.  The effect
  of the regression is that ptys will receive a SIGCONT when, in similar
  circumstances, ttys would not.

  The fact that two test vectors accidentally tripped over this
  regression suggests that some other apps may as well.

  Thanks for catching this"

Cc: stable@vger.kernel.org # v3.10+
Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Reported-by: Karel Srot &lt;ksrot@redhat.com&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Only hangup once</title>
<updated>2013-08-02T03:47:42+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-07-31T18:05:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=cb50e5235b8ae5aa0fe422eaaa8e444024c5bd98'/>
<id>cb50e5235b8ae5aa0fe422eaaa8e444024c5bd98</id>
<content type='text'>
Instrumented testing shows a tty can be hungup multiple times [1].
Although concurrent hangups are properly serialized, multiple
hangups for the same tty should be prevented.

If tty has already been HUPPED, abort hangup. Note it is not
necessary to cleanup file *redirect on subsequent hangups,
as only TIOCCONS can set that value and ioctls are disabled
after hangup.

[1]
Test performed by simulating a concurrent async hangup via
tty_hangup() with a sync hangup via tty_vhangup(), while
__tty_hangup() was instrumented with:

	diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
	index 26bb78c..fe8b061 100644
	--- a/drivers/tty/tty_io.c
	+++ b/drivers/tty/tty_io.c
	@@ -629,6 +629,8 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)

		tty_lock(tty);

	+	WARN_ON(test_bit(TTY_HUPPED, &amp;tty-&gt;flags));
	+
		/* some functions below drop BTM, so we need this bit */
		set_bit(TTY_HUPPING, &amp;tty-&gt;flags);

Test result:

WARNING: at /home/peter/src/kernels/mainline/drivers/tty/tty_io.c:632 __tty_hangup+0x459/0x460()
Modules linked in: ip6table_filter ip6_tables ebtable_nat &lt;...snip...&gt;
CPU: 6 PID: 1197 Comm: kworker/6:2 Not tainted 3.10.0-0+rfcomm-xeon #0+rfcomm
Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
Workqueue: events do_tty_hangup
 0000000000000009 ffff8802b16d7d18 ffffffff816b553e ffff8802b16d7d58
 ffffffff810407e0 ffff880254f95c00 ffff880254f95c00 ffff8802bfd92b00
 ffff8802bfd96b00 ffff880254f95e40 0000000000000180 ffff8802b16d7d68
Call Trace:
 [&lt;ffffffff816b553e&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff810407e0&gt;] warn_slowpath_common+0x70/0xa0
 [&lt;ffffffff8104082a&gt;] warn_slowpath_null+0x1a/0x20
 [&lt;ffffffff813fb279&gt;] __tty_hangup+0x459/0x460
 [&lt;ffffffff8107409c&gt;] ? finish_task_switch+0xbc/0xe0
 [&lt;ffffffff813fb297&gt;] do_tty_hangup+0x17/0x20
 [&lt;ffffffff8105fd6f&gt;] process_one_work+0x16f/0x450
 [&lt;ffffffff8106007c&gt;] process_scheduled_works+0x2c/0x40
 [&lt;ffffffff8106060a&gt;] worker_thread+0x26a/0x380
 [&lt;ffffffff810603a0&gt;] ? rescuer_thread+0x310/0x310
 [&lt;ffffffff810698a0&gt;] kthread+0xc0/0xd0
 [&lt;ffffffff816b0000&gt;] ? destroy_compound_page+0x65/0x92
 [&lt;ffffffff810697e0&gt;] ? kthread_create_on_node+0x130/0x130
 [&lt;ffffffff816c495c&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff810697e0&gt;] ? kthread_create_on_node+0x130/0x130
---[ end trace 98d9f01536cf411e ]---

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>
Instrumented testing shows a tty can be hungup multiple times [1].
Although concurrent hangups are properly serialized, multiple
hangups for the same tty should be prevented.

If tty has already been HUPPED, abort hangup. Note it is not
necessary to cleanup file *redirect on subsequent hangups,
as only TIOCCONS can set that value and ioctls are disabled
after hangup.

[1]
Test performed by simulating a concurrent async hangup via
tty_hangup() with a sync hangup via tty_vhangup(), while
__tty_hangup() was instrumented with:

	diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
	index 26bb78c..fe8b061 100644
	--- a/drivers/tty/tty_io.c
	+++ b/drivers/tty/tty_io.c
	@@ -629,6 +629,8 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)

		tty_lock(tty);

	+	WARN_ON(test_bit(TTY_HUPPED, &amp;tty-&gt;flags));
	+
		/* some functions below drop BTM, so we need this bit */
		set_bit(TTY_HUPPING, &amp;tty-&gt;flags);

Test result:

WARNING: at /home/peter/src/kernels/mainline/drivers/tty/tty_io.c:632 __tty_hangup+0x459/0x460()
Modules linked in: ip6table_filter ip6_tables ebtable_nat &lt;...snip...&gt;
CPU: 6 PID: 1197 Comm: kworker/6:2 Not tainted 3.10.0-0+rfcomm-xeon #0+rfcomm
Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
Workqueue: events do_tty_hangup
 0000000000000009 ffff8802b16d7d18 ffffffff816b553e ffff8802b16d7d58
 ffffffff810407e0 ffff880254f95c00 ffff880254f95c00 ffff8802bfd92b00
 ffff8802bfd96b00 ffff880254f95e40 0000000000000180 ffff8802b16d7d68
Call Trace:
 [&lt;ffffffff816b553e&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff810407e0&gt;] warn_slowpath_common+0x70/0xa0
 [&lt;ffffffff8104082a&gt;] warn_slowpath_null+0x1a/0x20
 [&lt;ffffffff813fb279&gt;] __tty_hangup+0x459/0x460
 [&lt;ffffffff8107409c&gt;] ? finish_task_switch+0xbc/0xe0
 [&lt;ffffffff813fb297&gt;] do_tty_hangup+0x17/0x20
 [&lt;ffffffff8105fd6f&gt;] process_one_work+0x16f/0x450
 [&lt;ffffffff8106007c&gt;] process_scheduled_works+0x2c/0x40
 [&lt;ffffffff8106060a&gt;] worker_thread+0x26a/0x380
 [&lt;ffffffff810603a0&gt;] ? rescuer_thread+0x310/0x310
 [&lt;ffffffff810698a0&gt;] kthread+0xc0/0xd0
 [&lt;ffffffff816b0000&gt;] ? destroy_compound_page+0x65/0x92
 [&lt;ffffffff810697e0&gt;] ? kthread_create_on_node+0x130/0x130
 [&lt;ffffffff816c495c&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff810697e0&gt;] ? kthread_create_on_node+0x130/0x130
---[ end trace 98d9f01536cf411e ]---

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 lock order in tty_do_resize()</title>
<updated>2013-07-24T22:12:53+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-07-24T20:43:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=dee4a0be69c0e2996188e0c46478eadc280a8954'/>
<id>dee4a0be69c0e2996188e0c46478eadc280a8954</id>
<content type='text'>
Commits 6a1c0680cf3ba94356ecd58833e1540c93472a57 and
9356b535fcb71db494fc434acceb79f56d15bda2, respectively
  'tty: Convert termios_mutex to termios_rwsem' and
  'n_tty: Access termios values safely'
introduced a circular lock dependency with console_lock and
termios_rwsem.

The lockdep report [1] shows that n_tty_write() will attempt
to claim console_lock while holding the termios_rwsem, whereas
tty_do_resize() may already hold the console_lock while
claiming the termios_rwsem.

Since n_tty_write() and tty_do_resize() do not contend
over the same data -- the tty-&gt;winsize structure -- correct
the lock dependency by introducing a new lock which
specifically serializes access to tty-&gt;winsize only.

[1] Lockdep report

======================================================
[ INFO: possible circular locking dependency detected ]
3.10.0-0+tip-xeon+lockdep #0+tip Not tainted
-------------------------------------------------------
modprobe/277 is trying to acquire lock:
 (&amp;tty-&gt;termios_rwsem){++++..}, at: [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0

but task is already holding lock:
 ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #2 ((fb_notifier_list).rwsem){.+.+.+}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b797&gt;] down_read+0x47/0x5c
       [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #1 (console_lock){+.+.+.}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff810430a7&gt;] console_lock+0x77/0x80
       [&lt;ffffffff8146b2a1&gt;] con_flush_chars+0x31/0x50
       [&lt;ffffffff8145780c&gt;] n_tty_write+0x1ec/0x4d0
       [&lt;ffffffff814541b9&gt;] tty_write+0x159/0x2e0
       [&lt;ffffffff814543f5&gt;] redirected_tty_write+0xb5/0xc0
       [&lt;ffffffff811ab9d5&gt;] vfs_write+0xc5/0x1f0
       [&lt;ffffffff811abec5&gt;] SyS_write+0x55/0xa0
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #0 (&amp;tty-&gt;termios_rwsem){++++..}:
       [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
       [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
       [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
       [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
       [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
       [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
       [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
       [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
       [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
       [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
       [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
       [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

other info that might help us debug this:

Chain exists of:
  &amp;tty-&gt;termios_rwsem --&gt; console_lock --&gt; (fb_notifier_list).rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((fb_notifier_list).rwsem);
                               lock(console_lock);
                               lock((fb_notifier_list).rwsem);
  lock(&amp;tty-&gt;termios_rwsem);

 *** DEADLOCK ***

7 locks held by modprobe/277:
 #0:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b5b&gt;] __driver_attach+0x5b/0xb0
 #1:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b69&gt;] __driver_attach+0x69/0xb0
 #2:  (drm_global_mutex){+.+.+.}, at: [&lt;ffffffffa008a6dd&gt;] drm_get_pci_dev+0xbd/0x2a0 [drm]
 #3:  (registration_lock){+.+.+.}, at: [&lt;ffffffff813d93f5&gt;] register_framebuffer+0x25/0x320
 #4:  (&amp;fb_info-&gt;lock){+.+.+.}, at: [&lt;ffffffff813d8116&gt;] lock_fb_info+0x26/0x60
 #5:  (console_lock){+.+.+.}, at: [&lt;ffffffff813d95a4&gt;] register_framebuffer+0x1d4/0x320
 #6:  ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

stack backtrace:
CPU: 0 PID: 277 Comm: modprobe Not tainted 3.10.0-0+tip-xeon+lockdep #0+tip
Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
 ffffffff8213e5e0 ffff8802aa2fb298 ffffffff81755f19 ffff8802aa2fb2e8
 ffffffff8174f506 ffff8802aa2fa000 ffff8802aa2fb378 ffff8802aa2ea8e8
 ffff8802aa2ea910 ffff8802aa2ea8e8 0000000000000006 0000000000000007
Call Trace:
 [&lt;ffffffff81755f19&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff8174f506&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
 [&lt;ffffffff810b775e&gt;] ? mark_held_locks+0xae/0x120
 [&lt;ffffffff810b78d5&gt;] ? trace_hardirqs_on_caller+0x105/0x1d0
 [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
 [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
 [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
 [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
 [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
 [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
 [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
 [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
 [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
 [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
 [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
 [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
 [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
 [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
 [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
 [&lt;ffffffff8173cbcb&gt;] ? kmemleak_alloc+0x5b/0xc0
 [&lt;ffffffff81198874&gt;] ? kmem_cache_alloc_trace+0x104/0x290
 [&lt;ffffffffa01035e1&gt;] ? drm_fb_helper_single_add_all_connectors+0x81/0xf0 [drm_kms_helper]
 [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
 [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
 [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
 [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
 [&lt;ffffffff8175f162&gt;] ? _raw_spin_unlock_irqrestore+0x42/0x80
 [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
 [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
 [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
 [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
 [&lt;ffffffff81497b00&gt;] ? driver_probe_device+0x3a0/0x3a0
 [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
 [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
 [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
 [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
 [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
 [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
 [&lt;ffffffff81399a50&gt;] ? ddebug_proc_open+0xb0/0xb0
 [&lt;ffffffff813855ae&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
 [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

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>
Commits 6a1c0680cf3ba94356ecd58833e1540c93472a57 and
9356b535fcb71db494fc434acceb79f56d15bda2, respectively
  'tty: Convert termios_mutex to termios_rwsem' and
  'n_tty: Access termios values safely'
introduced a circular lock dependency with console_lock and
termios_rwsem.

The lockdep report [1] shows that n_tty_write() will attempt
to claim console_lock while holding the termios_rwsem, whereas
tty_do_resize() may already hold the console_lock while
claiming the termios_rwsem.

Since n_tty_write() and tty_do_resize() do not contend
over the same data -- the tty-&gt;winsize structure -- correct
the lock dependency by introducing a new lock which
specifically serializes access to tty-&gt;winsize only.

[1] Lockdep report

======================================================
[ INFO: possible circular locking dependency detected ]
3.10.0-0+tip-xeon+lockdep #0+tip Not tainted
-------------------------------------------------------
modprobe/277 is trying to acquire lock:
 (&amp;tty-&gt;termios_rwsem){++++..}, at: [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0

but task is already holding lock:
 ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #2 ((fb_notifier_list).rwsem){.+.+.+}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b797&gt;] down_read+0x47/0x5c
       [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #1 (console_lock){+.+.+.}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff810430a7&gt;] console_lock+0x77/0x80
       [&lt;ffffffff8146b2a1&gt;] con_flush_chars+0x31/0x50
       [&lt;ffffffff8145780c&gt;] n_tty_write+0x1ec/0x4d0
       [&lt;ffffffff814541b9&gt;] tty_write+0x159/0x2e0
       [&lt;ffffffff814543f5&gt;] redirected_tty_write+0xb5/0xc0
       [&lt;ffffffff811ab9d5&gt;] vfs_write+0xc5/0x1f0
       [&lt;ffffffff811abec5&gt;] SyS_write+0x55/0xa0
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #0 (&amp;tty-&gt;termios_rwsem){++++..}:
       [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
       [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
       [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
       [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
       [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
       [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
       [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
       [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
       [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
       [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
       [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
       [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

other info that might help us debug this:

Chain exists of:
  &amp;tty-&gt;termios_rwsem --&gt; console_lock --&gt; (fb_notifier_list).rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((fb_notifier_list).rwsem);
                               lock(console_lock);
                               lock((fb_notifier_list).rwsem);
  lock(&amp;tty-&gt;termios_rwsem);

 *** DEADLOCK ***

7 locks held by modprobe/277:
 #0:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b5b&gt;] __driver_attach+0x5b/0xb0
 #1:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b69&gt;] __driver_attach+0x69/0xb0
 #2:  (drm_global_mutex){+.+.+.}, at: [&lt;ffffffffa008a6dd&gt;] drm_get_pci_dev+0xbd/0x2a0 [drm]
 #3:  (registration_lock){+.+.+.}, at: [&lt;ffffffff813d93f5&gt;] register_framebuffer+0x25/0x320
 #4:  (&amp;fb_info-&gt;lock){+.+.+.}, at: [&lt;ffffffff813d8116&gt;] lock_fb_info+0x26/0x60
 #5:  (console_lock){+.+.+.}, at: [&lt;ffffffff813d95a4&gt;] register_framebuffer+0x1d4/0x320
 #6:  ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

stack backtrace:
CPU: 0 PID: 277 Comm: modprobe Not tainted 3.10.0-0+tip-xeon+lockdep #0+tip
Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
 ffffffff8213e5e0 ffff8802aa2fb298 ffffffff81755f19 ffff8802aa2fb2e8
 ffffffff8174f506 ffff8802aa2fa000 ffff8802aa2fb378 ffff8802aa2ea8e8
 ffff8802aa2ea910 ffff8802aa2ea8e8 0000000000000006 0000000000000007
Call Trace:
 [&lt;ffffffff81755f19&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff8174f506&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
 [&lt;ffffffff810b775e&gt;] ? mark_held_locks+0xae/0x120
 [&lt;ffffffff810b78d5&gt;] ? trace_hardirqs_on_caller+0x105/0x1d0
 [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
 [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
 [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
 [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
 [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
 [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
 [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
 [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
 [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
 [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
 [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
 [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
 [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
 [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
 [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
 [&lt;ffffffff8173cbcb&gt;] ? kmemleak_alloc+0x5b/0xc0
 [&lt;ffffffff81198874&gt;] ? kmem_cache_alloc_trace+0x104/0x290
 [&lt;ffffffffa01035e1&gt;] ? drm_fb_helper_single_add_all_connectors+0x81/0xf0 [drm_kms_helper]
 [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
 [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
 [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
 [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
 [&lt;ffffffff8175f162&gt;] ? _raw_spin_unlock_irqrestore+0x42/0x80
 [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
 [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
 [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
 [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
 [&lt;ffffffff81497b00&gt;] ? driver_probe_device+0x3a0/0x3a0
 [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
 [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
 [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
 [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
 [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
 [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
 [&lt;ffffffff81399a50&gt;] ? ddebug_proc_open+0xb0/0xb0
 [&lt;ffffffff813855ae&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
 [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

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>n_tty: Fix EOF push handling</title>
<updated>2013-07-24T00:08:40+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T14:21:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=40d5e0905a03601d40cd4e46b8690093c2355d03'/>
<id>40d5e0905a03601d40cd4e46b8690093c2355d03</id>
<content type='text'>
In canonical mode, an EOF which is not the first character of the line
causes read() to complete and return the number of characters read so
far (commonly referred to as EOF push). However, if the previous read()
returned because the user buffer was full _and_ the next character
is an EOF not at the beginning of the line, read() must not return 0,
thus mistakenly indicating the end-of-file condition.

The TTY_PUSH flag is used to indicate an EOF was received which is not
at the beginning of the line. Because the EOF push condition is
evaluated by a thread other than the read(), multiple EOF pushes can
cause a premature end-of-file to be indicated.

Instead, discover the 'EOF push as first read character' condition
from the read() thread itself, and restart the i/o loop if detected.

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>
In canonical mode, an EOF which is not the first character of the line
causes read() to complete and return the number of characters read so
far (commonly referred to as EOF push). However, if the previous read()
returned because the user buffer was full _and_ the next character
is an EOF not at the beginning of the line, read() must not return 0,
thus mistakenly indicating the end-of-file condition.

The TTY_PUSH flag is used to indicate an EOF was received which is not
at the beginning of the line. Because the EOF push condition is
evaluated by a thread other than the read(), multiple EOF pushes can
cause a premature end-of-file to be indicated.

Instead, discover the 'EOF push as first read character' condition
from the read() thread itself, and restart the i/o loop if detected.

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: Only guarantee termios read safety for throttle/unthrottle</title>
<updated>2013-07-23T23:43:02+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T13:14:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d8c1f929aa8164cd8eaa830068d2fa3159c0764a'/>
<id>d8c1f929aa8164cd8eaa830068d2fa3159c0764a</id>
<content type='text'>
No tty driver modifies termios during throttle() or unthrottle().
Therefore, only read safety is required.

However, tty_throttle_safe and tty_unthrottle_safe must still be
mutually exclusive; introduce throttle_mutex for that purpose.

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>
No tty driver modifies termios during throttle() or unthrottle().
Therefore, only read safety is required.

However, tty_throttle_safe and tty_unthrottle_safe must still be
mutually exclusive; introduce throttle_mutex for that purpose.

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: Convert termios_mutex to termios_rwsem</title>
<updated>2013-07-23T23:43:01+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T13:14:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6a1c0680cf3ba94356ecd58833e1540c93472a57'/>
<id>6a1c0680cf3ba94356ecd58833e1540c93472a57</id>
<content type='text'>
termios is commonly accessed unsafely (especially by N_TTY)
because the existing mutex forces exclusive access.
Convert existing usage.

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>
termios is commonly accessed unsafely (especially by N_TTY)
because the existing mutex forces exclusive access.
Convert existing usage.

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: Replace ldisc locking with ldisc_sem</title>
<updated>2013-07-23T23:38:34+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T11:04:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=36697529b5bbe36911e39a6309e7a7c9250d280a'/>
<id>36697529b5bbe36911e39a6309e7a7c9250d280a</id>
<content type='text'>
Line discipline locking was performed with a combination of
a mutex, a status bit, a count, and a waitqueue -- basically,
a rw semaphore.

Replace the existing combination with an ld_semaphore.

Fixes:
 1) the 'reference acquire after ldisc locked' bug
 2) the over-complicated halt mechanism
 3) lock order wrt. tty_lock()
 4) dropping locks while changing ldisc
 5) previously unidentified deadlock while locking ldisc from
    both linked ttys concurrently
 6) previously unidentified recursive deadlocks

Adds much-needed lockdep diagnostics.

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>
Line discipline locking was performed with a combination of
a mutex, a status bit, a count, and a waitqueue -- basically,
a rw semaphore.

Replace the existing combination with an ld_semaphore.

Fixes:
 1) the 'reference acquire after ldisc locked' bug
 2) the over-complicated halt mechanism
 3) lock order wrt. tty_lock()
 4) dropping locks while changing ldisc
 5) previously unidentified deadlock while locking ldisc from
    both linked ttys concurrently
 6) previously unidentified recursive deadlocks

Adds much-needed lockdep diagnostics.

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_ldisc_lock name collision</title>
<updated>2013-07-23T23:38:34+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T11:04:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=137084bbaddf4f6dde948ef3a14e18ba0754cc0d'/>
<id>137084bbaddf4f6dde948ef3a14e18ba0754cc0d</id>
<content type='text'>
The file scope spinlock identifier, tty_ldisc_lock, will collide
with the file scope lock function tty_ldisc_lock() so rename it.

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>
The file scope spinlock identifier, tty_ldisc_lock, will collide
with the file scope lock function tty_ldisc_lock() so rename it.

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>
</feed>
