<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/tty/tty_io.c, branch linux-3.14.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: Fix unsafe ldisc reference via ioctl(TIOCGETD)</title>
<updated>2016-02-17T20:34:38+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2016-01-11T06:40:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a08f833c45a2e803183ae82c153694711dccc16f'/>
<id>a08f833c45a2e803183ae82c153694711dccc16f</id>
<content type='text'>
commit 5c17c861a357e9458001f021a7afa7aab9937439 upstream.

ioctl(TIOCGETD) retrieves the line discipline id directly from the
ldisc because the line discipline id (c_line) in termios is untrustworthy;
userspace may have set termios via ioctl(TCSETS*) without actually
changing the line discipline via ioctl(TIOCSETD).

However, directly accessing the current ldisc via tty-&gt;ldisc is
unsafe; the ldisc ptr dereferenced may be stale if the line discipline
is changing via ioctl(TIOCSETD) or hangup.

Wait for the line discipline reference (just like read() or write())
to retrieve the "current" line discipline id.

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>
commit 5c17c861a357e9458001f021a7afa7aab9937439 upstream.

ioctl(TIOCGETD) retrieves the line discipline id directly from the
ldisc because the line discipline id (c_line) in termios is untrustworthy;
userspace may have set termios via ioctl(TCSETS*) without actually
changing the line discipline via ioctl(TIOCSETD).

However, directly accessing the current ldisc via tty-&gt;ldisc is
unsafe; the ldisc ptr dereferenced may be stale if the line discipline
is changing via ioctl(TIOCSETD) or hangup.

Wait for the line discipline reference (just like read() or write())
to retrieve the "current" line discipline id.

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 up atime/mtime mess, take four</title>
<updated>2015-03-18T12:31:31+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2015-02-27T17:40:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a7cfc5a06d444214d6ee90ee0b22113e07ff7488'/>
<id>a7cfc5a06d444214d6ee90ee0b22113e07ff7488</id>
<content type='text'>
commit f0bf0bd07943bfde8f5ac39a32664810a379c7d3 upstream.

This problem was taken care of three times already in
* b0de59b5733d18b0d1974a060860a8b5c1b36a2e (TTY: do not update
  atime/mtime on read/write),
* 37b7f3c76595e23257f61bd80b223de8658617ee (TTY: fix atime/mtime
  regression), and
* b0b885657b6c8ef63a46bc9299b2a7715d19acde (tty: fix up atime/mtime
  mess, take three)

But it still misses one point. As John Paul correctly points out, we
do not care about setting date. If somebody ever changes wall
time backwards (by mistake for example), tty timestamps are never
updated until the original wall time passes.

So check the absolute difference of times and if it large than "8
seconds or so", always update the time. That means we will update
immediatelly when changing time. Ergo, CAP_SYS_TIME can foul the
check, but it was always that way.

Thanks John for serving me this so nicely debugged.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: John Paul Perry &lt;john_paul.perry@alcatel-lucent.com&gt;
Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit f0bf0bd07943bfde8f5ac39a32664810a379c7d3 upstream.

This problem was taken care of three times already in
* b0de59b5733d18b0d1974a060860a8b5c1b36a2e (TTY: do not update
  atime/mtime on read/write),
* 37b7f3c76595e23257f61bd80b223de8658617ee (TTY: fix atime/mtime
  regression), and
* b0b885657b6c8ef63a46bc9299b2a7715d19acde (tty: fix up atime/mtime
  mess, take three)

But it still misses one point. As John Paul correctly points out, we
do not care about setting date. If somebody ever changes wall
time backwards (by mistake for example), tty timestamps are never
updated until the original wall time passes.

So check the absolute difference of times and if it large than "8
seconds or so", always update the time. That means we will update
immediatelly when changing time. Ergo, CAP_SYS_TIME can foul the
check, but it was always that way.

Thanks John for serving me this so nicely debugged.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: John Paul Perry &lt;john_paul.perry@alcatel-lucent.com&gt;
Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Fix high cpu load if tty is unreleaseable</title>
<updated>2014-11-14T17:00:10+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2014-10-16T17:51:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2ceee507fac81179f206691fec3163839c5dd5d8'/>
<id>2ceee507fac81179f206691fec3163839c5dd5d8</id>
<content type='text'>
commit 37b164578826406a173ca7c20d9ba7430134d23e upstream.

Kernel oops can cause the tty to be unreleaseable (for example, if
n_tty_read() crashes while on the read_wait queue). This will cause
tty_release() to endlessly loop without sleeping.

Use a killable sleep timeout which grows by 2n+1 jiffies over the interval
[0, 120 secs.) and then jumps to forever (but still killable).

NB: killable just allows for the task to be rewoken manually, not
to be terminated.

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>
commit 37b164578826406a173ca7c20d9ba7430134d23e upstream.

Kernel oops can cause the tty to be unreleaseable (for example, if
n_tty_read() crashes while on the read_wait queue). This will cause
tty_release() to endlessly loop without sleeping.

Use a killable sleep timeout which grows by 2n+1 jiffies over the interval
[0, 120 secs.) and then jumps to forever (but still killable).

NB: killable just allows for the task to be rewoken manually, not
to be terminated.

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: Set correct tty name in 'active' sysfs attribute</title>
<updated>2014-04-27T00:19:04+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=192ae8160c9465dd3f0c6650b29cc4ad019bc4e2'/>
<id>192ae8160c9465dd3f0c6650b29cc4ad019bc4e2</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>Revert "tty: Set correct tty name in 'active' sysfs attribute"</title>
<updated>2014-02-22T22:31:04+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2014-02-22T22:31:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5c0a2450d695bbe32b1fb81c07751bcbea64f084'/>
<id>5c0a2450d695bbe32b1fb81c07751bcbea64f084</id>
<content type='text'>
This reverts commit d8a5dc3033af2fd6d16030d2ee4fbd073460fe54.

This breaks plymouth installs, either because plymouth is using the file
"incorrectly" or because the patch is incorrect.  Either way, this needs
to be reverted until it is all figured out.

Reported-by: Josh Boyer &lt;jwboyer@fedoraproject.org&gt;
Reported-by: Ray Strode &lt;halfline@gmail.com&gt;
Cc: Lennart Poettering &lt;lennart@poettering.net&gt;
Cc: Kay Sievers &lt;kay@vrfy.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Cc: Werner Fink &lt;werner@suse.de&gt;
Cc: Hannes Reinecke &lt;hare@suse.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>
This reverts commit d8a5dc3033af2fd6d16030d2ee4fbd073460fe54.

This breaks plymouth installs, either because plymouth is using the file
"incorrectly" or because the patch is incorrect.  Either way, this needs
to be reverted until it is all figured out.

Reported-by: Josh Boyer &lt;jwboyer@fedoraproject.org&gt;
Reported-by: Ray Strode &lt;halfline@gmail.com&gt;
Cc: Lennart Poettering &lt;lennart@poettering.net&gt;
Cc: Kay Sievers &lt;kay@vrfy.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Cc: Werner Fink &lt;werner@suse.de&gt;
Cc: Hannes Reinecke &lt;hare@suse.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: Set correct tty name in 'active' sysfs attribute</title>
<updated>2014-02-07T16:40:54+00:00</updated>
<author>
<name>Hannes Reinecke</name>
<email>hare@suse.de</email>
</author>
<published>2014-02-07T10:38:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d8a5dc3033af2fd6d16030d2ee4fbd073460fe54'/>
<id>d8a5dc3033af2fd6d16030d2ee4fbd073460fe54</id>
<content type='text'>
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.

This resolves an issue on s390 platforms in determining the correct
console device to use.

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

This resolves an issue on s390 platforms in determining the correct
console device to use.

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