From: Andrew Morton <akpm@linux-foundation.org>
To: Russell King <rmk@arm.linux.org.uk>
Cc: linux-arch@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [BUG] Fault handlers can deadlock
Date: Mon, 11 Jun 2007 09:41:16 -0700 [thread overview]
Message-ID: <20070611094116.34e83ae6.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070611160026.GA16265@flint.arm.linux.org.uk>
On Mon, 11 Jun 2007 17:00:27 +0100 Russell King <rmk@arm.linux.org.uk> wrote:
> Recently, a bug has been discovered on ARM whereby if futexes are
> being used and the system is put under heavy load, a deadlock will
> occur.
>
> The deadlock involves mmap_sem having been taken by the futex code
> and a page fault occuring in copy_from_user_inatomic(). We then
> hit this:
>
> /*
> * As per x86, we may deadlock here. However, since the kernel only
> * validly references user space from well defined areas of the code,
> * we can bug out early if this is from code which shouldn't.
> */
> if (!down_read_trylock(&mm->mmap_sem)) {
> if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
> goto no_context;
> down_read(&mm->mmap_sem);
> }
We shouldn't get that far, if the caller is copy_from_user_inatomic():
/*
* If we're in an interrupt or have no user
* context, we must not take the fault..
*/
if (in_atomic() || !mm)
**taken goto no_context;
/*
* As per x86, we may deadlock here. However, since the kernel only
* validly references user space from well defined areas of the code,
* we can bug out early if this is from code which shouldn't.
*/
if (!down_read_trylock(&mm->mmap_sem)) {
if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
goto no_context;
down_read(&mm->mmap_sem);
}
I assume this is the callsite:
static inline int get_futex_value_locked(u32 *dest, u32 __user *from)
{
int ret;
pagefault_disable();
ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
pagefault_enable();
return ret ? -EFAULT : 0;
}
it seems to be doing the right thing there, but for some reason it isn't
working as designed?
next prev parent reply other threads:[~2007-06-11 16:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 16:00 [BUG] Fault handlers can deadlock Russell King
2007-06-11 16:41 ` Andrew Morton [this message]
2007-06-11 16:53 ` Russell King
2007-06-11 17:31 ` Andrew Morton
2007-06-11 17:38 ` Russell King
2007-06-11 17:51 ` Linus Torvalds
2007-06-11 17:39 ` Linus Torvalds
2007-06-11 18:08 ` Russell King
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=20070611094116.34e83ae6.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-arch@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
--cc=torvalds@linux-foundation.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).