From: Robin Holt <holt@sgi.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] AB-BA deadlock between uidhash_lock and tasklist_lock.
Date: Wed, 22 Dec 2004 16:08:00 -0600 [thread overview]
Message-ID: <20041222220800.GB6213@lnx-holt.americas.sgi.com> (raw)
We have uncovered a very difficult to trip AB-BA deadlock between the
uidhash_lock and tasklist_lock.
reparent_to_init() does write_lock_irq(&tasklist_lock) then calls
switch_uid() which calls free_uid() which grabs the uidhash_lock.
Independent of that, we have seen a different cpu call free_uid as a
result of sys_wait4 and, immediately after acquiring the uidhash_lock,
receive a timer interrupt which eventually leads to an attempt to grab
the tasklist_lock.
Signed-off-by: Robin Holt <holt@sgi.com>
Index: linux/kernel/user.c
===================================================================
--- linux.orig/kernel/user.c 2004-12-22 13:10:49.000000000 -0600
+++ linux/kernel/user.c 2004-12-22 16:04:40.244569776 -0600
@@ -90,6 +90,9 @@
void free_uid(struct user_struct *up)
{
+ unsigned long flags;
+
+ local_irq_save(flags);
if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
uid_hash_remove(up);
key_put(up->uid_keyring);
@@ -97,6 +100,7 @@
kmem_cache_free(uid_cachep, up);
spin_unlock(&uidhash_lock);
}
+ local_irq_restore(flags);
}
struct user_struct * alloc_uid(uid_t uid)
next reply other threads:[~2004-12-22 22:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-22 22:08 Robin Holt [this message]
2004-12-23 17:37 ` [PATCH] AB-BA deadlock between uidhash_lock and tasklist_lock Robin Holt
2004-12-23 22:54 ` Andrew Morton
2004-12-23 23:21 ` Jesper Juhl
2004-12-23 23:30 ` Andrew Morton
2004-12-23 23:37 ` Linus Torvalds
2005-03-10 12:37 Robin Holt
2005-03-10 18:40 ` Linus Torvalds
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=20041222220800.GB6213@lnx-holt.americas.sgi.com \
--to=holt@sgi.com \
--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;
as well as URLs for NNTP newsgroup(s).