mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: akpm@osdl.org, linux-kernel@vger.kernel.org, npiggin@suse.de,
	tglx@linutronix.de, dvhltc@us.ibm.com
Cc: stable@kernel.org
Subject: [PATCH] futex: Take mmap_sem for get_user_pages in fault_in_user_writeable
Date: Tue, 8 Dec 2009 13:19:42 +0100	[thread overview]
Message-ID: <20091208121942.GA21298@basil.fritz.box> (raw)

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>

---
 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:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 12:19 Andi Kleen [this message]
2009-12-08 11:26 ` Nick Piggin
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=20091208121942.GA21298@basil.fritz.box \
    --to=andi@firstfloor.org \
    --cc=akpm@osdl.org \
    --cc=dvhltc@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --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

Powered by JetHome