Commit 808a0d38 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[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: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1266b1e1
...@@ -2740,18 +2740,21 @@ static int tiocsti(struct tty_struct *tty, char __user *p) ...@@ -2740,18 +2740,21 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
* @tty; tty * @tty; tty
* @arg: user buffer for result * @arg: user buffer for result
* *
* Copies the kernel idea of the window size into the user buffer. No * Copies the kernel idea of the window size into the user buffer.
* locking is done.
* *
* FIXME: Returning random values racing a window size set is wrong * Locking: tty->termios_sem is taken to ensure the winsize data
* should lock here against that * is consistent.
*/ */
static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg)
{ {
if (copy_to_user(arg, &tty->winsize, sizeof(*arg))) int err;
return -EFAULT;
return 0; down(&tty->termios_sem);
err = copy_to_user(arg, &tty->winsize, sizeof(*arg));
up(&tty->termios_sem);
return err ? -EFAULT: 0;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment