From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbaFGBcu (ORCPT ); Fri, 6 Jun 2014 21:32:50 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36092 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbaFGBXi (ORCPT ); Fri, 6 Jun 2014 21:23:38 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Roland McGrath" , "Lai Jiangshan" , "Jakub Jelinek" , "Carlos ODonell" , "Clark Williams" , "Darren Hart" , "Peter Zijlstra" , "Michael Kerrisk" , "Linus Torvalds" , "Steven Rostedt" , "Paul McKenney" , "Sebastian Andrzej Siewior" , "Thomas Gleixner" , "Dave Jones" , "Davidlohr Bueso" Date: Sat, 07 Jun 2014 02:26:29 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 88/92] futex: Prevent attaching to kernel threads In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.249 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.60-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit f0d71b3dcb8332f7971b5f2363632573e6d9486a upstream. 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 Cc: Dave Jones Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Darren Hart Cc: Davidlohr Bueso Cc: Steven Rostedt Cc: Clark Williams Cc: Paul McKenney Cc: Lai Jiangshan Cc: Roland McGrath Cc: Carlos ODonell Cc: Jakub Jelinek Cc: Michael Kerrisk Cc: Sebastian Andrzej Siewior Link: http://lkml.kernel.org/r/20140512201701.194824402@linutronix.de Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings --- kernel/futex.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -662,6 +662,11 @@ lookup_pi_state(u32 uval, struct futex_h 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