futexes: Fix infinite loop in get_futex_key() on huge page
authorSonny Rao <[email protected]>
Fri, 10 Jul 2009 23:13:13 +0000 (18:13 -0500)
committerIngo Molnar <[email protected]>
Sat, 11 Jul 2009 10:40:44 +0000 (12:40 +0200)
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 <[email protected]>
Acked-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
LKML-Reference: <20090710231313[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
kernel/futex.c

index 794c862125feff034a231d4f16a5106189625d10..0672ff88f159f3041206750b3427fdd68aa0afc1 100644 (file)
@@ -247,6 +247,7 @@ again:
        if (err < 0)
                return err;
 
+       page = compound_head(page);
        lock_page(page);
        if (!page->mapping) {
                unlock_page(page);