From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: PATCH: lock ticogwinsz
Date: Wed, 16 Aug 2006 17:30:44 +0100 [thread overview]
Message-ID: <1155745844.24077.357.camel@localhost.localdomain> (raw)
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>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.18-rc4-mm1/drivers/char/tty_io.c linux-2.6.18-rc4-mm1/drivers/char/tty_io.c
--- linux.vanilla-2.6.18-rc4-mm1/drivers/char/tty_io.c 2006-08-15 15:40:16.000000000 +0100
+++ linux-2.6.18-rc4-mm1/drivers/char/tty_io.c 2006-08-15 16:01:19.000000000 +0100
@@ -2746,18 +2742,21 @@
* @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;
}
/**
reply other threads:[~2006-08-16 16:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1155745844.24077.357.camel@localhost.localdomain \
--to=alan@lxorguk.ukuu.org.uk \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome