lkml.org 
[lkml]   [2013]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tty: Fix transient pty write() EIO
Peter Hurley writes:
> 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 <markus@trippelsdorf.de>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>

I've tested this for two days on 3.9.0 (where the bug reproduces
easily for me, for some reason I can't seem to trigger it with
3.10-rc5), and with the patch I no longer see the bug.

Tested-by: Mikael Pettersson <mikpe@it.uu.se>

> ---
> drivers/tty/pty.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
> index 9c2f1bc..dd08d3d 100644
> --- a/drivers/tty/pty.c
> +++ b/drivers/tty/pty.c
> @@ -238,14 +238,9 @@ static void pty_flush_buffer(struct tty_struct *tty)
>
> static int pty_open(struct tty_struct *tty, struct file *filp)
> {
> - int retval = -ENODEV;
> -
> if (!tty || !tty->link)
> - goto out;
> -
> - set_bit(TTY_IO_ERROR, &tty->flags);
> + return -ENODEV;
>
> - retval = -EIO;
> if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
> goto out;
> if (test_bit(TTY_PTY_LOCK, &tty->link->flags))
> @@ -256,9 +251,11 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
> clear_bit(TTY_IO_ERROR, &tty->flags);
> clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
> set_bit(TTY_THROTTLED, &tty->flags);
> - retval = 0;
> + return 0;
> +
> out:
> - return retval;
> + set_bit(TTY_IO_ERROR, &tty->flags);
> + return -EIO;
> }
>
> static void pty_set_termios(struct tty_struct *tty,
> --
> 1.8.1.2
>


\
 
 \ /
  Last update: 2013-06-16 20:01    [W:0.051 / U:1.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site