Re: ldisc writes during tty release_dev() causing problems.

From: Ryan Arnold
Date: Fri Sep 24 2004 - 11:09:59 EST


On Fri, 2004-09-24 at 07:40, Alan Cox wrote:

> > If tty release_dev() is called when write_chan() is blocked awaiting I/O
> > with the driver and tty->count == 1 the final call to driver->close()
> > will clean up the driver without the ldisc knowing that the driver has
> > closed the device.
>
> That should not be possible. The terminal cannot be both blocking in
> write_chan and executing a close path for the final opener.

Thanks for the reply Alan,

I think I see what you mean. The ldisc write_chan code is actually
invoked from the terminal process and if this is I/O blocked then the
terminal process cannot invoke release_dev(). So why did I experience
calls to hvc_write() after the final open instance was closed with
release_dev()?

> > Additionally, there doesn't seem to be anything to prevent hangup being
> > called on a tty during the final close operation (this actually happened
> > in hvc_console).
>
> I had assumed would have to come from the serial side because if the
> last owner is executing close() they can't be executing vhangup on the
> same but given a rapid close/re-open/vhangup on a new fd it might be
> a dangerous assumption. Added to the TODO pile

In hvc_console we don't have a serial side, but I do have the device
side which will invoke a tty_hangup() if an hvc adapter was hotplug
removed. This doesn't happen for the actual console adapter (hvc0)
because it isn't allowed in firmware.

So my strategy for now is going to be to get rid of the tty->driver_data
= NULL in hvc_close() and simply check the open count in hvc_hangup()
and hvc_write() to verify that these operations are actually relevant.

thanks again Alan,

Ryan S. Arnold
IBM Linux Technology Center

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