<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/tty/pty.c, branch v3.10.78</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>tty: Prevent untrappable signals from malicious program</title>
<updated>2015-03-06T22:40:51+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2015-01-19T18:05:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4324af6a14ad1c0553a35d82a17d2a6066e98b79'/>
<id>4324af6a14ad1c0553a35d82a17d2a6066e98b79</id>
<content type='text'>
commit 37480a05685ed5b8e1b9bf5e5c53b5810258b149 upstream.

Commit 26df6d13406d1a5 ("tty: Add EXTPROC support for LINEMODE")
allows a process which has opened a pty master to send _any_ signal
to the process group of the pty slave. Although potentially
exploitable by a malicious program running a setuid program on
a pty slave, it's unknown if this exploit currently exists.

Limit to signals actually used.

Cc: Theodore Ts'o &lt;tytso@mit.edu&gt;
Cc: Howard Chu &lt;hyc@symas.com&gt;
Cc: One Thousand Gnomes &lt;gnomes@lxorguk.ukuu.org.uk&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&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>
commit 37480a05685ed5b8e1b9bf5e5c53b5810258b149 upstream.

Commit 26df6d13406d1a5 ("tty: Add EXTPROC support for LINEMODE")
allows a process which has opened a pty master to send _any_ signal
to the process group of the pty slave. Although potentially
exploitable by a malicious program running a setuid program on
a pty slave, it's unknown if this exploit currently exists.

Limit to signals actually used.

Cc: Theodore Ts'o &lt;tytso@mit.edu&gt;
Cc: Howard Chu &lt;hyc@symas.com&gt;
Cc: One Thousand Gnomes &lt;gnomes@lxorguk.ukuu.org.uk&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&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>
<entry>
<title>tty: Fix transient pty write() EIO</title>
<updated>2013-06-17T19:37:29+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-13T19:56:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7c61c3d8f44d5d822f758754287af644307b4af9'/>
<id>7c61c3d8f44d5d822f758754287af644307b4af9</id>
<content type='text'>
Commit 699390354da6c258b65bf8fa79cfd5feaede50b6
('pty: Ignore slave pty close() if never successfully opened')
introduced a bug with ptys whereby a write() in parallel with an
open() on an existing pty could mistakenly indicate an I/O error.

Only indicate an I/O error if the condition on open() actually exists.

Reported-by: Markus Trippelsdorf &lt;markus@trippelsdorf.de&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.9
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 699390354da6c258b65bf8fa79cfd5feaede50b6
('pty: Ignore slave pty close() if never successfully opened')
introduced a bug with ptys whereby a write() in parallel with an
open() on an existing pty could mistakenly indicate an I/O error.

Only indicate an I/O error if the condition on open() actually exists.

Reported-by: Markus Trippelsdorf &lt;markus@trippelsdorf.de&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.9
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: fix up atime/mtime mess, take three</title>
<updated>2013-05-01T14:32:21+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2013-05-01T14:32:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b0b885657b6c8ef63a46bc9299b2a7715d19acde'/>
<id>b0b885657b6c8ef63a46bc9299b2a7715d19acde</id>
<content type='text'>
We first tried to avoid updating atime/mtime entirely (commit
b0de59b5733d: "TTY: do not update atime/mtime on read/write"), and then
limited it to only update it occasionally (commit 37b7f3c76595: "TTY:
fix atime/mtime regression"), but it turns out that this was both
insufficient and overkill.

It was insufficient because we let people attach to the shared ptmx node
to see activity without even reading atime/mtime, and it was overkill
because the "only once a minute" means that you can't really tell an
idle person from an active one with 'w'.

So this tries to fix the problem properly.  It marks the shared ptmx
node as un-notifiable, and it lowers the "only once a minute" to a few
seconds instead - still long enough that you can't time individual
keystrokes, but short enough that you can tell whether somebody is
active or not.

Reported-by: Simon Kirby &lt;sim@hostway.ca&gt;
Acked-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We first tried to avoid updating atime/mtime entirely (commit
b0de59b5733d: "TTY: do not update atime/mtime on read/write"), and then
limited it to only update it occasionally (commit 37b7f3c76595: "TTY:
fix atime/mtime regression"), but it turns out that this was both
insufficient and overkill.

It was insufficient because we let people attach to the shared ptmx node
to see activity without even reading atime/mtime, and it was overkill
because the "only once a minute" means that you can't really tell an
idle person from an active one with 'w'.

So this tries to fix the problem properly.  It marks the shared ptmx
node as un-notifiable, and it lowers the "only once a minute" to a few
seconds instead - still long enough that you can't time individual
keystrokes, but short enough that you can tell whether somebody is
active or not.

Reported-by: Simon Kirby &lt;sim@hostway.ca&gt;
Acked-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>TTY: pty, fix compilation warning</title>
<updated>2013-04-15T18:02:54+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2013-04-15T05:52:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f4b208eb91776b0522b41c78fac6cf08134db78f'/>
<id>f4b208eb91776b0522b41c78fac6cf08134db78f</id>
<content type='text'>
When CONFIG_UNIX98_PTYS is unset, we see this warning in pty:
  drivers/tty/pty.c:409:13: warning: ‘pty_unix98_shutdown’ defined but not used

Fix that by moving the function to a section which depends on that
config.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Toralf Foerster &lt;toralf.foerster@gmx.de&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>
When CONFIG_UNIX98_PTYS is unset, we see this warning in pty:
  drivers/tty/pty.c:409:13: warning: ‘pty_unix98_shutdown’ defined but not used

Fix that by moving the function to a section which depends on that
config.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Toralf Foerster &lt;toralf.foerster@gmx.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pty: Remove redundant itty reset</title>
<updated>2013-03-15T20:00:48+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-02-05T21:08:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=19ffd68f816878aed456d5e87697f43bd9e3bd2b'/>
<id>19ffd68f816878aed456d5e87697f43bd9e3bd2b</id>
<content type='text'>
port-&gt;itty has already been reset by release_tty() before
pty_cleanup() is called.

Call stack:
release_tty()
  tty_kref_put()
    queue_release_one_tty()
      release_one_tty() : workqueue
        tty-&gt;ops-&gt;cleanup()
          pty_cleanup()

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>
port-&gt;itty has already been reset by release_tty() before
pty_cleanup() is called.

Call stack:
release_tty()
  tty_kref_put()
    queue_release_one_tty()
      release_one_tty() : workqueue
        tty-&gt;ops-&gt;cleanup()
          pty_cleanup()

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>pty: Ignore slave open count for master pty open</title>
<updated>2013-02-04T23:40:29+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-01-30T17:43:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=80cace72566633bb99da1f022f71d3dac3498b02'/>
<id>80cace72566633bb99da1f022f71d3dac3498b02</id>
<content type='text'>
Multiple slave pty opens may be performed in parallel with the
master open. Of course, all the slave opens will fail because the
master pty is still locked but during this time the slave pty
count will be artificially greater than 1. This is should not
cause the master pty open to fail.

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>
Multiple slave pty opens may be performed in parallel with the
master open. Of course, all the slave opens will fail because the
master pty is still locked but during this time the slave pty
count will be artificially greater than 1. This is should not
cause the master pty open to fail.

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>pty: Ignore slave pty close() if never successfully opened</title>
<updated>2013-02-04T23:40:28+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-01-30T17:43:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=699390354da6c258b65bf8fa79cfd5feaede50b6'/>
<id>699390354da6c258b65bf8fa79cfd5feaede50b6</id>
<content type='text'>
If the master and slave ptys are opened in parallel, the slave open
fails because the pty is still locked. This is as designed.
However, pty_close() is still called for the slave pty which sets
TTY_OTHER_CLOSED in the master pty. This can cause the master open
to fail as well.

Use a common pattern in other tty drivers by setting TTY_IO_ERROR
until the open is successful and only closing the pty if not set.

Note: the master pty always closes regardless of whether the open
was successful, so that proper cleanup can occur.

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>
If the master and slave ptys are opened in parallel, the slave open
fails because the pty is still locked. This is as designed.
However, pty_close() is still called for the slave pty which sets
TTY_OTHER_CLOSED in the master pty. This can cause the master open
to fail as well.

Use a common pattern in other tty drivers by setting TTY_IO_ERROR
until the open is successful and only closing the pty if not set.

Note: the master pty always closes regardless of whether the open
was successful, so that proper cleanup can occur.

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>pty: Fix BUG()s when ptmx_open() errors out</title>
<updated>2013-02-04T23:40:28+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-01-30T17:43:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7acf6cd80b201f77371a5374a786144153629be8'/>
<id>7acf6cd80b201f77371a5374a786144153629be8</id>
<content type='text'>
If pmtx_open() fails to get a slave inode or fails the pty_open(),
the tty is released as part of the error cleanup. As evidenced by the
first BUG stacktrace below, pty_close() assumes that the linked pty has
a valid, initialized inode* stored in driver_data.

Also, as evidenced by the second BUG stacktrace below, pty_unix98_shutdown()
assumes that the master pty's driver_data has been initialized.

1) Fix the invalid assumption in pty_close().
2) Initialize driver_data immediately so proper devpts fs cleanup occurs.

Fixes this BUG:

[  815.868844] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[  815.869018] IP: [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.869190] PGD 7c775067 PUD 79deb067 PMD 0
[  815.869315] Oops: 0000 [#1] PREEMPT SMP
[  815.869443] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi microcode snd_rawmidi psmouse serio_raw snd_seq_midi_event snd_seq snd_timer$
[  815.870025] CPU 0
[  815.870143] Pid: 27819, comm: stress_test_tty Tainted: G        W    3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs
[  815.870386] RIP: 0010:[&lt;ffffffff81207bcc&gt;]  [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.870540] RSP: 0018:ffff88007d3e1ac8  EFLAGS: 00010282
[  815.870661] RAX: ffff880079c20800 RBX: 0000000000000000 RCX: 0000000000000000
[  815.870804] RDX: ffff880079c209a8 RSI: 0000000000000286 RDI: 0000000000000000
[  815.870933] RBP: ffff88007d3e1ae8 R08: 0000000000000000 R09: 0000000000000000
[  815.871078] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88007bfb7e00
[  815.871209] R13: 0000000000000005 R14: ffff880079c20c00 R15: ffff880079c20c00
[  815.871343] FS:  00007f2e86206700(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
[  815.871495] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  815.871617] CR2: 0000000000000028 CR3: 000000007ae56000 CR4: 00000000000006f0
[  815.871752] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  815.871902] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  815.872012] Process stress_test_tty (pid: 27819, threadinfo ffff88007d3e0000, task ffff88007c874530)
[  815.872012] Stack:
[  815.872012]  ffff88007bfb7e00 ffff880079c20c00 ffff88007bfb7e00 0000000000000005
[  815.872012]  ffff88007d3e1b08 ffffffff81417be7 ffff88007caa9bd8 ffff880079c20800
[  815.872012]  ffff88007d3e1bc8 ffffffff8140e5f8 0000000000000000 0000000000000000
[  815.872012] Call Trace:
[  815.872012]  [&lt;ffffffff81417be7&gt;] pty_close+0x157/0x170
[  815.872012]  [&lt;ffffffff8140e5f8&gt;] tty_release+0x138/0x580
[  815.872012]  [&lt;ffffffff816d29f3&gt;] ? _raw_spin_lock+0x23/0x30
[  815.872012]  [&lt;ffffffff816d267a&gt;] ? _raw_spin_unlock+0x1a/0x40
[  815.872012]  [&lt;ffffffff816d0178&gt;] ? __mutex_unlock_slowpath+0x48/0x60
[  815.872012]  [&lt;ffffffff81417dff&gt;] ptmx_open+0x11f/0x180
[  815.872012]  [&lt;ffffffff8119394b&gt;] chrdev_open+0x9b/0x1c0
[  815.872012]  [&lt;ffffffff8118d643&gt;] do_dentry_open+0x203/0x290
[  815.872012]  [&lt;ffffffff811938b0&gt;] ? cdev_put+0x30/0x30
[  815.872012]  [&lt;ffffffff8118d705&gt;] finish_open+0x35/0x50
[  815.872012]  [&lt;ffffffff8119dcce&gt;] do_last+0x6fe/0xe90
[  815.872012]  [&lt;ffffffff8119a7af&gt;] ? link_path_walk+0x7f/0x880
[  815.872012]  [&lt;ffffffff810909d5&gt;] ? cpuacct_charge+0x75/0x80
[  815.872012]  [&lt;ffffffff8119e51c&gt;] path_openat+0xbc/0x4e0
[  815.872012]  [&lt;ffffffff816d0fd0&gt;] ? __schedule+0x400/0x7f0
[  815.872012]  [&lt;ffffffff8140e956&gt;] ? tty_release+0x496/0x580
[  815.872012]  [&lt;ffffffff8119ec11&gt;] do_filp_open+0x41/0xa0
[  815.872012]  [&lt;ffffffff816d267a&gt;] ? _raw_spin_unlock+0x1a/0x40
[  815.872012]  [&lt;ffffffff811abe39&gt;] ? __alloc_fd+0xe9/0x140
[  815.872012]  [&lt;ffffffff8118ea44&gt;] do_sys_open+0xf4/0x1e0
[  815.872012]  [&lt;ffffffff8118eb51&gt;] sys_open+0x21/0x30
[  815.872012]  [&lt;ffffffff816da499&gt;] system_call_fastpath+0x16/0x1b
[  815.872012] Code: 0f 1f 80 00 00 00 00 45 31 e4 eb d7 0f 0b 90 0f 1f 44 00 00 55 48 89 e5 48 83 ec 20 48 89 5d e8 48 89 fb 4c 89 65 f0 4c 89 6d f8 &lt;48&gt; 8b 47 28 48 81 78 58 d1 1c 0$
[  815.872012] RIP  [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.872012]  RSP &lt;ffff88007d3e1ac8&gt;
[  815.872012] CR2: 0000000000000028
[  815.897036] ---[ end trace eadf50b7f34e47d5 ]---

Fixes this BUG also:

[  608.366836] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[  608.366948] IP: [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.367050] PGD 7c75b067 PUD 7b919067 PMD 0
[  608.367135] Oops: 0000 [#1] PREEMPT SMP
[  608.367201] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event microcode snd_seq psmouse snd_timer snd_seq_device serio_raw snd mac_hid soundcore snd_page_alloc rfcomm virtio_balloon parport_pc bnep bluetooth ppdev i2c_piix4 lp parport floppy
[  608.367617] CPU 2
[  608.367669] Pid: 1918, comm: stress_test_tty Tainted: G        W    3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs
[  608.367796] RIP: 0010:[&lt;ffffffff812078d8&gt;]  [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.367885] RSP: 0018:ffff88007ae41a88  EFLAGS: 00010286
[  608.367951] RAX: ffffffff81417e80 RBX: ffff880036472400 RCX: 0000000180400028
[  608.368010] RDX: ffff880036470004 RSI: 0000000000000004 RDI: 0000000000000000
[  608.368010] RBP: ffff88007ae41a98 R08: 0000000000000000 R09: 0000000000000001
[  608.368010] R10: ffffea0001f22e40 R11: ffffffff814151d5 R12: 0000000000000004
[  608.368010] R13: ffff880036470000 R14: 0000000000000004 R15: ffff880036472400
[  608.368010] FS:  00007ff7a5268700(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000
[  608.368010] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  608.368010] CR2: 0000000000000028 CR3: 000000007a0fd000 CR4: 00000000000006e0
[  608.368010] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  608.368010] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  608.368010] Process stress_test_tty (pid: 1918, threadinfo ffff88007ae40000, task ffff88003688dc40)
[  608.368010] Stack:
[  608.368010]  ffff880036472400 0000000000000001 ffff88007ae41aa8 ffffffff81417e98
[  608.368010]  ffff88007ae41ac8 ffffffff8140c42b ffff88007ac73100 ffff88007ac73100
[  608.368010]  ffff88007ae41b98 ffffffff8140ead5 ffff88007ae41b38 ffff88007ca40e40
[  608.368010] Call Trace:
[  608.368010]  [&lt;ffffffff81417e98&gt;] pty_unix98_shutdown+0x18/0x20
[  608.368010]  [&lt;ffffffff8140c42b&gt;] release_tty+0x3b/0xe0
[  608.368010]  [&lt;ffffffff8140ead5&gt;] __tty_release+0x575/0x5d0
[  608.368010]  [&lt;ffffffff816d2c63&gt;] ? _raw_spin_lock+0x23/0x30
[  608.368010]  [&lt;ffffffff816d28ea&gt;] ? _raw_spin_unlock+0x1a/0x40
[  608.368010]  [&lt;ffffffff816d03e8&gt;] ? __mutex_unlock_slowpath+0x48/0x60
[  608.368010]  [&lt;ffffffff8140ef79&gt;] tty_open+0x449/0x5f0
[  608.368010]  [&lt;ffffffff8119394b&gt;] chrdev_open+0x9b/0x1c0
[  608.368010]  [&lt;ffffffff8118d643&gt;] do_dentry_open+0x203/0x290
[  608.368010]  [&lt;ffffffff811938b0&gt;] ? cdev_put+0x30/0x30
[  608.368010]  [&lt;ffffffff8118d705&gt;] finish_open+0x35/0x50
[  608.368010]  [&lt;ffffffff8119dcce&gt;] do_last+0x6fe/0xe90
[  608.368010]  [&lt;ffffffff8119a7af&gt;] ? link_path_walk+0x7f/0x880
[  608.368010]  [&lt;ffffffff8119e51c&gt;] path_openat+0xbc/0x4e0
[  608.368010]  [&lt;ffffffff8119ec11&gt;] do_filp_open+0x41/0xa0
[  608.368010]  [&lt;ffffffff816d28ea&gt;] ? _raw_spin_unlock+0x1a/0x40
[  608.368010]  [&lt;ffffffff811abe39&gt;] ? __alloc_fd+0xe9/0x140
[  608.368010]  [&lt;ffffffff8118ea44&gt;] do_sys_open+0xf4/0x1e0
[  608.368010]  [&lt;ffffffff816d2c63&gt;] ? _raw_spin_lock+0x23/0x30
[  608.368010]  [&lt;ffffffff8118eb51&gt;] sys_open+0x21/0x30
[  608.368010]  [&lt;ffffffff816da719&gt;] system_call_fastpath+0x16/0x1b
[  608.368010] Code: ec 48 83 c4 10 5b 41 5c 5d c3 66 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 48 83 ec 10 4c 89 65 f8 41 89 f4 48 89 5d f0 &lt;48&gt; 8b 47 28 48 81 78 58 d1 1c 00 00 74 0b 48 8b 05 4b 66 cf 00
[  608.368010] RIP  [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.368010]  RSP &lt;ffff88007ae41a88&gt;
[  608.368010] CR2: 0000000000000028
[  608.394153] ---[ end trace afe83b0fb5fbda93 ]---

Reported-by: Ilya Zykov &lt;ilya@ilyx.ru&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>
If pmtx_open() fails to get a slave inode or fails the pty_open(),
the tty is released as part of the error cleanup. As evidenced by the
first BUG stacktrace below, pty_close() assumes that the linked pty has
a valid, initialized inode* stored in driver_data.

Also, as evidenced by the second BUG stacktrace below, pty_unix98_shutdown()
assumes that the master pty's driver_data has been initialized.

1) Fix the invalid assumption in pty_close().
2) Initialize driver_data immediately so proper devpts fs cleanup occurs.

Fixes this BUG:

[  815.868844] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[  815.869018] IP: [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.869190] PGD 7c775067 PUD 79deb067 PMD 0
[  815.869315] Oops: 0000 [#1] PREEMPT SMP
[  815.869443] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi microcode snd_rawmidi psmouse serio_raw snd_seq_midi_event snd_seq snd_timer$
[  815.870025] CPU 0
[  815.870143] Pid: 27819, comm: stress_test_tty Tainted: G        W    3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs
[  815.870386] RIP: 0010:[&lt;ffffffff81207bcc&gt;]  [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.870540] RSP: 0018:ffff88007d3e1ac8  EFLAGS: 00010282
[  815.870661] RAX: ffff880079c20800 RBX: 0000000000000000 RCX: 0000000000000000
[  815.870804] RDX: ffff880079c209a8 RSI: 0000000000000286 RDI: 0000000000000000
[  815.870933] RBP: ffff88007d3e1ae8 R08: 0000000000000000 R09: 0000000000000000
[  815.871078] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88007bfb7e00
[  815.871209] R13: 0000000000000005 R14: ffff880079c20c00 R15: ffff880079c20c00
[  815.871343] FS:  00007f2e86206700(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
[  815.871495] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  815.871617] CR2: 0000000000000028 CR3: 000000007ae56000 CR4: 00000000000006f0
[  815.871752] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  815.871902] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  815.872012] Process stress_test_tty (pid: 27819, threadinfo ffff88007d3e0000, task ffff88007c874530)
[  815.872012] Stack:
[  815.872012]  ffff88007bfb7e00 ffff880079c20c00 ffff88007bfb7e00 0000000000000005
[  815.872012]  ffff88007d3e1b08 ffffffff81417be7 ffff88007caa9bd8 ffff880079c20800
[  815.872012]  ffff88007d3e1bc8 ffffffff8140e5f8 0000000000000000 0000000000000000
[  815.872012] Call Trace:
[  815.872012]  [&lt;ffffffff81417be7&gt;] pty_close+0x157/0x170
[  815.872012]  [&lt;ffffffff8140e5f8&gt;] tty_release+0x138/0x580
[  815.872012]  [&lt;ffffffff816d29f3&gt;] ? _raw_spin_lock+0x23/0x30
[  815.872012]  [&lt;ffffffff816d267a&gt;] ? _raw_spin_unlock+0x1a/0x40
[  815.872012]  [&lt;ffffffff816d0178&gt;] ? __mutex_unlock_slowpath+0x48/0x60
[  815.872012]  [&lt;ffffffff81417dff&gt;] ptmx_open+0x11f/0x180
[  815.872012]  [&lt;ffffffff8119394b&gt;] chrdev_open+0x9b/0x1c0
[  815.872012]  [&lt;ffffffff8118d643&gt;] do_dentry_open+0x203/0x290
[  815.872012]  [&lt;ffffffff811938b0&gt;] ? cdev_put+0x30/0x30
[  815.872012]  [&lt;ffffffff8118d705&gt;] finish_open+0x35/0x50
[  815.872012]  [&lt;ffffffff8119dcce&gt;] do_last+0x6fe/0xe90
[  815.872012]  [&lt;ffffffff8119a7af&gt;] ? link_path_walk+0x7f/0x880
[  815.872012]  [&lt;ffffffff810909d5&gt;] ? cpuacct_charge+0x75/0x80
[  815.872012]  [&lt;ffffffff8119e51c&gt;] path_openat+0xbc/0x4e0
[  815.872012]  [&lt;ffffffff816d0fd0&gt;] ? __schedule+0x400/0x7f0
[  815.872012]  [&lt;ffffffff8140e956&gt;] ? tty_release+0x496/0x580
[  815.872012]  [&lt;ffffffff8119ec11&gt;] do_filp_open+0x41/0xa0
[  815.872012]  [&lt;ffffffff816d267a&gt;] ? _raw_spin_unlock+0x1a/0x40
[  815.872012]  [&lt;ffffffff811abe39&gt;] ? __alloc_fd+0xe9/0x140
[  815.872012]  [&lt;ffffffff8118ea44&gt;] do_sys_open+0xf4/0x1e0
[  815.872012]  [&lt;ffffffff8118eb51&gt;] sys_open+0x21/0x30
[  815.872012]  [&lt;ffffffff816da499&gt;] system_call_fastpath+0x16/0x1b
[  815.872012] Code: 0f 1f 80 00 00 00 00 45 31 e4 eb d7 0f 0b 90 0f 1f 44 00 00 55 48 89 e5 48 83 ec 20 48 89 5d e8 48 89 fb 4c 89 65 f0 4c 89 6d f8 &lt;48&gt; 8b 47 28 48 81 78 58 d1 1c 0$
[  815.872012] RIP  [&lt;ffffffff81207bcc&gt;] devpts_pty_kill+0x1c/0xa0
[  815.872012]  RSP &lt;ffff88007d3e1ac8&gt;
[  815.872012] CR2: 0000000000000028
[  815.897036] ---[ end trace eadf50b7f34e47d5 ]---

Fixes this BUG also:

[  608.366836] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[  608.366948] IP: [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.367050] PGD 7c75b067 PUD 7b919067 PMD 0
[  608.367135] Oops: 0000 [#1] PREEMPT SMP
[  608.367201] Modules linked in: kvm_intel kvm snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event microcode snd_seq psmouse snd_timer snd_seq_device serio_raw snd mac_hid soundcore snd_page_alloc rfcomm virtio_balloon parport_pc bnep bluetooth ppdev i2c_piix4 lp parport floppy
[  608.367617] CPU 2
[  608.367669] Pid: 1918, comm: stress_test_tty Tainted: G        W    3.8.0-next-20130125+ttypatch-2-xeon #2 Bochs Bochs
[  608.367796] RIP: 0010:[&lt;ffffffff812078d8&gt;]  [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.367885] RSP: 0018:ffff88007ae41a88  EFLAGS: 00010286
[  608.367951] RAX: ffffffff81417e80 RBX: ffff880036472400 RCX: 0000000180400028
[  608.368010] RDX: ffff880036470004 RSI: 0000000000000004 RDI: 0000000000000000
[  608.368010] RBP: ffff88007ae41a98 R08: 0000000000000000 R09: 0000000000000001
[  608.368010] R10: ffffea0001f22e40 R11: ffffffff814151d5 R12: 0000000000000004
[  608.368010] R13: ffff880036470000 R14: 0000000000000004 R15: ffff880036472400
[  608.368010] FS:  00007ff7a5268700(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000
[  608.368010] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  608.368010] CR2: 0000000000000028 CR3: 000000007a0fd000 CR4: 00000000000006e0
[  608.368010] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  608.368010] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  608.368010] Process stress_test_tty (pid: 1918, threadinfo ffff88007ae40000, task ffff88003688dc40)
[  608.368010] Stack:
[  608.368010]  ffff880036472400 0000000000000001 ffff88007ae41aa8 ffffffff81417e98
[  608.368010]  ffff88007ae41ac8 ffffffff8140c42b ffff88007ac73100 ffff88007ac73100
[  608.368010]  ffff88007ae41b98 ffffffff8140ead5 ffff88007ae41b38 ffff88007ca40e40
[  608.368010] Call Trace:
[  608.368010]  [&lt;ffffffff81417e98&gt;] pty_unix98_shutdown+0x18/0x20
[  608.368010]  [&lt;ffffffff8140c42b&gt;] release_tty+0x3b/0xe0
[  608.368010]  [&lt;ffffffff8140ead5&gt;] __tty_release+0x575/0x5d0
[  608.368010]  [&lt;ffffffff816d2c63&gt;] ? _raw_spin_lock+0x23/0x30
[  608.368010]  [&lt;ffffffff816d28ea&gt;] ? _raw_spin_unlock+0x1a/0x40
[  608.368010]  [&lt;ffffffff816d03e8&gt;] ? __mutex_unlock_slowpath+0x48/0x60
[  608.368010]  [&lt;ffffffff8140ef79&gt;] tty_open+0x449/0x5f0
[  608.368010]  [&lt;ffffffff8119394b&gt;] chrdev_open+0x9b/0x1c0
[  608.368010]  [&lt;ffffffff8118d643&gt;] do_dentry_open+0x203/0x290
[  608.368010]  [&lt;ffffffff811938b0&gt;] ? cdev_put+0x30/0x30
[  608.368010]  [&lt;ffffffff8118d705&gt;] finish_open+0x35/0x50
[  608.368010]  [&lt;ffffffff8119dcce&gt;] do_last+0x6fe/0xe90
[  608.368010]  [&lt;ffffffff8119a7af&gt;] ? link_path_walk+0x7f/0x880
[  608.368010]  [&lt;ffffffff8119e51c&gt;] path_openat+0xbc/0x4e0
[  608.368010]  [&lt;ffffffff8119ec11&gt;] do_filp_open+0x41/0xa0
[  608.368010]  [&lt;ffffffff816d28ea&gt;] ? _raw_spin_unlock+0x1a/0x40
[  608.368010]  [&lt;ffffffff811abe39&gt;] ? __alloc_fd+0xe9/0x140
[  608.368010]  [&lt;ffffffff8118ea44&gt;] do_sys_open+0xf4/0x1e0
[  608.368010]  [&lt;ffffffff816d2c63&gt;] ? _raw_spin_lock+0x23/0x30
[  608.368010]  [&lt;ffffffff8118eb51&gt;] sys_open+0x21/0x30
[  608.368010]  [&lt;ffffffff816da719&gt;] system_call_fastpath+0x16/0x1b
[  608.368010] Code: ec 48 83 c4 10 5b 41 5c 5d c3 66 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 48 83 ec 10 4c 89 65 f8 41 89 f4 48 89 5d f0 &lt;48&gt; 8b 47 28 48 81 78 58 d1 1c 00 00 74 0b 48 8b 05 4b 66 cf 00
[  608.368010] RIP  [&lt;ffffffff812078d8&gt;] devpts_kill_index+0x18/0x70
[  608.368010]  RSP &lt;ffff88007ae41a88&gt;
[  608.368010] CR2: 0000000000000028
[  608.394153] ---[ end trace afe83b0fb5fbda93 ]---

Reported-by: Ilya Zykov &lt;ilya@ilyx.ru&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>
<entry>
<title>Merge 3.8-rc5 into tty-next</title>
<updated>2013-01-25T21:27:36+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2013-01-25T21:27:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9f9cba810f36d16f4e64477e879a69f6c47b389d'/>
<id>9f9cba810f36d16f4e64477e879a69f6c47b389d</id>
<content type='text'>
This resolves a number of tty driver merge issues found in linux-next

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 resolves a number of tty driver merge issues found in linux-next

Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pty: return EINVAL for TIOCGPTN for BSD ptys</title>
<updated>2013-01-17T21:56:57+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2013-01-11T11:06:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ded2f295a36d17838fe97e80d7b6ea83381474f8'/>
<id>ded2f295a36d17838fe97e80d7b6ea83381474f8</id>
<content type='text'>
Commit bbb63c514a3464342967237a51a21ea8f61ab951 (drivers:tty:fix up
ENOIOCTLCMD error handling) changed the default return value from tty
ioctl to be ENOTTY and not EINVAL. This is appropriate.

But in case of TIOCGPTN for the old BSD ptys glibc started failing
because it expects EINVAL to be returned. Only then it continues to
obtain the pts name the other way around.

So fix this case by explicit return of EINVAL in this case.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Florian Westphal &lt;fw@strlen.de&gt;
Cc: Alan Cox &lt;alan@linux.intel.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.7+
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 bbb63c514a3464342967237a51a21ea8f61ab951 (drivers:tty:fix up
ENOIOCTLCMD error handling) changed the default return value from tty
ioctl to be ENOTTY and not EINVAL. This is appropriate.

But in case of TIOCGPTN for the old BSD ptys glibc started failing
because it expects EINVAL to be returned. Only then it continues to
obtain the pts name the other way around.

So fix this case by explicit return of EINVAL in this case.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Florian Westphal &lt;fw@strlen.de&gt;
Cc: Alan Cox &lt;alan@linux.intel.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.7+
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
