<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/tty/vt, branch linux-3.10.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>vt: fix unchecked __put_user() in tioclinux ioctls</title>
<updated>2017-11-01T21:12:43+00:00</updated>
<author>
<name>Adam Borowski</name>
<email>kilobyte@angband.pl</email>
</author>
<published>2017-06-03T07:35:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=1fc0b43a1df72704b4d5f6cd5a2ca6c09736d67f'/>
<id>1fc0b43a1df72704b4d5f6cd5a2ca6c09736d67f</id>
<content type='text'>
commit 6987dc8a70976561d22450b5858fc9767788cc1c upstream.

Only read access is checked before this call.

Actually, at the moment this is not an issue, as every in-tree arch does
the same manual checks for VERIFY_READ vs VERIFY_WRITE, relying on the MMU
to tell them apart, but this wasn't the case in the past and may happen
again on some odd arch in the future.

If anyone cares about 3.7 and earlier, this is a security hole (untested)
on real 80386 CPUs.

Signed-off-by: Adam Borowski &lt;kilobyte@angband.pl&gt;
CC: stable@vger.kernel.org # v3.7-
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6987dc8a70976561d22450b5858fc9767788cc1c upstream.

Only read access is checked before this call.

Actually, at the moment this is not an issue, as every in-tree arch does
the same manual checks for VERIFY_READ vs VERIFY_WRITE, relying on the MMU
to tell them apart, but this wasn't the case in the past and may happen
again on some odd arch in the future.

If anyone cares about 3.7 and earlier, this is a security hole (untested)
on real 80386 CPUs.

Signed-off-by: Adam Borowski &lt;kilobyte@angband.pl&gt;
CC: stable@vger.kernel.org # v3.7-
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>vt: clear selection before resizing</title>
<updated>2017-02-10T10:03:41+00:00</updated>
<author>
<name>Scot Doyle</name>
<email>lkml14@scotdoyle.com</email>
</author>
<published>2016-10-13T17:12:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5812a9bc9d68a82c2cc839f88e6f7a05093ab39d'/>
<id>5812a9bc9d68a82c2cc839f88e6f7a05093ab39d</id>
<content type='text'>
commit 009e39ae44f4191188aeb6dfbf661b771dbbe515 upstream.

When resizing a vt its selection may exceed the new size, resulting in
an invalid memory access [1]. Clear the selection before resizing.

[1] http://lkml.kernel.org/r/CACT4Y+acDTwy4umEvf5ROBGiRJNrxHN4Cn5szCXE5Jw-d1B=Xw@mail.gmail.com

Reported-and-tested-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Scot Doyle &lt;lkml14@scotdoyle.com&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 009e39ae44f4191188aeb6dfbf661b771dbbe515 upstream.

When resizing a vt its selection may exceed the new size, resulting in
an invalid memory access [1]. Clear the selection before resizing.

[1] http://lkml.kernel.org/r/CACT4Y+acDTwy4umEvf5ROBGiRJNrxHN4Cn5szCXE5Jw-d1B=Xw@mail.gmail.com

Reported-and-tested-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Scot Doyle &lt;lkml14@scotdoyle.com&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: vt, fix bogus division in csi_J</title>
<updated>2017-02-10T10:03:40+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2016-10-03T09:00:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=902fd8d597f6cec01c7d24da38e0a921fdbc6382'/>
<id>902fd8d597f6cec01c7d24da38e0a921fdbc6382</id>
<content type='text'>
commit 42acfc6615f47e465731c263bee0c799edb098f2 upstream.

In csi_J(3), the third parameter of scr_memsetw (vc_screenbuf_size) is
divided by 2 inappropriatelly. But scr_memsetw expects size, not
count, because it divides the size by 2 on its own before doing actual
memset-by-words.

So remove the bogus division.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Petr PÃ­saÅ &lt;ppisar@redhat.com&gt;
Fixes: f8df13e0a9 (tty: Clean console safely)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 42acfc6615f47e465731c263bee0c799edb098f2 upstream.

In csi_J(3), the third parameter of scr_memsetw (vc_screenbuf_size) is
divided by 2 inappropriatelly. But scr_memsetw expects size, not
count, because it divides the size by 2 on its own before doing actual
memset-by-words.

So remove the bogus division.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Petr PÃ­saÅ &lt;ppisar@redhat.com&gt;
Fixes: f8df13e0a9 (tty: Clean console safely)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: limit terminal size to 4M chars</title>
<updated>2017-02-10T10:03:40+00:00</updated>
<author>
<name>Dmitry Vyukov</name>
<email>dvyukov@google.com</email>
</author>
<published>2016-10-14T13:18:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=350594012a219713e7ad990669c660b29bad2ab2'/>
<id>350594012a219713e7ad990669c660b29bad2ab2</id>
<content type='text'>
commit 32b2921e6a7461fe63b71217067a6cf4bddb132f upstream.

Size of kmalloc() in vc_do_resize() is controlled by user.
Too large kmalloc() size triggers WARNING message on console.
Put a reasonable upper bound on terminal size to prevent WARNINGs.

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
CC: David Rientjes &lt;rientjes@google.com&gt;
Cc: One Thousand Gnomes &lt;gnomes@lxorguk.ukuu.org.uk&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.com&gt;
Cc: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: syzkaller@googlegroups.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 32b2921e6a7461fe63b71217067a6cf4bddb132f upstream.

Size of kmalloc() in vc_do_resize() is controlled by user.
Too large kmalloc() size triggers WARNING message on console.
Put a reasonable upper bound on terminal size to prevent WARNINGs.

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
CC: David Rientjes &lt;rientjes@google.com&gt;
Cc: One Thousand Gnomes &lt;gnomes@lxorguk.ukuu.org.uk&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Jiri Slaby &lt;jslaby@suse.com&gt;
Cc: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: syzkaller@googlegroups.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty/vt/keyboard: fix OOB access in do_compute_shiftstate()</title>
<updated>2016-08-27T09:40:26+00:00</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2016-06-27T21:12:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=074ed3fd042d2a8bebef38147ce4de3ac6933da3'/>
<id>074ed3fd042d2a8bebef38147ce4de3ac6933da3</id>
<content type='text'>
commit 510cccb5b0c8868a2b302a0ab524da7912da648b upstream.

The size of individual keymap in drivers/tty/vt/keyboard.c is NR_KEYS,
which is currently 256, whereas number of keys/buttons in input device (and
therefor in key_down) is much larger - KEY_CNT - 768, and that can cause
out-of-bound access when we do

	sym = U(key_maps[0][k]);

with large 'k'.

To fix it we should not attempt iterating beyond smaller of NR_KEYS and
KEY_CNT.

Also while at it let's switch to for_each_set_bit() instead of open-coding
it.

Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 510cccb5b0c8868a2b302a0ab524da7912da648b upstream.

The size of individual keymap in drivers/tty/vt/keyboard.c is NR_KEYS,
which is currently 256, whereas number of keys/buttons in input device (and
therefor in key_down) is much larger - KEY_CNT - 768, and that can cause
out-of-bound access when we do

	sym = U(key_maps[0][k]);

with large 'k'.

To fix it we should not attempt iterating beyond smaller of NR_KEYS and
KEY_CNT.

Also while at it let's switch to for_each_set_bit() instead of open-coding
it.

Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: vt, return error when con_startup fails</title>
<updated>2016-06-07T08:42:55+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2016-05-03T15:05:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0fff1b1ff8c9c07caa1762b6c0b76b1dbbe20223'/>
<id>0fff1b1ff8c9c07caa1762b6c0b76b1dbbe20223</id>
<content type='text'>
commit 6798df4c5fe0a7e6d2065cf79649a794e5ba7114 upstream.

When csw-&gt;con_startup() fails in do_register_con_driver, we return no
error (i.e. 0). This was changed back in 2006 by commit 3e795de763.
Before that we used to return -ENODEV.

So fix the return value to be -ENODEV in that case again.

Fixes: 3e795de763 ("VT binding: Add binding/unbinding support for the VT console")
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: "Dan Carpenter" &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6798df4c5fe0a7e6d2065cf79649a794e5ba7114 upstream.

When csw-&gt;con_startup() fails in do_register_con_driver, we return no
error (i.e. 0). This was changed back in 2006 by commit 3e795de763.
Before that we used to return -ENODEV.

So fix the return value to be -ENODEV in that case again.

Fixes: 3e795de763 ("VT binding: Add binding/unbinding support for the VT console")
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: "Dan Carpenter" &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>vt: provide notifications on selection changes</title>
<updated>2015-03-06T22:40:51+00:00</updated>
<author>
<name>Nicolas Pitre</name>
<email>nicolas.pitre@linaro.org</email>
</author>
<published>2015-01-23T22:07:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=cabab528e7641cc210791af946031ff98d06046d'/>
<id>cabab528e7641cc210791af946031ff98d06046d</id>
<content type='text'>
commit 19e3ae6b4f07a87822c1c9e7ed99d31860e701af upstream.

The vcs device's poll/fasync support relies on the vt notifier to signal
changes to the screen content.  Notifier invocations were missing for
changes that comes through the selection interface though.  Fix that.

Tested with BRLTTY 5.2.

Signed-off-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Cc: Dave Mielke &lt;dave@mielke.cc&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 19e3ae6b4f07a87822c1c9e7ed99d31860e701af upstream.

The vcs device's poll/fasync support relies on the vt notifier to signal
changes to the screen content.  Notifier invocations were missing for
changes that comes through the selection interface though.  Fix that.

Tested with BRLTTY 5.2.

Signed-off-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Cc: Dave Mielke &lt;dave@mielke.cc&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>vt: Fix secure clear screen</title>
<updated>2014-02-22T20:41:27+00:00</updated>
<author>
<name>Petr Písař</name>
<email>petr.pisar@atlas.cz</email>
</author>
<published>2014-02-06T20:01:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=27f0831c1aedad09238f173550919ac7f809e4fa'/>
<id>27f0831c1aedad09238f173550919ac7f809e4fa</id>
<content type='text'>
commit 0930b0950a8996aa88b0d2ba4bb2bab27cc36bc7 upstream.

\E[3J console code (secure clear screen) needs to update_screen(vc)
in order to write-through blanks into off-screen video memory.

This has been removed accidentally in 3.6 by:

commit 81732c3b2fede049a692e58a7ceabb6d18ffb18c
Author: Jean-François Moine &lt;moinejf@free.fr&gt;
Date:   Thu Sep 6 19:24:13 2012 +0200

    tty vt: Fix line garbage in virtual console on command line edition

Signed-off-by: Petr Písař &lt;petr.pisar@atlas.cz&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 0930b0950a8996aa88b0d2ba4bb2bab27cc36bc7 upstream.

\E[3J console code (secure clear screen) needs to update_screen(vc)
in order to write-through blanks into off-screen video memory.

This has been removed accidentally in 3.6 by:

commit 81732c3b2fede049a692e58a7ceabb6d18ffb18c
Author: Jean-François Moine &lt;moinejf@free.fr&gt;
Date:   Thu Sep 6 19:24:13 2012 +0200

    tty vt: Fix line garbage in virtual console on command line edition

Signed-off-by: Petr Písař &lt;petr.pisar@atlas.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>tty/vt: Return EBUSY if deallocating VT1 and it is busy</title>
<updated>2013-06-17T19:37:29+00:00</updated>
<author>
<name>Ross Lagerwall</name>
<email>rosslagerwall@gmail.com</email>
</author>
<published>2013-06-14T22:24:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ef223fb3d1d61c2a95a89cdc02f8e86dac96ddc3'/>
<id>ef223fb3d1d61c2a95a89cdc02f8e86dac96ddc3</id>
<content type='text'>
Commit 421b40a6286e ("tty/vt: Fix vc_deallocate() lock order") changed
the behavior when deallocating VT 1.  Previously if trying to
deallocate VT1 and it is busy, we would return EBUSY.  The commit
changed this to return 0 (success).

This commit restores the old behavior.

Signed-off-by: Ross Lagerwall &lt;rosslagerwall@gmail.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Acked-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 421b40a6286e ("tty/vt: Fix vc_deallocate() lock order") changed
the behavior when deallocating VT 1.  Previously if trying to
deallocate VT1 and it is busy, we would return EBUSY.  The commit
changed this to return 0 (success).

This commit restores the old behavior.

Signed-off-by: Ross Lagerwall &lt;rosslagerwall@gmail.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Acked-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/vt: Fix vc_deallocate() lock order</title>
<updated>2013-05-20T19:15:59+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-05-17T16:41:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=421b40a6286ee343d77d5e51f5ee6d04d7a2a90f'/>
<id>421b40a6286ee343d77d5e51f5ee6d04d7a2a90f</id>
<content type='text'>
Now that the tty port owns the flip buffers and i/o is allowed
from the driver even when no tty is attached, the destruction
of the tty port (and the flip buffers) must ensure that no
outstanding work is pending.

Unfortunately, this creates a lock order problem with the
console_lock (see attached lockdep report [1] below).

For single console deallocation, drop the console_lock prior
to port destruction. When multiple console deallocation,
defer port destruction until the consoles have been
deallocated.

tty_port_destroy() is not required if the port has not
been used; remove from vc_allocate() failure path.

[1] lockdep report from Dave Jones &lt;davej@redhat.com&gt;

 ======================================================
 [ INFO: possible circular locking dependency detected ]
 3.9.0+ #16 Not tainted
 -------------------------------------------------------
 (agetty)/26163 is trying to acquire lock:
 blocked:  ((&amp;buf-&gt;work)){+.+...}, instance: ffff88011c8b0020, at: [&lt;ffffffff81062065&gt;] flush_work+0x5/0x2e0

 but task is already holding lock:
 blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [&lt;ffffffff813bc201&gt;] vt_ioctl+0xb61/0x1230

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (console_lock){+.+.+.}:
        [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
        [&lt;ffffffff810416c7&gt;] console_lock+0x77/0x80
        [&lt;ffffffff813c3dcd&gt;] con_flush_chars+0x2d/0x50
        [&lt;ffffffff813b32b2&gt;] n_tty_receive_buf+0x122/0x14d0
        [&lt;ffffffff813b7709&gt;] flush_to_ldisc+0x119/0x170
        [&lt;ffffffff81064381&gt;] process_one_work+0x211/0x700
        [&lt;ffffffff8106498b&gt;] worker_thread+0x11b/0x3a0
        [&lt;ffffffff8106ce5d&gt;] kthread+0xed/0x100
        [&lt;ffffffff81601cac&gt;] ret_from_fork+0x7c/0xb0

 -&gt; #0 ((&amp;buf-&gt;work)){+.+...}:
        [&lt;ffffffff810b349a&gt;] __lock_acquire+0x193a/0x1c00
        [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
        [&lt;ffffffff810620ae&gt;] flush_work+0x4e/0x2e0
        [&lt;ffffffff81065305&gt;] __cancel_work_timer+0x95/0x130
        [&lt;ffffffff810653b0&gt;] cancel_work_sync+0x10/0x20
        [&lt;ffffffff813b8212&gt;] tty_port_destroy+0x12/0x20
        [&lt;ffffffff813c65e8&gt;] vc_deallocate+0xf8/0x110
        [&lt;ffffffff813bc20c&gt;] vt_ioctl+0xb6c/0x1230
        [&lt;ffffffff813b01a5&gt;] tty_ioctl+0x285/0xd50
        [&lt;ffffffff811ba825&gt;] do_vfs_ioctl+0x305/0x530
        [&lt;ffffffff811baad1&gt;] sys_ioctl+0x81/0xa0
        [&lt;ffffffff81601d59&gt;] system_call_fastpath+0x16/0x1b

 other info that might help us debug this:

 [ 6760.076175]  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(console_lock);
                                lock((&amp;buf-&gt;work));
                                lock(console_lock);
   lock((&amp;buf-&gt;work));

  *** DEADLOCK ***

 1 lock on stack by (agetty)/26163:
  #0: blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [&lt;ffffffff813bc201&gt;] vt_ioctl+0xb61/0x1230
 stack backtrace:
 Pid: 26163, comm: (agetty) Not tainted 3.9.0+ #16
 Call Trace:
  [&lt;ffffffff815edb14&gt;] print_circular_bug+0x200/0x20e
  [&lt;ffffffff810b349a&gt;] __lock_acquire+0x193a/0x1c00
  [&lt;ffffffff8100a269&gt;] ? sched_clock+0x9/0x10
  [&lt;ffffffff8100a269&gt;] ? sched_clock+0x9/0x10
  [&lt;ffffffff8100a200&gt;] ? native_sched_clock+0x20/0x80
  [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
  [&lt;ffffffff81062065&gt;] ? flush_work+0x5/0x2e0
  [&lt;ffffffff810620ae&gt;] flush_work+0x4e/0x2e0
  [&lt;ffffffff81062065&gt;] ? flush_work+0x5/0x2e0
  [&lt;ffffffff810b15db&gt;] ? mark_held_locks+0xbb/0x140
  [&lt;ffffffff8113c8a3&gt;] ? __free_pages_ok.part.57+0x93/0xc0
  [&lt;ffffffff810b15db&gt;] ? mark_held_locks+0xbb/0x140
  [&lt;ffffffff810652f2&gt;] ? __cancel_work_timer+0x82/0x130
  [&lt;ffffffff81065305&gt;] __cancel_work_timer+0x95/0x130
  [&lt;ffffffff810653b0&gt;] cancel_work_sync+0x10/0x20
  [&lt;ffffffff813b8212&gt;] tty_port_destroy+0x12/0x20
  [&lt;ffffffff813c65e8&gt;] vc_deallocate+0xf8/0x110
  [&lt;ffffffff813bc20c&gt;] vt_ioctl+0xb6c/0x1230
  [&lt;ffffffff810aec41&gt;] ? lock_release_holdtime.part.30+0xa1/0x170
  [&lt;ffffffff813b01a5&gt;] tty_ioctl+0x285/0xd50
  [&lt;ffffffff812b00f6&gt;] ? inode_has_perm.isra.46.constprop.61+0x56/0x80
  [&lt;ffffffff811ba825&gt;] do_vfs_ioctl+0x305/0x530
  [&lt;ffffffff812b04db&gt;] ? selinux_file_ioctl+0x5b/0x110
  [&lt;ffffffff811baad1&gt;] sys_ioctl+0x81/0xa0
  [&lt;ffffffff81601d59&gt;] system_call_fastpath+0x16/0x1b

Cc: Dave Jones &lt;davej@redhat.com&gt;
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>
Now that the tty port owns the flip buffers and i/o is allowed
from the driver even when no tty is attached, the destruction
of the tty port (and the flip buffers) must ensure that no
outstanding work is pending.

Unfortunately, this creates a lock order problem with the
console_lock (see attached lockdep report [1] below).

For single console deallocation, drop the console_lock prior
to port destruction. When multiple console deallocation,
defer port destruction until the consoles have been
deallocated.

tty_port_destroy() is not required if the port has not
been used; remove from vc_allocate() failure path.

[1] lockdep report from Dave Jones &lt;davej@redhat.com&gt;

 ======================================================
 [ INFO: possible circular locking dependency detected ]
 3.9.0+ #16 Not tainted
 -------------------------------------------------------
 (agetty)/26163 is trying to acquire lock:
 blocked:  ((&amp;buf-&gt;work)){+.+...}, instance: ffff88011c8b0020, at: [&lt;ffffffff81062065&gt;] flush_work+0x5/0x2e0

 but task is already holding lock:
 blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [&lt;ffffffff813bc201&gt;] vt_ioctl+0xb61/0x1230

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (console_lock){+.+.+.}:
        [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
        [&lt;ffffffff810416c7&gt;] console_lock+0x77/0x80
        [&lt;ffffffff813c3dcd&gt;] con_flush_chars+0x2d/0x50
        [&lt;ffffffff813b32b2&gt;] n_tty_receive_buf+0x122/0x14d0
        [&lt;ffffffff813b7709&gt;] flush_to_ldisc+0x119/0x170
        [&lt;ffffffff81064381&gt;] process_one_work+0x211/0x700
        [&lt;ffffffff8106498b&gt;] worker_thread+0x11b/0x3a0
        [&lt;ffffffff8106ce5d&gt;] kthread+0xed/0x100
        [&lt;ffffffff81601cac&gt;] ret_from_fork+0x7c/0xb0

 -&gt; #0 ((&amp;buf-&gt;work)){+.+...}:
        [&lt;ffffffff810b349a&gt;] __lock_acquire+0x193a/0x1c00
        [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
        [&lt;ffffffff810620ae&gt;] flush_work+0x4e/0x2e0
        [&lt;ffffffff81065305&gt;] __cancel_work_timer+0x95/0x130
        [&lt;ffffffff810653b0&gt;] cancel_work_sync+0x10/0x20
        [&lt;ffffffff813b8212&gt;] tty_port_destroy+0x12/0x20
        [&lt;ffffffff813c65e8&gt;] vc_deallocate+0xf8/0x110
        [&lt;ffffffff813bc20c&gt;] vt_ioctl+0xb6c/0x1230
        [&lt;ffffffff813b01a5&gt;] tty_ioctl+0x285/0xd50
        [&lt;ffffffff811ba825&gt;] do_vfs_ioctl+0x305/0x530
        [&lt;ffffffff811baad1&gt;] sys_ioctl+0x81/0xa0
        [&lt;ffffffff81601d59&gt;] system_call_fastpath+0x16/0x1b

 other info that might help us debug this:

 [ 6760.076175]  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(console_lock);
                                lock((&amp;buf-&gt;work));
                                lock(console_lock);
   lock((&amp;buf-&gt;work));

  *** DEADLOCK ***

 1 lock on stack by (agetty)/26163:
  #0: blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [&lt;ffffffff813bc201&gt;] vt_ioctl+0xb61/0x1230
 stack backtrace:
 Pid: 26163, comm: (agetty) Not tainted 3.9.0+ #16
 Call Trace:
  [&lt;ffffffff815edb14&gt;] print_circular_bug+0x200/0x20e
  [&lt;ffffffff810b349a&gt;] __lock_acquire+0x193a/0x1c00
  [&lt;ffffffff8100a269&gt;] ? sched_clock+0x9/0x10
  [&lt;ffffffff8100a269&gt;] ? sched_clock+0x9/0x10
  [&lt;ffffffff8100a200&gt;] ? native_sched_clock+0x20/0x80
  [&lt;ffffffff810b3f74&gt;] lock_acquire+0xa4/0x210
  [&lt;ffffffff81062065&gt;] ? flush_work+0x5/0x2e0
  [&lt;ffffffff810620ae&gt;] flush_work+0x4e/0x2e0
  [&lt;ffffffff81062065&gt;] ? flush_work+0x5/0x2e0
  [&lt;ffffffff810b15db&gt;] ? mark_held_locks+0xbb/0x140
  [&lt;ffffffff8113c8a3&gt;] ? __free_pages_ok.part.57+0x93/0xc0
  [&lt;ffffffff810b15db&gt;] ? mark_held_locks+0xbb/0x140
  [&lt;ffffffff810652f2&gt;] ? __cancel_work_timer+0x82/0x130
  [&lt;ffffffff81065305&gt;] __cancel_work_timer+0x95/0x130
  [&lt;ffffffff810653b0&gt;] cancel_work_sync+0x10/0x20
  [&lt;ffffffff813b8212&gt;] tty_port_destroy+0x12/0x20
  [&lt;ffffffff813c65e8&gt;] vc_deallocate+0xf8/0x110
  [&lt;ffffffff813bc20c&gt;] vt_ioctl+0xb6c/0x1230
  [&lt;ffffffff810aec41&gt;] ? lock_release_holdtime.part.30+0xa1/0x170
  [&lt;ffffffff813b01a5&gt;] tty_ioctl+0x285/0xd50
  [&lt;ffffffff812b00f6&gt;] ? inode_has_perm.isra.46.constprop.61+0x56/0x80
  [&lt;ffffffff811ba825&gt;] do_vfs_ioctl+0x305/0x530
  [&lt;ffffffff812b04db&gt;] ? selinux_file_ioctl+0x5b/0x110
  [&lt;ffffffff811baad1&gt;] sys_ioctl+0x81/0xa0
  [&lt;ffffffff81601d59&gt;] system_call_fastpath+0x16/0x1b

Cc: Dave Jones &lt;davej@redhat.com&gt;
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>
