From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>, Ray Lee <ray-lk@madrabbit.org>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kdesu broken
Date: Wed, 29 Jul 2009 09:59:23 +0100 [thread overview]
Message-ID: <20090729095923.4ca5ca3e@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <alpine.LFD.2.01.0907281736260.3161@localhost.localdomain>
> > - The driver ensures that it will not call
> > tty_flip_buffer_push/flush_to_ldisc again for this port until re-opened
>
> That's just bogus.
I didn't invent it, thats how it works and its not an area I've touched.
> If that is wrong as per hangup code, then the bug is in the hangup
> handling, not in the tty_flush_to_ldisc().
I wouldn't argue with that - I merely pointed out they need synchronizing
>
> > - The driver calls tty_hangup
> > - tty_hangup ensures that tty_flip_buffer_push cannot occur again
> > (by killing the workqueue)
> > - resources may well then get freed before close()
>
> They had better not be, since all the data structures touched are inside
> the 'tty_struct' (which we're dereferencing in other ways anyway in that
> whole routine).
You are only looking at pty. That code is used for all the real physical
tty devices too. With real devices the underlying physical device and its
structures can get dumped. When you run the n_tty ldisc you call back out
to the drivers for echo etc.
> So the only thing that the hangup code needs to do is to make that the
> "tty->buf.work.work" function pointer is a nop. And it does, as far as I
> can tell.
What happens if the hangup occurs just after you start running the ldisc
on another CPU ?
> So regardless, by now we have moved from "trivial bug that bites people in
> real life" to "theoretical bug that looks impossible to trigger".
Actually all the hangup races turn up for people. Not often but now and
then. Also because you have vhangup() you can cause them in software by
leaving one app spinning in a loop hanging up and opening stuff while you
try and make it break.
> Well, put this way: the only thing that actually stops the outstanding
> timer (for the delayed work) is the tty_ldisc_halt() call in
> tty_ldisc_hangup(). If that _isn't_ called, then your argument is
> pointless, since the tty_flush_to_ldisc() will be done by a timer later
> (and Ogawa's patch thus clearly introduces nothing new).
>
> And when it _is_ called, it also clears TTY_LDISC, so now tty_ldisc_ref()
> will return NULL, so then flush_to_ldisc() will be a no-op.
IFF the hangup doesn't occur while you are entering flush_to_ldisc()
Consider a real tty for a bit
CPU0 CPU1
n_tty methods
flush_to_ldisc
get ldisc ref
INTERRUPT
tty_hangup
do_tty_hangup
ldisc work tty_ldisc_hangup
RESET_TERMIOS is false
tty->ops->hangup()
[usb]serial_hangup()
[usb]serial_do_down()
close physical
driver
tty->ops->write
[usb]serial_write
WARN()
So as I said before you need to fix flush_to_ldisc and the hangup running
against one another. At the very least I think you need a
tty_ldisc_wait_idle(tty); just before
if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
so that you stall the hangup until n_tty exits the ldisc.
(The other case is calling ld->ops->hangup then calling ld->ops->write
which no ldisc seems to care about)
next prev parent reply other threads:[~2009-07-29 8:59 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 23:45 [Regression] " Rafael J. Wysocki
2009-07-24 0:21 ` Ray Lee
2009-07-24 15:21 ` Rafael J. Wysocki
2009-07-24 15:40 ` Alan Cox
2009-07-24 16:34 ` Linus Torvalds
2009-07-25 6:04 ` OGAWA Hirofumi
2009-07-25 13:31 ` Alan Cox
2009-07-25 14:05 ` Alan Cox
2009-07-25 14:55 ` OGAWA Hirofumi
2009-07-25 15:32 ` Alan Cox
2009-07-26 11:51 ` OGAWA Hirofumi
2009-07-27 10:57 ` Alan Cox
2009-07-27 12:07 ` OGAWA Hirofumi
2009-07-27 12:46 ` OGAWA Hirofumi
2009-07-27 13:23 ` [PATCH] " Alan Cox
2009-07-27 13:50 ` OGAWA Hirofumi
2009-07-27 13:58 ` Alan Cox
2009-07-27 15:04 ` OGAWA Hirofumi
2009-07-27 16:14 ` Aneesh Kumar K.V
2009-07-27 16:42 ` Alan Cox
2009-07-27 17:12 ` Aneesh Kumar K.V
2009-07-27 19:28 ` OGAWA Hirofumi
2009-07-27 19:40 ` Linus Torvalds
2009-07-27 20:38 ` OGAWA Hirofumi
2009-07-27 20:45 ` Linus Torvalds
2009-07-27 21:42 ` Alan Cox
2009-07-27 22:04 ` Linus Torvalds
2009-07-27 22:41 ` Alan Cox
2009-07-27 20:52 ` Alan Cox
2009-07-27 21:22 ` Linus Torvalds
2009-07-27 21:54 ` Alan Cox
2009-07-27 21:20 ` Alan Cox
2009-07-28 5:33 ` OGAWA Hirofumi
2009-07-28 10:22 ` Alan Cox
2009-07-28 10:42 ` OGAWA Hirofumi
2009-07-28 15:49 ` Linus Torvalds
2009-07-28 16:42 ` Alan Cox
2009-07-28 16:49 ` Linus Torvalds
2009-07-28 16:52 ` Linus Torvalds
2009-07-28 17:09 ` Alan Cox
2009-07-28 18:45 ` Linus Torvalds
2009-07-28 17:06 ` Alan Cox
2009-07-28 18:44 ` Linus Torvalds
2009-07-28 18:56 ` Alan Cox
2009-07-28 19:08 ` Linus Torvalds
2009-07-28 19:15 ` Alan Cox
2009-07-28 19:56 ` Greg KH
2009-07-28 20:47 ` Theodore Tso
2009-07-28 21:01 ` Greg KH
2009-07-28 22:02 ` Theodore Tso
2009-07-28 23:49 ` Alan Cox
2009-07-29 0:12 ` Greg KH
2009-07-30 23:16 ` Alan Cox
2009-07-30 23:24 ` Greg KH
2009-07-31 13:49 ` Alan Cox
2009-07-31 14:17 ` Greg KH
2009-07-28 23:46 ` Alan Cox
2009-07-29 0:10 ` Linus Torvalds
2009-07-29 0:26 ` Linus Torvalds
2009-07-29 7:01 ` Aneesh Kumar K.V
2009-07-29 0:34 ` Alan Cox
2009-07-29 1:04 ` Linus Torvalds
2009-07-29 1:23 ` Linus Torvalds
2009-07-29 11:17 ` Alan Cox
2009-07-29 8:59 ` Alan Cox [this message]
2009-07-29 15:48 ` Linus Torvalds
2009-07-29 15:55 ` Alan Cox
2009-07-29 16:05 ` Linus Torvalds
2009-07-29 16:39 ` Alan Cox
2009-07-29 19:07 ` Linus Torvalds
2009-07-29 2:50 ` Gene Heskett
2009-07-29 4:49 ` Linus Torvalds
2009-07-29 4:54 ` Linus Torvalds
2009-07-29 5:04 ` Gene Heskett
2009-07-29 5:00 ` Gene Heskett
2009-07-29 5:08 ` Andrew Morton
2009-07-29 7:46 ` Gene Heskett
2009-07-29 11:07 ` Alan Cox
2009-07-29 17:40 ` Gene Heskett
2009-07-29 18:28 ` Frans Pop
2009-07-29 18:43 ` Gene Heskett
2009-07-29 19:08 ` Frans Pop
2009-07-29 19:19 ` Gene Heskett
2009-07-30 12:43 ` Valdis.Kletnieks
2009-07-30 15:35 ` Gene Heskett
2009-07-30 18:39 ` Valdis.Kletnieks
2009-07-31 2:01 ` H. Peter Anvin
2009-07-28 15:48 ` Linus Torvalds
2009-07-28 16:16 ` OGAWA Hirofumi
2009-07-27 18:28 ` Andreas Schwab
2009-07-27 13:58 ` Aneesh Kumar K.V
2009-07-25 20:12 ` [Regression] " Rafael J. Wysocki
2009-07-26 17:41 ` Aneesh Kumar K.V
2009-07-29 2:20 ` Gene Heskett
2009-07-25 11:48 ` Alan Cox
2009-07-25 14:02 ` Frans Pop
2009-07-25 20:16 ` Rafael J. Wysocki
2009-07-25 21:03 ` Alan Cox
2009-07-26 15:51 ` Sergey Senozhatsky
2009-07-24 18:25 ` Aneesh Kumar K.V
2009-07-25 12:07 ` Alan Cox
2009-07-25 16:18 ` Aneesh Kumar K.V
2009-07-25 17:06 ` Aneesh Kumar K.V
2009-07-29 19:09 ` [Regression] kdesu broken, now usb fixed in current git pull Gene Heskett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090729095923.4ca5ca3e@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=ray-lk@madrabbit.org \
--cc=rjw@sisk.pl \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®