]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.7.4/pty-return-einval-for-tiocgptn-for-bsd-ptys.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.7.4 / pty-return-einval-for-tiocgptn-for-bsd-ptys.patch
1 From ded2f295a36d17838fe97e80d7b6ea83381474f8 Mon Sep 17 00:00:00 2001
2 From: Jiri Slaby <jslaby@suse.cz>
3 Date: Fri, 11 Jan 2013 12:06:27 +0100
4 Subject: pty: return EINVAL for TIOCGPTN for BSD ptys
5
6 From: Jiri Slaby <jslaby@suse.cz>
7
8 commit ded2f295a36d17838fe97e80d7b6ea83381474f8 upstream.
9
10 Commit bbb63c514a3464342967237a51a21ea8f61ab951 (drivers:tty:fix up
11 ENOIOCTLCMD error handling) changed the default return value from tty
12 ioctl to be ENOTTY and not EINVAL. This is appropriate.
13
14 But in case of TIOCGPTN for the old BSD ptys glibc started failing
15 because it expects EINVAL to be returned. Only then it continues to
16 obtain the pts name the other way around.
17
18 So fix this case by explicit return of EINVAL in this case.
19
20 Signed-off-by: Jiri Slaby <jslaby@suse.cz>
21 Reported-by: Florian Westphal <fw@strlen.de>
22 Cc: Alan Cox <alan@linux.intel.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/tty/pty.c | 2 ++
27 1 file changed, 2 insertions(+)
28
29 --- a/drivers/tty/pty.c
30 +++ b/drivers/tty/pty.c
31 @@ -395,6 +395,8 @@ static int pty_bsd_ioctl(struct tty_stru
32 return pty_set_lock(tty, (int __user *) arg);
33 case TIOCSIG: /* Send signal to other side of pty */
34 return pty_signal(tty, (int) arg);
35 + case TIOCGPTN: /* TTY returns ENOTTY, but glibc expects EINVAL here */
36 + return -EINVAL;
37 }
38 return -ENOIOCTLCMD;
39 }