public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Andi Kleen <andi@firstfloor.org>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, tglx@linutronix.de,
	dvhltc@us.ibm.com, stable@kernel.org
Subject: Re: [PATCH] futex: Take mmap_sem for get_user_pages in fault_in_user_writeable
Date: Tue, 8 Dec 2009 22:26:12 +1100	[thread overview]
Message-ID: <20091208112612.GH3511@nick> (raw)
In-Reply-To: <20091208121942.GA21298@basil.fritz.box>

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@suse.de
> Cc: tglx@linutronix.de
> Cc: dvhltc@us.ibm.com
> Signed-off-by: Andi Kleen <ak@linux.intel.com>

I agree it should go to .stable.

Acked-by: Nick Piggin <npiggin@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;
>  }
>  

  reply	other threads:[~2009-12-08 12:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 12:19 [PATCH] futex: Take mmap_sem for get_user_pages in fault_in_user_writeable Andi Kleen
2009-12-08 11:26 ` Nick Piggin [this message]
2009-12-08 14:03 ` [tip:core/urgent] " tip-bot for Andi Kleen

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=20091208112612.GH3511@nick \
    --to=npiggin@suse.de \
    --cc=akpm@osdl.org \
    --cc=andi@firstfloor.org \
    --cc=dvhltc@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.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