diff options
author | Konstantin Khlebnikov <khlebnikov@openvz.org> | 2012-01-05 04:04:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-24 16:56:10 -0500 |
commit | 593a27c4b212e2afdf772a1f8dcb894e91bda0fa (patch) | |
tree | 6b670f6ec0ef138fcfa6e68f3b2a456f86941efd /drivers/tty/tty_io.c | |
parent | dcd6c92267155e70a94b3927bce681ce74b80d1f (diff) |
tty: cleanup prohibition of direct opening for unix98 pty master
cleanup hack added in v2.6.27-3203-g15582d3
comment from that patch:
: pty: If the administrator creates a device for a ptmx slave we should not error
:
: The open path for ptmx slaves is via the ptmx device. Opening them any
: other way is not allowed. Vegard Nossum found that previously this was not
: the case and mknod foo c 128 42; cat foo would produce nasty diagnostics
:
: Signed-off-by: Alan Cox <alan@redhat.com>
: Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
devpts_get_tty() returns non-null only for inodes on devpts, but there is no
inodes for master-devices, /dev/ptmx (/dev/pts/ptmx) is the only way to open them.
Thus we can completely forbid lookup for master-devices and eliminate that hack in
tty_init_dev() because tty_open() will get EIO from tty_driver_lookup_tty().
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r-- | drivers/tty/tty_io.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index e41b9bbc107d..fbcc14063804 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -1365,7 +1365,6 @@ static int tty_reopen(struct tty_struct *tty) | |||
1365 | * @driver: tty driver we are opening a device on | 1365 | * @driver: tty driver we are opening a device on |
1366 | * @idx: device index | 1366 | * @idx: device index |
1367 | * @ret_tty: returned tty structure | 1367 | * @ret_tty: returned tty structure |
1368 | * @first_ok: ok to open a new device (used by ptmx) | ||
1369 | * | 1368 | * |
1370 | * Prepare a tty device. This may not be a "new" clean device but | 1369 | * Prepare a tty device. This may not be a "new" clean device but |
1371 | * could also be an active device. The pty drivers require special | 1370 | * could also be an active device. The pty drivers require special |
@@ -1385,18 +1384,11 @@ static int tty_reopen(struct tty_struct *tty) | |||
1385 | * relaxed for the (most common) case of reopening a tty. | 1384 | * relaxed for the (most common) case of reopening a tty. |
1386 | */ | 1385 | */ |
1387 | 1386 | ||
1388 | struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | 1387 | struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) |
1389 | int first_ok) | ||
1390 | { | 1388 | { |
1391 | struct tty_struct *tty; | 1389 | struct tty_struct *tty; |
1392 | int retval; | 1390 | int retval; |
1393 | 1391 | ||
1394 | /* Check if pty master is being opened multiple times */ | ||
1395 | if (driver->subtype == PTY_TYPE_MASTER && | ||
1396 | (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) { | ||
1397 | return ERR_PTR(-EIO); | ||
1398 | } | ||
1399 | |||
1400 | /* | 1392 | /* |
1401 | * First time open is complex, especially for PTY devices. | 1393 | * First time open is complex, especially for PTY devices. |
1402 | * This code guarantees that either everything succeeds and the | 1394 | * This code guarantees that either everything succeeds and the |
@@ -1950,7 +1942,7 @@ retry_open: | |||
1950 | if (retval) | 1942 | if (retval) |
1951 | tty = ERR_PTR(retval); | 1943 | tty = ERR_PTR(retval); |
1952 | } else | 1944 | } else |
1953 | tty = tty_init_dev(driver, index, 0); | 1945 | tty = tty_init_dev(driver, index); |
1954 | 1946 | ||
1955 | mutex_unlock(&tty_mutex); | 1947 | mutex_unlock(&tty_mutex); |
1956 | if (driver) | 1948 | if (driver) |