Skip to content

Commit

Permalink
futex: Take mmap_sem for get_user_pages in fault_in_user_writeable
Browse files Browse the repository at this point in the history
get_user_pages() must be called with mmap_sem held.

Signed-off-by: Andi Kleen <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
Andi Kleen authored and KAGA-KOKO committed Dec 8, 2009
1 parent f5754bf commit 722d017
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,14 @@ void put_futex_key(int fshared, union futex_key *key)
*/
static int fault_in_user_writeable(u32 __user *uaddr)
{
int ret = get_user_pages(current, current->mm, (unsigned long)uaddr,
1, 1, 0, NULL, NULL);
struct mm_struct *mm = current->mm;
int ret;

down_read(&mm->mmap_sem);
ret = get_user_pages(current, mm, (unsigned long)uaddr,
1, 1, 0, NULL, NULL);
up_read(&mm->mmap_sem);

return ret < 0 ? ret : 0;
}

Expand Down

0 comments on commit 722d017

Please sign in to comment.