From: Frederic Weisbecker <fweisbec@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: v2.6.31-rc6: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
Date: Tue, 25 Aug 2009 16:24:27 +0200 [thread overview]
Message-ID: <20090825142424.GF6114@nowhere> (raw)
In-Reply-To: <alpine.LFD.2.01.0908242043280.3218@localhost.localdomain>
On Mon, Aug 24, 2009 at 09:10:38PM -0700, Linus Torvalds wrote:
>
>
> On Tue, 25 Aug 2009, Frederic Weisbecker wrote:
> >
> > Now that also makes the TTY_LDISC flag clearing unprotected by
> > tty->ldisc_mutex.
>
> Yes.
>
> > tty_set_ldisc() can play concurrently with these flags right?
>
> .. but that shouldn't matter.
>
> The actual bit-setting is "atomic" already - and any other atomicity is
> pretty much unattainable, because all the routines in question drop the
> lock they need to hold in order to make it really be reliably atomic.
>
> > tty_ldisc_halt() could remain protected by the mutex, so that the
> > flag is safely toggled. Once it is cleared, we can ensure no more
> > user can ref it and the lock can be relaxed while the pending
> > work is flushed.
>
> That would make no difference at all. tty_set_ldisc() won't care about the
> flag (in fact, it will do its own tty_ldisc_halt()), and will be happy to
> replace the ldisc we just flushed with a new one regardless of whether it
> was halted before or not. And it will do tty_ldisc_enable() regardless of
> whether it was enabled or not before.
>
> In fact, because tty_set_ldisc() itself had to release the ldisc_mutex
> (for the same reason), you have this issue regardless of whether you hold
> the lock in tty_hangup() or not: the two will always be able to get "mixed
> up", because they - by design - have to release that silly lock.
Hmm, that's why I had a headache while trying to imagine every races in this
place...
> That's why I said I was unhappy about the tty layer locking - it really
> isn't very sane. Things like tty_set_ldisc() will drop the lock in the
> middle because of that crazy workqueue deadlock - exactly for the same
> reasons that tty_ldisc_hangup() will need to do that "wait for things to
> flush" without the lock held.
>
> So I could have taken the ldisc_mutex, and then just dropped it
> temporarily while waiting for any workqueue entries, but as far as I can
> tell, it doesn't actually solve anything.
Yeah, indeed.
> I considered using the TTY_LDISC_CHANGING bit(*) there to protect against
> tty_set_ldisc(), and it may even be the right solution. But there's no way
> I'll do that kind of changes this late in the -rc series.
>
> We also have the "TTY_HUPPED" bit that disables tty_set_ldisc(), but that
> is set too late by do_tty_hangup(), and so doesn't fix the problem either.
> Again, moving it earlier may be a solution, but again, it's not
> appropriate for this late in the -rc.
Ok.
> Finally, the solution that is most likely the _real_ solution would be to
> just fix the locking. The whole "ldisc_mutex" seems dubious. It's not even
> a real lock - exactly because it's dropped - and we already really use
> that TTY_LDISC_CHANGING bit to do the _real_ locking. I don't think it
> needs to be a mutex at all. The locking is just very dubious.
>
> And that, least of all, is anything I'm willing to really do in -rc.
>
> Anyway, I'll happily be shown wrong. I think the (second) patch I sent out
> is an acceptable hack in the presense of the current locking, but as I
> said, I'm not exactly happy about it, because I do think the locking is
> broken.
>
> Linus
>
> (*) We already have that hacky open-coded "lock" using TTY_LDISC_CHANGING,
> which protects two different tty_set_ldisc()'s from screwing up each other
> when they drop the semaphore. It could be just separated out into a
> function of its own, and then the hangup code would/could/should be taught
> to use that logic.
Ok, thanks.
next prev parent reply other threads:[~2009-08-25 14:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 5:46 v2.6.31-rc6: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 Eric W. Biederman
2009-08-20 6:07 ` Eric W. Biederman
[not found] ` <7b6bb4a50908200010h1c60d007p4fa017fd97c87c19@mail.gmail.com>
2009-08-20 7:33 ` Eric W. Biederman
2009-08-20 9:23 ` Xiaotian Feng
2009-08-21 2:09 ` Zhang, Yanmin
2009-08-21 18:23 ` Eric W. Biederman
2009-08-20 7:54 ` Dave Young
2009-08-20 8:00 ` Eric W. Biederman
2009-08-20 8:19 ` Dave Young
2009-08-24 22:34 ` Linus Torvalds
2009-08-24 23:51 ` Linus Torvalds
2009-08-25 0:09 ` Linus Torvalds
2009-08-25 1:41 ` Eric W. Biederman
2009-08-25 2:48 ` Dave Young
2009-08-25 3:08 ` Xiaotian Feng
2009-08-25 6:16 ` Zhang, Yanmin
2009-08-25 3:39 ` Frederic Weisbecker
2009-08-25 4:10 ` Linus Torvalds
2009-08-25 4:30 ` Linus Torvalds
2009-08-25 15:05 ` Frederic Weisbecker
2009-08-25 14:24 ` Frederic Weisbecker [this message]
2009-08-27 9:15 ` Zhang, Yanmin
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=20090825142424.GF6114@nowhere \
--to=fweisbec@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ebiederm@xmission.com \
--cc=gregkh@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.