[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <505A1C0D.3050906@suse.cz>
Date: Wed, 19 Sep 2012 21:25:01 +0200
From: Jiri Slaby <jslaby@...e.cz>
To: Shachar Shemesh <shachar@...eu.tv>
CC: Greg KH <greg@...ah.com>, LKML <linux-kernel@...r.kernel.org>,
kzak@...hat.com, Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH] tty ldisc: Close/Reopen race prevention should check
the proper flag
On 07/10/2012 06:54 AM, Shachar Shemesh wrote:
> From: Shachar Shemesh <shachar@...eu.tv>
>
> Commit acfa747b introduced the TTY_HUPPING flag to distinguish
> closed TTY from currently closing ones. The test in tty_set_ldisc
> still remained pointing at the old flag. This causes pppd to
> sometimes lapse into uninterruptible sleep when killed and
> restarted.
>
> Signed-off-by: Shachar Shemesh <shachar@...eu.tv>
> ---
> Tested with 3.2.20 kernel.
>
> diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
> index 24b95db..a662a24 100644
> --- a/drivers/tty/tty_ldisc.c
> +++ b/drivers/tty/tty_ldisc.c
> @@ -658,7 +658,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
> goto enable;
> }
>
> - if (test_bit(TTY_HUPPED, &tty->flags)) {
> + if (test_bit(TTY_HUPPING, &tty->flags)) {
> /* We were raced by the hangup method. It will have stomped
> the ldisc data and closed the ldisc down */
> clear_bit(TTY_LDISC_CHANGING, &tty->flags);
Yes, that makes the issue go away, but does not seem to be right too.
There are two issues I see:
* TTY_HUPPED has no use now. That is incorrect. Here should be a test
for both flags, I think.
* The change forces the set_ldisc path to always re-open the ldisc even
if it the terminal is HUPPED.
The bug is not in the kernel. It was in login(1) (util-linux). And it
should be fixed by now. See:
http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=2e7035646eb85851171cc2e989bfa858a4f00cd4
I'm for an in-fact revert of the patch. But temporarily I would still
return EIO. However let's do it even after the reopen is done, so that
we get rid of the user-visible regression. Like in the attached patch.
The regression was introduced by commit c65c9bc3e (tty: rewrite the
ldisc locking). That is !three! years ago. And that is suspicious in itself.
BTW Why pppd thinks it is a good idea to ignore EIO from TIOCSETD ioctl?
regards,
--
js
suse labs
View attachment "0001-TTY-forbid-setting-ldisc-on-HUPPED-tty-step-1.patch" of type "text/x-patch" (4130 bytes)
Powered by blists - more mailing lists