From: Prarit Bhargava <prarit@redhat.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org, arjan@infradead.org
Subject: Re: [PATCH]: disassociate tty locking fixups
Date: Sat, 14 Oct 2006 11:06:55 -0400 [thread overview]
Message-ID: <4530FD0F.4050305@redhat.com> (raw)
In-Reply-To: <1160830509.5732.26.camel@localhost.localdomain>
Alan Cox wrote:
>Ugly but I don't think the patches are sufficient. Firstly you need to
>hold the task lock if you are poking around some other users ->signal,
>or that may itself change. (disassociate_ctty seems to have this wrong)
Ah -- okay.
So the locking order is (for example):
mutex_lock(&tty_mutex);
read_lock(&tasklist_lock);
task_lock(current);
Correct?
>Secondly you appear to have lock ordering issues (you lock tty_mutex in
>both orders relative to the task list lock) (you take tty_mutex first,
>then the task lock which is correct, but then you drop and retake the
>tty_mutex while holding the task lock, which may deadlock)
Fixed.
>Can you also explain why the ctty change proposed is neccessary ?
disassociate_ctty can call tty_vhangup which calls do tty_hangup directly.
do_tty_hangup can then set p->signal->tty = NULL, and after returning to
disassociate_ctty, the value of tty will now contain a bad pointer. (I can
reproduce this behaviour by running the gdb testsuite with slab debug on)
>NAK the actual code, provisionally agree with the basic diagnosis of
>insufficient locking.
Arjan wrote:
>in addition, are you sure you don't need to revalidate anything after
>retaking the lock?
The only place I need to revalidate data (AFAICT) is in
disassociate_ctty where
I re-check to see if current->signal->tty is still valid. Admittedly, I am
looking at a very specific failure path though.
I'll rework the patch and post later.
P.
next prev parent reply other threads:[~2006-10-14 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-14 11:22 [PATCH]: disassociate tty locking fixups Prarit Bhargava
2006-10-14 12:20 ` Arjan van de Ven
2006-10-14 12:55 ` Alan Cox
2006-10-14 15:06 ` Prarit Bhargava [this message]
2006-10-14 16:29 ` Alan Cox
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=4530FD0F.4050305@redhat.com \
--to=prarit@redhat.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjan@infradead.org \
--cc=linux-kernel@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