diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-09-10 19:06:35 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-09-24 04:19:36 (GMT) |
commit | c274f6ef1c6665632767d32e4ab912aad839ce27 (patch) | |
tree | fb916689439d10e29c55abc4e0af24e38ec203ec | |
parent | 136d5258b2bc4ffae99cb69874a76624c26fbfad (diff) | |
download | linux-c274f6ef1c6665632767d32e4ab912aad839ce27.tar.xz |
tty: Hold termios_rwsem for tcflow(TCIxxx)
While transmitting a START/STOP char for tcflow(TCION/TCIOFF), prevent
a termios change. Otherwise, a garbage in-band flow control char
may be sent, if the termios change overlaps the transmission setup.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/tty_ioctl.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index ad9120d..62380cc 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -1164,17 +1164,21 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, spin_unlock_irq(&tty->flow_lock); break; case TCIOFF: + down_read(&tty->termios_rwsem); if (STOP_CHAR(tty) != __DISABLED_CHAR) - return tty_send_xchar(tty, STOP_CHAR(tty)); + retval = tty_send_xchar(tty, STOP_CHAR(tty)); + up_read(&tty->termios_rwsem); break; case TCION: + down_read(&tty->termios_rwsem); if (START_CHAR(tty) != __DISABLED_CHAR) - return tty_send_xchar(tty, START_CHAR(tty)); + retval = tty_send_xchar(tty, START_CHAR(tty)); + up_read(&tty->termios_rwsem); break; default: return -EINVAL; } - return 0; + return retval; case TCFLSH: retval = tty_check_change(tty); if (retval) |