lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1247843274-7462-1-git-send-email-jeff_harris@kentrox.com>
Date:	Fri, 17 Jul 2009 11:07:54 -0400
From:	Jeff Harris <jeff_harris@...trox.com>
To:	alan@...ux.intel.com, vapier@...too.org, adobriyan@...il.com
Cc:	linux-kernel@...r.kernel.org, Jeff Harris <jeff_harris@...trox.com>
Subject: [PATCH] tty: Fix tcdrain hang due to tty chars_in_buffer errors

If a tty driver's chars_in_buffer callback reports an error, the wait loop in
tty_wait_until_sent may never exit until its timeout.  A tty device
disconnection will hangup the tty causing the tty_wait_until_sent loop to
wake-up, but if the subsequent call to chars_in_buffer reports an error
instead of zero, the loop will go back to sleep instead of exiting.

A process calling tcdrain will block indefinitely if it calls tcdrain when the
device is disconnected.

Signed-off-by: Jeff Harris <jeff_harris@...trox.com>
---
 drivers/char/tty_ioctl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index ad6ba4e..306d52e 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -156,7 +156,7 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
 	if (!timeout)
 		timeout = MAX_SCHEDULE_TIMEOUT;
 	if (wait_event_interruptible_timeout(tty->write_wait,
-			!tty_chars_in_buffer(tty), timeout) >= 0) {
+			tty_chars_in_buffer(tty) <= 0, timeout) >= 0) {
 		if (tty->ops->wait_until_sent)
 			tty->ops->wait_until_sent(tty, timeout);
 	}
@@ -332,7 +332,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 	int iclose = ibaud/50, oclose = obaud/50;
 	int ibinput = 0;
 
-	if (obaud == 0)			/* CD dropped 		  */
+	if (obaud == 0)			/* CD dropped		  */
 		ibaud = 0;		/* Clear ibaud to be sure */
 
 	termios->c_ispeed = ibaud;
-- 
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ