aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 09:14:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 19:43:01 -0400
commit6a1c0680cf3ba94356ecd58833e1540c93472a57 (patch)
treed370b0888214bb59049181ac98c567d153263f48 /drivers/tty/tty_io.c
parenta2f73be8ee36e48f11f89ab705beb3c587a2f320 (diff)
tty: Convert termios_mutex to termios_rwsem
termios is commonly accessed unsafely (especially by N_TTY) because the existing mutex forces exclusive access. Convert existing usage. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 0fa5db4c7a7a..639e24ade9bf 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -604,7 +604,7 @@ static int tty_signal_session_leader(struct tty_struct *tty, int exit_session)
604 * redirect lock for undoing redirection 604 * redirect lock for undoing redirection
605 * file list lock for manipulating list of ttys 605 * file list lock for manipulating list of ttys
606 * tty_ldiscs_lock from called functions 606 * tty_ldiscs_lock from called functions
607 * termios_mutex resetting termios data 607 * termios_rwsem resetting termios data
608 * tasklist_lock to walk task list for hangup event 608 * tasklist_lock to walk task list for hangup event
609 * ->siglock to protect ->signal/->sighand 609 * ->siglock to protect ->signal/->sighand
610 */ 610 */
@@ -2230,7 +2230,7 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
2230 * 2230 *
2231 * Copies the kernel idea of the window size into the user buffer. 2231 * Copies the kernel idea of the window size into the user buffer.
2232 * 2232 *
2233 * Locking: tty->termios_mutex is taken to ensure the winsize data 2233 * Locking: tty->termios_rwsem is taken to ensure the winsize data
2234 * is consistent. 2234 * is consistent.
2235 */ 2235 */
2236 2236
@@ -2238,9 +2238,9 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg)
2238{ 2238{
2239 int err; 2239 int err;
2240 2240
2241 mutex_lock(&tty->termios_mutex); 2241 down_read(&tty->termios_rwsem);
2242 err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); 2242 err = copy_to_user(arg, &tty->winsize, sizeof(*arg));
2243 mutex_unlock(&tty->termios_mutex); 2243 up_read(&tty->termios_rwsem);
2244 2244
2245 return err ? -EFAULT: 0; 2245 return err ? -EFAULT: 0;
2246} 2246}
@@ -2261,7 +2261,7 @@ int tty_do_resize(struct tty_struct *tty, struct winsize *ws)
2261 unsigned long flags; 2261 unsigned long flags;
2262 2262
2263 /* Lock the tty */ 2263 /* Lock the tty */
2264 mutex_lock(&tty->termios_mutex); 2264 down_write(&tty->termios_rwsem);
2265 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) 2265 if (!memcmp(ws, &tty->winsize, sizeof(*ws)))
2266 goto done; 2266 goto done;
2267 /* Get the PID values and reference them so we can 2267 /* Get the PID values and reference them so we can
@@ -2276,7 +2276,7 @@ int tty_do_resize(struct tty_struct *tty, struct winsize *ws)
2276 2276
2277 tty->winsize = *ws; 2277 tty->winsize = *ws;
2278done: 2278done:
2279 mutex_unlock(&tty->termios_mutex); 2279 up_write(&tty->termios_rwsem);
2280 return 0; 2280 return 0;
2281} 2281}
2282EXPORT_SYMBOL(tty_do_resize); 2282EXPORT_SYMBOL(tty_do_resize);
@@ -3015,7 +3015,7 @@ void initialize_tty_struct(struct tty_struct *tty,
3015 tty->session = NULL; 3015 tty->session = NULL;
3016 tty->pgrp = NULL; 3016 tty->pgrp = NULL;
3017 mutex_init(&tty->legacy_mutex); 3017 mutex_init(&tty->legacy_mutex);
3018 mutex_init(&tty->termios_mutex); 3018 init_rwsem(&tty->termios_rwsem);
3019 init_ldsem(&tty->ldisc_sem); 3019 init_ldsem(&tty->ldisc_sem);
3020 init_waitqueue_head(&tty->write_wait); 3020 init_waitqueue_head(&tty->write_wait);
3021 init_waitqueue_head(&tty->read_wait); 3021 init_waitqueue_head(&tty->read_wait);