diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-08-26 14:55:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-27 17:37:09 -0400 |
commit | a152db71d962f405f7e9be5c818bddf6d1be50a7 (patch) | |
tree | ec9bd5c50f1e925318488d585a8504a552a63f30 /drivers/char | |
parent | f753f3272b4d2108d1e4b121ddcde504737a8693 (diff) |
tty: Fix termios tty window resize race with pty/tty pair
Kanru Chen posted a patch versus the old code which deals with the case
where you resize the pty side of a pty/tty pair. In that situation the
termios data is updated for both pty and tty but the locks are not held
for the right side.
This implements the fix differently against the updated tty code. Patch
by self but the hard bit (noticing and fixing the bug) is thanks to Kanru
Chen.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tty_io.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index a27160ba21d7..daeb8f766971 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2498,7 +2498,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2498 | /** | 2498 | /** |
2499 | * tty_do_resize - resize event | 2499 | * tty_do_resize - resize event |
2500 | * @tty: tty being resized | 2500 | * @tty: tty being resized |
2501 | * @real_tty: real tty (if using a pty/tty pair) | 2501 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) |
2502 | * @rows: rows (character) | 2502 | * @rows: rows (character) |
2503 | * @cols: cols (character) | 2503 | * @cols: cols (character) |
2504 | * | 2504 | * |
@@ -2512,7 +2512,8 @@ int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2512 | struct pid *pgrp, *rpgrp; | 2512 | struct pid *pgrp, *rpgrp; |
2513 | unsigned long flags; | 2513 | unsigned long flags; |
2514 | 2514 | ||
2515 | mutex_lock(&tty->termios_mutex); | 2515 | /* For a PTY we need to lock the tty side */ |
2516 | mutex_lock(&real_tty->termios_mutex); | ||
2516 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) | 2517 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) |
2517 | goto done; | 2518 | goto done; |
2518 | /* Get the PID values and reference them so we can | 2519 | /* Get the PID values and reference them so we can |
@@ -2533,7 +2534,7 @@ int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2533 | tty->winsize = *ws; | 2534 | tty->winsize = *ws; |
2534 | real_tty->winsize = *ws; | 2535 | real_tty->winsize = *ws; |
2535 | done: | 2536 | done: |
2536 | mutex_unlock(&tty->termios_mutex); | 2537 | mutex_unlock(&real_tty->termios_mutex); |
2537 | return 0; | 2538 | return 0; |
2538 | } | 2539 | } |
2539 | 2540 | ||