linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
@ 2013-11-07 19:01 Peter Hurley
  2013-11-25 16:36 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Hurley @ 2013-11-07 19:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, linux-serial, Peter Hurley

With multiple, concurrent readers (each waiting to acquire the
atomic_read_lock mutex), a departing reader may mistakenly reset
minimum_to_wake after a new reader has already set a new value.

Protect the minimum_to_wake reset with the atomic_read_lock critical
section.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/n_tty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index ce11cd5..bf9650d 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2253,12 +2253,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
 	n_tty_set_room(tty);
 	up_read(&tty->termios_rwsem);
 
-	mutex_unlock(&ldata->atomic_read_lock);
 	remove_wait_queue(&tty->read_wait, &wait);
-
 	if (!waitqueue_active(&tty->read_wait))
 		ldata->minimum_to_wake = minimum;
 
+	mutex_unlock(&ldata->atomic_read_lock);
+
 	__set_current_state(TASK_RUNNING);
 	if (b - buf)
 		retval = b - buf;
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-25 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07 19:01 [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers Peter Hurley
2013-11-25 16:36 ` Greg Kroah-Hartman
2013-11-25 17:12   ` Peter Hurley
2013-11-25 17:16     ` Greg Kroah-Hartman
2013-11-25 17:24       ` Greg Kroah-Hartman
2013-11-25 17:45         ` 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).