* [PATCH -next 0/3] more tty closing fixes
@ 2014-11-05 17:40 Peter Hurley
2014-11-05 17:40 ` [PATCH -next 1/3] tty: Move tty hung up check from port->lock critical section Peter Hurley
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peter Hurley @ 2014-11-05 17:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, One Thousand Gnomes, linux-kernel, linux-serial,
Peter Hurley
Hi Greg,
These 3 patches are stragglers from the old tty closing series.
I'm still working on eliminating ASYNC_CLOSING and the improvements to
opening in O_NONBLOCK mode.
Regards,
Peter Hurley (3):
tty: Move tty hung up check from port->lock critical section
tty: Convert tty->closing to int
tty: Flush tty buffers after hardware shutdown
drivers/tty/tty_port.c | 7 +++----
include/linux/tty.h | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
--
2.1.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH -next 1/3] tty: Move tty hung up check from port->lock critical section
2014-11-05 17:40 [PATCH -next 0/3] more tty closing fixes Peter Hurley
@ 2014-11-05 17:40 ` Peter Hurley
2014-11-05 17:40 ` [PATCH -next 2/3] tty: Convert tty->closing to int Peter Hurley
2014-11-05 17:40 ` [PATCH -next 3/3] tty: Flush tty buffers after hardware shutdown Peter Hurley
2 siblings, 0 replies; 4+ messages in thread
From: Peter Hurley @ 2014-11-05 17:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, One Thousand Gnomes, linux-kernel, linux-serial,
Peter Hurley
The port->lock does not protect the filp->f_op field; move
the tty_hung_up_p() test outside the port->lock critical section
in tty_port_close_start().
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
drivers/tty/tty_port.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 1b93357..3b641d1 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -473,12 +473,10 @@ int tty_port_close_start(struct tty_port *port,
{
unsigned long flags;
- spin_lock_irqsave(&port->lock, flags);
- if (tty_hung_up_p(filp)) {
- spin_unlock_irqrestore(&port->lock, flags);
+ if (tty_hung_up_p(filp))
return 0;
- }
+ spin_lock_irqsave(&port->lock, flags);
if (tty->count == 1 && port->count != 1) {
printk(KERN_WARNING
"tty_port_close_start: tty->count = 1 port count = %d.\n",
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH -next 2/3] tty: Convert tty->closing to int
2014-11-05 17:40 [PATCH -next 0/3] more tty closing fixes Peter Hurley
2014-11-05 17:40 ` [PATCH -next 1/3] tty: Move tty hung up check from port->lock critical section Peter Hurley
@ 2014-11-05 17:40 ` Peter Hurley
2014-11-05 17:40 ` [PATCH -next 3/3] tty: Flush tty buffers after hardware shutdown Peter Hurley
2 siblings, 0 replies; 4+ messages in thread
From: Peter Hurley @ 2014-11-05 17:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, One Thousand Gnomes, linux-kernel, linux-serial,
Peter Hurley
tty->closing is a bitfield member; prevent corruption from non-atomic
update by assigning a unique memory location.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
include/linux/tty.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c52a689..7d66ae5 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -284,7 +284,7 @@ struct tty_struct {
#define N_TTY_BUF_SIZE 4096
- unsigned char closing:1;
+ int closing;
unsigned char *write_buf;
int write_cnt;
/* If the tty has a pending do_SAK, queue it here - akpm */
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH -next 3/3] tty: Flush tty buffers after hardware shutdown
2014-11-05 17:40 [PATCH -next 0/3] more tty closing fixes Peter Hurley
2014-11-05 17:40 ` [PATCH -next 1/3] tty: Move tty hung up check from port->lock critical section Peter Hurley
2014-11-05 17:40 ` [PATCH -next 2/3] tty: Convert tty->closing to int Peter Hurley
@ 2014-11-05 17:40 ` Peter Hurley
2 siblings, 0 replies; 4+ messages in thread
From: Peter Hurley @ 2014-11-05 17:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, One Thousand Gnomes, linux-kernel, linux-serial,
Peter Hurley
The line discipline buffer and the tty buffers must be flushed again
after hardware shutdown; otherwise, a brief window exists between the
ldisc flush in tty_port_close_start() and the subsequent
tty_port_shutdown(), during which more data could be received into the
tty buffers. A racing open might then be able to receive data from the
previous session.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
drivers/tty/tty_port.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 3b641d1..4d9abaa 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -520,6 +520,7 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)
{
unsigned long flags;
+ tty_ldisc_flush(tty);
tty->closing = 0;
spin_lock_irqsave(&port->lock, flags);
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-05 17:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05 17:40 [PATCH -next 0/3] more tty closing fixes Peter Hurley
2014-11-05 17:40 ` [PATCH -next 1/3] tty: Move tty hung up check from port->lock critical section Peter Hurley
2014-11-05 17:40 ` [PATCH -next 2/3] tty: Convert tty->closing to int Peter Hurley
2014-11-05 17:40 ` [PATCH -next 3/3] tty: Flush tty buffers after hardware shutdown Peter Hurley
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).