From: Sasha Levin <levinsasha928@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 3/3] tty_lock: Localise the lock
Date: Mon, 07 May 2012 18:30:08 +0200 [thread overview]
Message-ID: <1336408208.3638.15.camel@lappy> (raw)
In-Reply-To: <20120507171126.5beddc27@pyramind.ukuu.org.uk>
On Mon, 2012-05-07 at 17:11 +0100, Alan Cox wrote:
> > I don't believe that this change is correct.
> >
> > Consider the following scenario:
> >
> > tty_release -> tty_lock -> pty_close -> tty_vhangup -> tty_lock
>
> We hang up tty->link not tty.
>
> It's now a per tty lock. So I think we are ok.
Unless we can cause tty->link == tty, in which case:
[ 6522.256890] =============================================
[ 6522.257023] [ INFO: possible recursive locking detected ]
[ 6522.257023] 3.4.0-rc6-next-20120507-sasha-00001-g06a300f #175 Tainted: G W
[ 6522.257023] ---------------------------------------------
[ 6522.257023] trinity/18088 is trying to acquire lock:
[ 6522.257023] (&tty->legacy_mutex){+.+.+.}, at: [<ffffffff82d8a6f2>] tty_lock+0x72/0x80
[ 6522.257023]
[ 6522.257023] but task is already holding lock:
[ 6522.257023] (&tty->legacy_mutex){+.+.+.}, at: [<ffffffff82d8a6f2>] tty_lock+0x72/0x80
[ 6522.257023]
[ 6522.257023] other info that might help us debug this:
[ 6522.257023] Possible unsafe locking scenario:
[ 6522.257023]
[ 6522.257023] CPU0
[ 6522.257023] ----
[ 6522.257023] lock(&tty->legacy_mutex);
[ 6522.257023] lock(&tty->legacy_mutex);
[ 6522.257023]
[ 6522.257023] *** DEADLOCK ***
[ 6522.257023]
[ 6522.257023] May be due to missing lock nesting notation
[ 6522.257023]
[ 6522.257023] 1 lock held by trinity/18088:
[ 6522.257023] #0: (&tty->legacy_mutex){+.+.+.}, at: [<ffffffff82d8a6f2>] tty_lock+0x72/0x80
[ 6522.257023]
[ 6522.257023] stack backtrace:
[ 6522.257023] Pid: 18088, comm: trinity Tainted: G W 3.4.0-rc6-next-20120507-sasha-00001-g06a300f #175
[ 6522.257023] Call Trace:
[ 6522.257023] [<ffffffff8111a509>] print_deadlock_bug+0x119/0x140
[ 6522.257023] [<ffffffff8111c6fe>] validate_chain+0x5ee/0x790
[ 6522.257023] [<ffffffff810f1418>] ? sched_clock_cpu+0x108/0x120
[ 6522.257023] [<ffffffff8111ccc3>] __lock_acquire+0x423/0x4c0
[ 6522.257023] [<ffffffff8111ce3c>] lock_acquire+0xdc/0x120
[ 6522.257023] [<ffffffff82d8a6f2>] ? tty_lock+0x72/0x80
[ 6522.257023] [<ffffffff82d86b60>] __mutex_lock_common+0x60/0x590
[ 6522.257023] [<ffffffff82d8a6f2>] ? tty_lock+0x72/0x80
[ 6522.257023] [<ffffffff82d8a6f2>] ? tty_lock+0x72/0x80
[ 6522.257023] [<ffffffff82d871c0>] mutex_lock_nested+0x40/0x50
[ 6522.257023] [<ffffffff82d8a6f2>] tty_lock+0x72/0x80
[ 6522.257023] [<ffffffff81a2ce34>] __tty_hangup+0x74/0x400
[ 6522.257023] [<ffffffff82d8a154>] ? _raw_spin_unlock_irqrestore+0x94/0xc0
[ 6522.257023] [<ffffffff81a2d1e9>] tty_vhangup+0x9/0x10
[ 6522.257023] [<ffffffff81a36264>] pty_close+0x154/0x160
[ 6522.257023] [<ffffffff81a2dfcd>] tty_release+0xed/0x4d0
[ 6522.257023] [<ffffffff8122d0eb>] ? vfs_lock_file+0x3b/0x40
[ 6522.257023] [<ffffffff8122d18e>] ? locks_remove_posix+0x9e/0xe0
[ 6522.257023] [<ffffffff811e13ea>] __fput+0x11a/0x2c0
[ 6522.257023] [<ffffffff811e15a5>] fput+0x15/0x20
[ 6522.257023] [<ffffffff811dd8b2>] filp_close+0x82/0xa0
[ 6522.257023] [<ffffffff810bb914>] close_files+0x1b4/0x200
[ 6522.257023] [<ffffffff810bb760>] ? sys_waitid+0x200/0x200
[ 6522.257023] [<ffffffff810bb981>] put_files_struct+0x21/0x180
[ 6522.257023] [<ffffffff82d8a090>] ? _raw_spin_unlock+0x30/0x60
[ 6522.257023] [<ffffffff810bbb2d>] exit_files+0x4d/0x60
[ 6522.257023] [<ffffffff810bc7b5>] do_exit+0x285/0x460
[ 6522.257023] [<ffffffff810e74e1>] ? get_parent_ip+0x11/0x50
[ 6522.257023] [<ffffffff810bca31>] do_group_exit+0xa1/0xe0
[ 6522.257023] [<ffffffff810cceb8>] get_signal_to_deliver+0x348/0x3a0
[ 6522.257023] [<ffffffff810e855d>] ? finish_task_switch+0x8d/0x110
[ 6522.257023] [<ffffffff8104daf2>] do_signal+0x42/0x120
[ 6522.257023] [<ffffffff810e74e1>] ? get_parent_ip+0x11/0x50
[ 6522.257023] [<ffffffff810e7c1e>] ? sub_preempt_count+0xae/0xf0
[ 6522.257023] [<ffffffff82d8850f>] ? __schedule+0x79f/0x7d0
[ 6522.257023] [<ffffffff82d8a934>] ? retint_restore_args+0x13/0x13
[ 6522.257023] [<ffffffff82d8a9bf>] ? retint_signal+0x11/0x92
[ 6522.257023] [<ffffffff8104dc24>] do_notify_resume+0x54/0xb0
[ 6522.257023] [<ffffffff82d8a9fb>] retint_signal+0x4d/0x92
next prev parent reply other threads:[~2012-05-07 16:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 21:21 [PATCH 1/3] tty_lock: undo the old tty_lock use on the ctty Alan Cox
2012-05-03 21:22 ` [PATCH 2/3] pty: Lock the devpts bits privately Alan Cox
2012-05-08 18:18 ` H. Peter Anvin
2012-05-08 20:43 ` Alan Cox
2012-05-08 20:41 ` H. Peter Anvin
2012-05-03 21:24 ` [PATCH 3/3] tty_lock: Localise the lock Alan Cox
2012-05-04 20:48 ` Arnd Bergmann
2012-05-04 23:54 ` Greg KH
2012-05-04 23:55 ` Greg KH
2012-05-07 16:03 ` Sasha Levin
2012-05-07 16:11 ` Alan Cox
2012-05-07 16:30 ` Sasha Levin [this message]
2012-05-07 16:42 ` Alan Cox
2012-05-07 17:00 ` Sasha Levin
2012-05-07 21:04 ` Jiri Slaby
2012-05-08 18:12 ` Sasha Levin
2012-05-11 10:40 ` Sasha Levin
2012-05-11 14:52 ` Greg KH
2012-05-11 15:09 ` Sasha Levin
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=1336408208.3638.15.camel@lappy \
--to=levinsasha928@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).