[patch 10/24] futexes: Fix infinite loop in get_futex_key() on huge page

From: Greg KH
Date: Fri Jul 17 2009 - 16:22:53 EST


2.6.30-stable review patch. If anyone has any objections, please let us know.

------------------

From: Sonny Rao <sonnyrao@xxxxxxxxxx>

commit ce2ae53b750abfaa012ce408e93da131a5b5649b upstream.

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@xxxxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: anton@xxxxxxxxx
Cc: rajamony@xxxxxxxxxx
Cc: speight@xxxxxxxxxx
Cc: mstephen@xxxxxxxxxx
Cc: grimm@xxxxxxxxxx
Cc: mikey@xxxxxxxxxxxxxxxxx
LKML-Reference: <20090710231313.GA23572@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
kernel/futex.c | 1 +
1 file changed, 1 insertion(+)

--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -241,6 +241,7 @@ again:
if (err < 0)
return err;

+ page = compound_head(page);
lock_page(page);
if (!page->mapping) {
unlock_page(page);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/