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>
This commit is contained in:
Peter Hurley 2013-06-15 09:14:23 -04:00 committed by Greg Kroah-Hartman
commit 6a1c0680cf
8 changed files with 70 additions and 69 deletions

View file

@ -10,6 +10,7 @@
#include <linux/mutex.h>
#include <linux/tty_flags.h>
#include <uapi/linux/tty.h>
#include <linux/rwsem.h>
@ -243,9 +244,9 @@ struct tty_struct {
struct mutex atomic_write_lock;
struct mutex legacy_mutex;
struct mutex termios_mutex;
struct rw_semaphore termios_rwsem;
spinlock_t ctrl_lock;
/* Termios values are protected by the termios mutex */
/* Termios values are protected by the termios rwsem */
struct ktermios termios, termios_locked;
struct termiox *termiox; /* May be NULL for unsupported */
char name[64];
@ -253,7 +254,7 @@ struct tty_struct {
struct pid *session;
unsigned long flags;
int count;
struct winsize winsize; /* termios mutex */
struct winsize winsize; /* termios rwsem */
unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
unsigned char ctrl_status; /* ctrl_lock */
unsigned int receive_room; /* Bytes free for queue */