1
0
Fork 0
alistair23-linux/drivers/tty
Peter Hurley e218eb32f5 tty: Serialize proc_set_tty() with tty_lock
Setting the controlling terminal for a session occurs with either
the first open of a non-pty master tty or with ioctl(TIOCSCTTY).
Since only the session leader can set the controlling terminal for
a session (and the session leader cannot change), it is not
necessary to prevent a process from attempting to set different
ttys as the controlling terminal concurrently.

So it's only necessary to prevent the same tty from becoming the
controlling terminal for different session leaders. The tty_lock()
is sufficient to prevent concurrent proc_set_tty() for the same
tty.

Remove the tty_mutex lock region; add tty_lock() to tiocsctty().

While this may appear to allow a race condition between opening
the controlling tty via tty_open_current_tty() and stealing the
controlling tty via ioctl(TIOCSCTTY, 1), that race condition already
existed. Even if the tty_mutex prevented stealing the controlling tty
while tty_open_current_tty() returned the original controlling tty,
it cannot prevent stealing the controlling tty before tty_open() returns.
Thus, tty_open() could already return a no-longer-controlling tty when
opening /dev/tty.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 16:26:14 -08:00
..
hvc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux 2014-10-11 20:34:00 -04:00
ipwireless tty: ipwireless: Remove tty->closing abort from ipw_open() 2014-07-10 16:06:49 -07:00
serial tty: serial: 8250_core: restore the LCR register in set_sleep 2014-11-05 16:23:34 -08:00
vt tty/vt/keyboard: Resolve many shadow warnings 2014-09-08 16:30:43 -07:00
Kconfig drivers/tty: ehv_bytechan fails to build as a module 2014-01-09 17:52:12 -06:00
Makefile tty: Add timed, writer-prioritized rw semaphore 2013-05-20 12:30:32 -07:00
amiserial.c tty/amiserial: avoid interruptible_sleep_on 2014-01-07 17:05:21 -08:00
bfin_jtag_comm.c sched, cleanup, treewide: Remove set_current_state(TASK_RUNNING) after schedule() 2014-09-19 12:35:17 +02:00
cyclades.c tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00
ehv_bytechan.c tty: Update hypervisor tty drivers to use core stdout parsing code. 2014-06-26 17:12:23 +01:00
goldfish.c goldfish: off by one in goldfish_tty_console_setup() 2014-11-05 16:12:45 -08:00
isicom.c
metag_da.c tty/metag_da: Add console_poll module parameter 2014-09-28 21:35:56 -04:00
moxa.c TTY: fix decimal printf format specifiers prefixed with 0x 2014-09-08 15:51:35 -07:00
moxa.h
mxser.c tty: mxser: Fix build warning introduced by dfc7b837c7 (Re: linux-next: build warning after merge of the tty.current tree) 2013-05-22 10:26:02 -07:00
mxser.h
n_gsm.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-08-06 09:38:14 -07:00
n_hdlc.c drivers/tty/n_hdlc.c: replace kmalloc/memset by kzalloc 2014-05-28 13:33:18 -07:00
n_r3964.c tty: Always handle NULL flag ptr 2013-12-08 16:56:05 -08:00
n_tracerouter.c
n_tracesink.c
n_tracesink.h
n_tty.c tty: Fix spurious poll() wakeups 2014-09-08 15:55:25 -07:00
nozomi.c drivers/tty/nozomi.c: Use 'nozomi_setup_memory' instead of 'setup_memory' 2014-09-08 16:09:23 -07:00
pty.c tty: Replace open-coded tty_get_pgrp() 2014-11-05 16:26:13 -08:00
rocket.c tty: remove DEFINE_PCI_DEVICE_TABLE macro 2013-12-08 17:09:07 -08:00
rocket.h
rocket_int.h
synclink.c tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00
synclink_gt.c synclink_gt: use pci_zalloc_consistent 2014-08-08 15:57:30 -07:00
synclinkmp.c tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00
sysrq.c mm, oom: ensure memoryless node zonelist always includes zones 2014-08-06 18:01:21 -07:00
tty_audit.c audit: anchor all pid references in the initial pid namespace 2014-03-20 10:11:55 -04:00
tty_buffer.c Staging: speakup: Update __speakup_paste_selection() tty (ab)usage to match vt 2014-05-24 02:25:11 +09:00
tty_io.c tty: Serialize proc_set_tty() with tty_lock 2014-11-05 16:26:14 -08:00
tty_ioctl.c tty: Hold termios_rwsem for tcflow(TCIxxx) 2014-09-23 21:19:36 -07:00
tty_ldisc.c tty: delete non-required instances of include <linux/init.h> 2014-01-07 17:05:21 -08:00
tty_ldsem.c lockdep: Make held_lock->check and "int check" argument bool 2014-02-09 21:18:54 +01:00
tty_mutex.c
tty_port.c tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00