* [PATCH] tty: Prevent hw state corruption in exclusive mode reopen
@ 2014-12-30 12:34 Peter Hurley
2014-12-30 15:15 ` Peter Hurley
2014-12-30 15:39 ` [PATCH v2] " Peter Hurley
0 siblings, 2 replies; 4+ messages in thread
From: Peter Hurley @ 2014-12-30 12:34 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-kernel, linux-serial, Shreyas Bethur,
Peter Hurley
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>
---
drivers/tty/tty_io.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 4f35b43..8629087 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2091,6 +2091,11 @@ retry_open:
goto err_file;
}
+ if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) {
+ retval = -EBUSY;
+ goto err_file;
+ }
+
tty_add_file(tty, filp);
check_tty_count(tty, __func__);
@@ -2106,10 +2111,6 @@ retry_open:
retval = -ENODEV;
filp->f_flags = saved_flags;
- if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
- !capable(CAP_SYS_ADMIN))
- retval = -EBUSY;
-
if (retval) {
#ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: Prevent hw state corruption in exclusive mode reopen
2014-12-30 12:34 [PATCH] tty: Prevent hw state corruption in exclusive mode reopen Peter Hurley
@ 2014-12-30 15:15 ` Peter Hurley
2014-12-30 15:39 ` [PATCH v2] " Peter Hurley
1 sibling, 0 replies; 4+ messages in thread
From: Peter Hurley @ 2014-12-30 15:15 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, linux-serial, Shreyas Bethur
On 12/30/2014 07:34 AM, Peter Hurley wrote:
> 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.
Greg,
Please disregard. I'll redo a v2 that isn't broken.
Regards,
Peter Hurley
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tty: Prevent hw state corruption in exclusive mode reopen
2014-12-30 12:34 [PATCH] tty: Prevent hw state corruption in exclusive mode reopen Peter Hurley
2014-12-30 15:15 ` Peter Hurley
@ 2014-12-30 15:39 ` Peter Hurley
2015-01-07 22:55 ` Shreyas Bethur
1 sibling, 1 reply; 4+ messages in thread
From: Peter Hurley @ 2014-12-30 15:39 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-kernel, linux-serial, Shreyas Bethur,
Peter Hurley
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>
---
drivers/tty/tty_io.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 4f35b43..51f066a 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)
driver->subtype == PTY_TYPE_MASTER)
return -EIO;
+ if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
+ return -EBUSY;
+
tty->count++;
WARN_ON(!tty->ldisc);
@@ -2106,10 +2109,6 @@ retry_open:
retval = -ENODEV;
filp->f_flags = saved_flags;
- if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
- !capable(CAP_SYS_ADMIN))
- retval = -EBUSY;
-
if (retval) {
#ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tty: Prevent hw state corruption in exclusive mode reopen
2014-12-30 15:39 ` [PATCH v2] " Peter Hurley
@ 2015-01-07 22:55 ` Shreyas Bethur
0 siblings, 0 replies; 4+ messages in thread
From: Shreyas Bethur @ 2015-01-07 22:55 UTC (permalink / raw)
To: Peter Hurley; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial
Peter Hurley <peter@hurleysoftware.com> wrote on 12/30/2014 09:39:25 AM:
> From: Peter Hurley <peter@hurleysoftware.com>
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
> Cc: Jiri Slaby <jslaby@suse.cz>, linux-kernel@vger.kernel.org,
> linux-serial@vger.kernel.org, Shreyas Bethur
> <shreyas.bethur@ni.com>, Peter Hurley <peter@hurleysoftware.com>
> Date: 12/30/2014 09:39 AM
> Subject: [PATCH v2] 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>
> ---
> drivers/tty/tty_io.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 4f35b43..51f066a 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)
> driver->subtype == PTY_TYPE_MASTER)
> return -EIO;
>
> + if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
> + return -EBUSY;
> +
> tty->count++;
>
> WARN_ON(!tty->ldisc);
> @@ -2106,10 +2109,6 @@ retry_open:
> retval = -ENODEV;
> filp->f_flags = saved_flags;
>
> - if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
> - !capable(CAP_SYS_ADMIN))
> - retval = -EBUSY;
> -
> if (retval) {
> #ifdef TTY_DEBUG_HANGUP
> printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,
> --
> 2.2.1
>
Acked-by: Shreyas Bethur <shreyas.bethur@ni.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-07 22:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-30 12:34 [PATCH] tty: Prevent hw state corruption in exclusive mode reopen Peter Hurley
2014-12-30 15:15 ` Peter Hurley
2014-12-30 15:39 ` [PATCH v2] " Peter Hurley
2015-01-07 22:55 ` Shreyas Bethur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).