Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: Retry failed reopen if tty teardown in-progress

A small window exists where a tty reopen will observe the tty
just prior to imminent teardown (tty->count == 0); in this case, open()
returns EIO to userspace.

Instead, retry the open after checking for signals and yielding;
this interruptible retry loop allows teardown to commence and initialize
a new tty on retry. Never retry the BSD master pty reopen; there is no
guarantee the pty pair teardown is imminent since the slave file
descriptors may remain open indefinitely.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Cc: stable <stable@vger.kernel.org> # 4.4
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Hurley and committed by
Greg Kroah-Hartman
7f22f6c9 0bfd464d

+8 -4
+8 -4
drivers/tty/tty_io.c
··· 1463 1463 { 1464 1464 struct tty_driver *driver = tty->driver; 1465 1465 1466 - if (!tty->count) 1467 - return -EIO; 1468 - 1469 1466 if (driver->type == TTY_DRIVER_TYPE_PTY && 1470 1467 driver->subtype == PTY_TYPE_MASTER) 1471 1468 return -EIO; 1469 + 1470 + if (!tty->count) 1471 + return -EAGAIN; 1472 1472 1473 1473 if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) 1474 1474 return -EBUSY; ··· 2088 2088 2089 2089 if (IS_ERR(tty)) { 2090 2090 retval = PTR_ERR(tty); 2091 - goto err_file; 2091 + if (retval != -EAGAIN || signal_pending(current)) 2092 + goto err_file; 2093 + tty_free_file(filp); 2094 + schedule(); 2095 + goto retry_open; 2092 2096 } 2093 2097 2094 2098 tty_add_file(tty, filp);