summaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2006-09-29 02:00:40 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 09:18:16 -0700
commit808a0d389ff8d85017ec811085a6083394c02caf (patch)
treebdd458bced9222bcf9515c3e3b4d349304c9d1a4 /drivers/char/tty_io.c
parent1266b1e1aed0a4d7d5cb569deca8c31cba34a990 (diff)
downloadlinux-808a0d389ff8d85017ec811085a6083394c02caf.tar.bz2
[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.c17
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)
* @tty; tty
* @arg: user buffer for result
*
- * Copies the kernel idea of the window size into the user buffer. No
- * locking is done.
+ * Copies the kernel idea of the window size into the user buffer.
*
- * FIXME: Returning random values racing a window size set is wrong
- * should lock here against that
+ * Locking: tty->termios_sem is taken to ensure the winsize data
+ * is consistent.
*/
static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg)
{
- if (copy_to_user(arg, &tty->winsize, sizeof(*arg)))
- return -EFAULT;
- return 0;
+ int err;
+
+ down(&tty->termios_sem);
+ err = copy_to_user(arg, &tty->winsize, sizeof(*arg));
+ up(&tty->termios_sem);
+
+ return err ? -EFAULT: 0;
}
/**