From: Alexander Gordeev <lasaine@lvk.cs.msu.su>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org,
"Nikita V\. Youshchenko" <yoush@cs.msu.su>,
linuxpps@ml.enneenne.com,
Rodolfo Giometti <giometti@enneenne.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Arnd Bergmann <arnd@arndb.de>, Al Viro <viro@zeniv.linux.org.uk>,
Nick Piggin <npiggin@kernel.dk>,
"Alan \"I must be out of my tree\" Cox" <alan@linux.intel.com>,
Jason Wessel <jason.wessel@windriver.com>,
Philippe Langlais <philippe.langlais@stericsson.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCHv5 05/17] tty: don't allow ldisc dcd_change() after ldisc halt
Date: Thu, 25 Nov 2010 01:38:12 +0300 [thread overview]
Message-ID: <20101125013812.0dc828ad@tornado.gnet> (raw)
In-Reply-To: <20101124164329.75368d71@lxorguk.ukuu.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]
В Wed, 24 Nov 2010 16:43:29 +0000
Alan Cox <alan@lxorguk.ukuu.org.uk> пишет:
> On Wed, 24 Nov 2010 19:15:43 +0300
> Alexander Gordeev <lasaine@lvk.cs.msu.su> wrote:
>
> > There was a possibility that uart_handle_dcd_change() could obtain a
> > reference to ldisc while running in parallel with tty_set_ldisc() on
> > different CPU but call dcd_change() operation after
> > tty_ldisc_close() which is incorrect.
>
> How can this occur ?
>
>
> > + spin_lock_irqsave(&tty->dcd_change_lock, flags);
> > +
> > + ld = tty_ldisc_ref(tty);
>
> What is the expecting lock ordering rule here ?
>
>
>
> I don't see why this patch is needed. You've got an ldisc ref from
> tty_ldisc_ref, until you drop that ldisc ref you are fine. If for some
> reason that is not the case then there is a bug in the ldisc code.
Yes, indeed, it's a bug. Please consider the following example:
CPU1 CPU2
=========================================================
uart_handle_dcd_change() { tty_set_ldisc() {
ld = tty_ldisc_ref(...) ...
... tty_ldisc_halt(...)
... ...
... tty_ldisc_close(...)
if (ld && ld->ops->dcd_change) ...
ld->ops->dcd_change(...); ...
... tty_ldisc_open(...)
} }
I think that semantically ldisc ops should never be called before open
or after close. This situation is possible because tty_ldisc_halt() only
ensures that no more references are taken. This is ok for everything
except dcd_change() because it cleans up workqueue and doesn't accept
any more data. dcd_change() is a different story because it doesn't use
workqueues.
I think tty code is exactly the right place to fix this bug; this is
what my patch is for.
--
Alexander
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2010-11-24 22:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 16:15 [PATCHv5 00/17] pps: several fixes and improvements Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 01/17] pps: trivial fixes Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 02/17] pps: declare variables where they are used in switch Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 03/17] pps: fix race in PPS_FETCH handler Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 04/17] pps: unify timestamp gathering Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 05/17] tty: don't allow ldisc dcd_change() after ldisc halt Alexander Gordeev
2010-11-24 16:43 ` Alan Cox
2010-11-24 22:38 ` Alexander Gordeev [this message]
2010-11-24 22:36 ` Alan Cox
2010-11-25 13:30 ` Alexander Gordeev
2010-11-25 14:03 ` Alan Cox
2010-12-15 16:13 ` Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 06/17] pps: access pps device by direct pointer Alexander Gordeev
2010-12-16 15:52 ` Rodolfo Giometti
2010-12-16 21:58 ` Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 07/17] pps: convert printk/pr_* to dev_* Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 08/17] pps: move idr stuff to pps.c Alexander Gordeev
2010-12-16 15:53 ` Rodolfo Giometti
2010-11-24 16:15 ` [PATCHv5 09/17] pps: do not disable interrupts for idr operations Alexander Gordeev
2010-12-16 15:53 ` Rodolfo Giometti
2010-11-24 16:15 ` [PATCHv5 10/17] pps: use BUG_ON for kernel API safety checks Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 11/17] pps: simplify conditions a bit Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 12/17] pps: timestamp is always passed to dcd_change() Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 13/17] ntp: add hardpps implementation Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 14/17] pps: capture MONOTONIC_RAW timestamps as well Alexander Gordeev
2010-11-24 16:49 ` Thomas Gleixner
2010-11-25 9:55 ` Alexander Gordeev
2010-11-24 16:15 ` [PATCHv5 15/17] pps: add kernel consumer support Alexander Gordeev
2010-12-16 15:55 ` Rodolfo Giometti
2010-11-24 16:15 ` [PATCHv5 16/17] pps: add parallel port PPS client Alexander Gordeev
2010-12-16 15:58 ` Rodolfo Giometti
2010-11-24 16:15 ` [PATCHv5 17/17] pps: add parallel port PPS signal generator Alexander Gordeev
2010-12-16 16:02 ` Rodolfo Giometti
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=20101125013812.0dc828ad@tornado.gnet \
--to=lasaine@lvk.cs.msu.su \
--cc=akpm@linux-foundation.org \
--cc=alan@linux.intel.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arnd@arndb.de \
--cc=giometti@enneenne.com \
--cc=gregkh@suse.de \
--cc=jason.wessel@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxpps@ml.enneenne.com \
--cc=npiggin@kernel.dk \
--cc=philippe.langlais@stericsson.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yoush@cs.msu.su \
/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