From: Nick Piggin on
On Tue, Dec 08, 2009 at 01:19:42PM +0100, Andi Kleen wrote:
> futex: Take mmap_sem for get_user_pages in fault_in_user_writeable
>
> gup() requires mmap_sem, so take it before running it. The
> recent fault_in_user_writeable() didn't do that.
>
> I didn't find a good futex test case, so untested.
>
> Likely a stable candidate.
>
> Cc: npiggin(a)suse.de
> Cc: tglx(a)linutronix.de
> Cc: dvhltc(a)us.ibm.com
> Signed-off-by: Andi Kleen <ak(a)linux.intel.com>

I agree it should go to .stable.

Acked-by: Nick Piggin <npiggin(a)suse.de>


> ---
> kernel/futex.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.32-ak/kernel/futex.c
> ===================================================================
> --- linux-2.6.32-ak.orig/kernel/futex.c
> +++ linux-2.6.32-ak/kernel/futex.c
> @@ -304,8 +304,13 @@ void put_futex_key(int fshared, union fu
> */
> static int fault_in_user_writeable(u32 __user *uaddr)
> {
> - int ret = get_user_pages(current, current->mm, (unsigned long)uaddr,
> + int ret;
> + struct mm_struct *mm = current->mm;
> +
> + 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;
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/