public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Sonny Rao <sonnyrao@us.ibm.com>
Cc: tglx@linuxtronix.de, mingo@redhat.com,
	linux-kernel@vger.kernel.org, linux-mm@vger.kernel.org,
	stable@kernel.org, anton@samba.org, rajamony@us.ibm.com,
	speight@us.ibm.com, mstephen@us.ibm.com, grimm@us.ibm.com,
	mikey@ozlabs.au.ibm.com
Subject: Re: [PATCH] futexs: fix infinite loop in get_futex_key on huge page
Date: Sat, 11 Jul 2009 10:19:24 +0200	[thread overview]
Message-ID: <20090711081924.GA10437@elte.hu> (raw)
In-Reply-To: <20090710231313.GA23572@us.ibm.com>


* Sonny Rao <sonnyrao@us.ibm.com> wrote:

> get_futex_key() can infinitely loop if it is called on a virtual 
> address that is within a huge page but not aligned to the 
> beginning of that page.  The call to get_user_pages_fast will 
> return the struct page for a sub-page within the huge page and the 
> check for page->mapping will always fail.
> 
> The fix is to call compound_head on the page before checking that 
> it's mapped.
> 
> Signed-off-by: Sonny Rao <sonnyrao@us.ibm.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: stable@kernel.org
> 
> Index: linux-2.6.31-rc2/kernel/futex.c
> ===================================================================
> --- linux-2.6.31-rc2.orig/kernel/futex.c	2009-07-10 17:45:46.181084475 -0500
> +++ linux-2.6.31-rc2/kernel/futex.c	2009-07-10 17:46:47.345084062 -0500
> @@ -247,6 +247,7 @@
>  	if (err < 0)
>  		return err;
>  
> +	page = compound_head(page);
>  	lock_page(page);
>  	if (!page->mapping) {
>  		unlock_page(page);

Nice catch! Applied it to tip:core/urgent - Thomas, do you agree 
with the fix?

	Ingo

  reply	other threads:[~2009-07-11  8:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10 23:13 [PATCH] futexs: fix infinite loop in get_futex_key on huge page Sonny Rao
2009-07-11  8:19 ` Ingo Molnar [this message]
2009-07-11 10:14   ` Thomas Gleixner
2009-07-11  8:22 ` [tip:core/urgent] futexes: Fix infinite loop in get_futex_key() " tip-bot for Sonny Rao
2009-07-11 10:42 ` tip-bot for Sonny Rao

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=20090711081924.GA10437@elte.hu \
    --to=mingo@elte.hu \
    --cc=anton@samba.org \
    --cc=grimm@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@vger.kernel.org \
    --cc=mikey@ozlabs.au.ibm.com \
    --cc=mingo@redhat.com \
    --cc=mstephen@us.ibm.com \
    --cc=rajamony@us.ibm.com \
    --cc=sonnyrao@us.ibm.com \
    --cc=speight@us.ibm.com \
    --cc=stable@kernel.org \
    --cc=tglx@linuxtronix.de \
    /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