Skip to content

Commit

Permalink
tty: Hold termios_rwsem for tcflow(TCIxxx)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Sep 24, 2014
1 parent 136d525 commit c274f6e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/tty/tty_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c274f6e

Please sign in to comment.