Subject: New set of serial patches --- big bugfix!!
From: [email-masked] (Theodore Ts'o)
Date: 20 Dec 1993 01:57:02 +0200
Newsgroups: comp.os.linux.announce

I have a yet another set of serial patches available on tsx-11.mit.edu,
in /pub/linux/ALPHA/serial, dated December 16, 1993.   If you took my
December 14, 1993 serial patches, then you must either get a fresh set
of serial patches from tsx-11, in the ALPHA/serial directory, or you
need to apply the following patch to your December 14th patched kernel:

--- serial.c.old	Tue Dec 14 11:43:25 1993
+++ serial.c	Thu Dec 16 01:57:36 1993
@@ -1142,7 +1142,6 @@
 		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
 			       (new_serial.flags & ASYNC_USR_MASK));
 		info->custom_divisor = new_serial.custom_divisor;
-		new_serial.port = 0;	/* Prevent initialization below */
 		goto check_and_exit;
 	}
 
@@ -1198,15 +1197,16 @@
 		 * We need to shutdown the serial port at the old
 		 * port/irq combination.
 		 */
-		shutdown(info, 0);
+		shutdown(info, change_irq);
 		info->irq = new_serial.irq;
 		info->port = new_serial.port;
 		info->hub6 = new_serial.hub6;
 	}
 	
 check_and_exit:
-	if (info->port && info->type &&
-	    (info->flags & ASYNC_INITIALIZED)) {
+	if (!info->port || !info->type)
+		return 0;
+	if (info->flags & ASYNC_INITIALIZED) {
 		if (((old_info.flags & ASYNC_SPD_MASK) !=
 		     (info->flags & ASYNC_SPD_MASK)) ||
 		    (old_info.custom_divisor != info->custom_divisor))

This fixes a bug in set_serial_info() which was preventing people from
accessing /dev/ttys0 after redefining /dev/ttys2 to use a different
interrupt, because irq 4 (which is used by default by both ttys0 and
ttys2) didn't get freed after /dev/ttys2 was configured.

					- Ted

P.S.  The new README file follows below:

This is the third set of patches to the serial driver in 0.99pl14,
dated December 16, 1993.  (Actually, these patches were made to
0.99pl14d, but they should patch cleanly into 0.99pl14 and other pl14
ALPHA releases.)

This patch contains one major bugfix over the previous set of patches
dated December 14, 1993:

	* Fixed a bug in set_serial_info where the old irq was not
		being freed properly.  This was causing people to lose
		when they redefined COM3 to use a different IRQ using
		/etc/setserial, and ended up causing the COM1 port to
		become permanently busy.

It also contains the following improvements over the serial driver in
0.99pl14:

	* Fixed a nasty race condition in rs_close() and tty_hangup()
		which caused kernel hangs or outright panics in
		rs_interrupt().  This would tend to happen only on
		machines which serial ports serving as both as callout
		and dialup devices.

	* Line disciplines are now reset when a terminal is completely
		freed.  This allows a Linux box which is working as a
		SLIP or PPP server to do the right thing when user
		hangs up.

	* Fix security hole in TIOCSTTY handling; if a root process
		forcibly takes over a tty as its controlling tty while
		another session group still has that tty, the tty is
		disassociated from the old session group before it is
		given to the calling process as the controlling tty.

		(NOTE: getty's really shouldn't be using TIOCSTTY
		anyway, since processes which have the tty open can
		still read/write to it.  getty/login should be using
		vhangup instead.)

	* Set FIFO trigger level to 1 if baud rate is under 2400.
		This will improve response time on 16550A's when they
		are operating at slow speeds; specifically when you're 
		using them with a mouse. 

	* Overrun conditions are now passed up to tty_io.c, and an
		appropriate warning message is printed.  (Previously,
		tty_io.c would handle it as a randomly as either a
		frame error, a parity error, or a break.)

	* Use a separate flag for hardware flow control, so that
		the right thing happens when both XON/XOFF and RTS/CTS
		flow control are enabled.

	* Allow the callout devices to be a controlling tty.

	* Hangup handling fixed; some race conditions removed.  The
		device specific close now happens at the instant when
		the hangup is signaled, instead of waiting until the
		the process closed the file descriptor.  This should
		fix the problems with background processes that still
		have the tty opened when the modem hangs up.  Linux
		will now deal correctly with this case.

Please try these changes out, especially if you support dialup via
modems.  There are a bunch of tricky race conditions with the hangup
code, which I *think* that I've resolved.  I want to make sure that
they work, though, before submitting them to Linux for inclusion in
the mainline kernel.  Please try them out and let me know how they
work on your system.  

					Ted Ts'o
					[email-masked]
					12/14/93

--
Mail submissions for comp.os.linux.announce to: [email-masked]
PLEASE remember Keywords: and a short description of the software.