aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-12-30 10:39:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-09 16:46:02 -0500
commit86f2c00f1d8e344965cf8df8572ed5f682956995 (patch)
tree3afe1620aba69b36ab45ff9fe26e368e452f25eb /drivers
parent72a3c0e4e6624a77ee6eee0903f209185fe20647 (diff)
tty: Prevent hw state corruption in exclusive mode reopen
Exclusive mode ttys (TTY_EXCLUSIVE) do not allow further reopens; fail the condition before associating the file pointer and calling the driver open() method. Prevents DTR programming when the tty is already in exclusive mode. Reported-by: Shreyas Bethur <shreyas.bethur@ni.com> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Acked-by: Shreyas Bethur <shreyas.bethur@ni.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/tty_io.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 4f35b43e2475..51f066aa375e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1464,6 +1464,9 @@ static int tty_reopen(struct tty_struct *tty)
1464 driver->subtype == PTY_TYPE_MASTER) 1464 driver->subtype == PTY_TYPE_MASTER)
1465 return -EIO; 1465 return -EIO;
1466 1466
1467 if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
1468 return -EBUSY;
1469
1467 tty->count++; 1470 tty->count++;
1468 1471
1469 WARN_ON(!tty->ldisc); 1472 WARN_ON(!tty->ldisc);
@@ -2106,10 +2109,6 @@ retry_open:
2106 retval = -ENODEV; 2109 retval = -ENODEV;
2107 filp->f_flags = saved_flags; 2110 filp->f_flags = saved_flags;
2108 2111
2109 if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
2110 !capable(CAP_SYS_ADMIN))
2111 retval = -EBUSY;
2112
2113 if (retval) { 2112 if (retval) {
2114#ifdef TTY_DEBUG_HANGUP 2113#ifdef TTY_DEBUG_HANGUP
2115 printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__, 2114 printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,