aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@openvz.org>2012-01-05 04:04:21 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-24 16:56:10 -0500
commit593a27c4b212e2afdf772a1f8dcb894e91bda0fa (patch)
tree6b670f6ec0ef138fcfa6e68f3b2a456f86941efd /drivers/tty/pty.c
parentdcd6c92267155e70a94b3927bce681ce74b80d1f (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/pty.c')
-rw-r--r--drivers/tty/pty.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d8653ab6f49..03147fa31d4 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -515,10 +515,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
515static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver, 515static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver,
516 struct inode *ptm_inode, int idx) 516 struct inode *ptm_inode, int idx)
517{ 517{
518 struct tty_struct *tty = devpts_get_tty(ptm_inode, idx); 518 /* Master must be open via /dev/ptmx */
519 if (tty) 519 return ERR_PTR(-EIO);
520 tty = tty->link;
521 return tty;
522} 520}
523 521
524/** 522/**
@@ -677,7 +675,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
677 675
678 mutex_lock(&tty_mutex); 676 mutex_lock(&tty_mutex);
679 tty_lock(); 677 tty_lock();
680 tty = tty_init_dev(ptm_driver, index, 1); 678 tty = tty_init_dev(ptm_driver, index);
681 mutex_unlock(&tty_mutex); 679 mutex_unlock(&tty_mutex);
682 680
683 if (IS_ERR(tty)) { 681 if (IS_ERR(tty)) {