mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Dave Jones <davej@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Darren Hart <darren@dvhart.com>,
	Davidlohr Bueso <davidlohr@hp.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Clark Williams <williams@redhat.com>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Roland McGrath <roland@hack.frob.com>,
	Carlos ODonell <carlos@redhat.com>,
	Jakub Jelinek <jakub@redhat.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Willy Tarreau <w@1wt.eu>
Subject: [ 3/9] futex: Prevent attaching to kernel threads
Date: Sat, 14 Jun 2014 21:12:53 +0200	[thread overview]
Message-ID: <20140614191250.253462412@1wt.eu> (raw)
In-Reply-To: <57d1129d02f4fc14423dd66474950cb7@local>

2.6.32-longterm review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Gleixner <tglx@linutronix.de>

We happily allow userspace to declare a random kernel thread to be the
owner of a user space PI futex.

Found while analysing the fallout of Dave Jones syscall fuzzer.

We also should validate the thread group for private futexes and find
some fast way to validate whether the "alleged" owner has RW access on
the file which backs the SHM, but that's a separate issue.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dave Jones <davej@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Darren Hart <darren@dvhart.com>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Clark Williams <williams@redhat.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Carlos ODonell <carlos@redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: http://lkml.kernel.org/r/20140512201701.194824402@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
(cherry picked from commit f0d71b3dcb8332f7971b5f2363632573e6d9486a)
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 kernel/futex.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 731b271..c00b6e4 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -610,6 +610,11 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
 	if (!p)
 		return -ESRCH;
 
+	if (!p->mm) {
+		put_task_struct(p);
+		return -EPERM;
+	}
+
 	/*
 	 * We need to look at the task state flags to figure out,
 	 * whether the task is exiting. To protect against the do_exit
-- 
1.7.12.2.21.g234cd45.dirty




  parent reply	other threads:[~2014-06-14 20:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <57d1129d02f4fc14423dd66474950cb7@local>
2014-06-14 19:12 ` [ 0/9] 2.6.32.63-longterm review Willy Tarreau
2014-06-14 19:12 ` [ 1/9] ethtool: Report link-down while interface is down Willy Tarreau
2014-06-14 19:12 ` [ 2/9] futex: Add another early deadlock detection check Willy Tarreau
2014-06-14 19:12 ` Willy Tarreau [this message]
2014-06-14 19:12 ` [ 4/9] futex-prevent-requeue-pi-on-same-futex.patch futex: Willy Tarreau
2014-06-14 19:12 ` [ 5/9] futex: Validate atomic acquisition in Willy Tarreau
2014-06-14 19:12 ` [ 6/9] futex: Always cleanup owner tid in unlock_pi Willy Tarreau
2014-06-14 19:12 ` [ 7/9] futex: Make lookup_pi_state more robust Willy Tarreau
2014-06-14 19:12 ` [ 8/9] auditsc: audit_krule mask accesses need bounds checking Willy Tarreau
2014-06-14 19:12 ` [ 9/9] net: fix regression introduced in 2.6.32.62 by sysctl Willy Tarreau

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=20140614191250.253462412@1wt.eu \
    --to=w@1wt.eu \
    --cc=bigeasy@linutronix.de \
    --cc=carlos@redhat.com \
    --cc=darren@dvhart.com \
    --cc=davej@redhat.com \
    --cc=davidlohr@hp.com \
    --cc=jakub@redhat.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=roland@hack.frob.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=williams@redhat.com \
    /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

all inboxes | Powered by JetHome®