diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2006-09-29 05:00:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 12:18:16 -0400 |
commit | 808a0d389ff8d85017ec811085a6083394c02caf (patch) | |
tree | bdd458bced9222bcf9515c3e3b4d349304c9d1a4 /drivers/char/tty_io.c | |
parent | 1266b1e1aed0a4d7d5cb569deca8c31cba34a990 (diff) |
[PATCH] tty: lock ticogwinsz
Now we lock the set ioctl its trivial to lock the get one so the data
copied is consistent. At the moment we have the BKL here but this removes
the need for it and is a step in the right direction
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 18085a20df23..b4f37c65b95c 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2740,18 +2740,21 @@ static int tiocsti(struct tty_struct *tty, char __user *p) | |||
2740 | * @tty; tty | 2740 | * @tty; tty |
2741 | * @arg: user buffer for result | 2741 | * @arg: user buffer for result |
2742 | * | 2742 | * |
2743 | * Copies the kernel idea of the window size into the user buffer. No | 2743 | * Copies the kernel idea of the window size into the user buffer. |
2744 | * locking is done. | ||
2745 | * | 2744 | * |
2746 | * FIXME: Returning random values racing a window size set is wrong | 2745 | * Locking: tty->termios_sem is taken to ensure the winsize data |
2747 | * should lock here against that | 2746 | * is consistent. |
2748 | */ | 2747 | */ |
2749 | 2748 | ||
2750 | static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) | 2749 | static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) |
2751 | { | 2750 | { |
2752 | if (copy_to_user(arg, &tty->winsize, sizeof(*arg))) | 2751 | int err; |
2753 | return -EFAULT; | 2752 | |
2754 | return 0; | 2753 | down(&tty->termios_sem); |
2754 | err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); | ||
2755 | up(&tty->termios_sem); | ||
2756 | |||
2757 | return err ? -EFAULT: 0; | ||
2755 | } | 2758 | } |
2756 | 2759 | ||
2757 | /** | 2760 | /** |