Commit 86f2c00f authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

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: default avatarShreyas Bethur <shreyas.bethur@ni.com>
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Acked-by: default avatarShreyas Bethur <shreyas.bethur@ni.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 72a3c0e4
...@@ -1464,6 +1464,9 @@ static int tty_reopen(struct tty_struct *tty) ...@@ -1464,6 +1464,9 @@ static int tty_reopen(struct tty_struct *tty)
driver->subtype == PTY_TYPE_MASTER) driver->subtype == PTY_TYPE_MASTER)
return -EIO; return -EIO;
if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
return -EBUSY;
tty->count++; tty->count++;
WARN_ON(!tty->ldisc); WARN_ON(!tty->ldisc);
...@@ -2106,10 +2109,6 @@ static int tty_open(struct inode *inode, struct file *filp) ...@@ -2106,10 +2109,6 @@ static int tty_open(struct inode *inode, struct file *filp)
retval = -ENODEV; retval = -ENODEV;
filp->f_flags = saved_flags; filp->f_flags = saved_flags;
if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
!capable(CAP_SYS_ADMIN))
retval = -EBUSY;
if (retval) { if (retval) {
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__, printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment