lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-a21294644623ee41034db60e93aaebed4db0e57b@git.kernel.org>
Date:	Wed, 18 Feb 2015 09:11:20 -0800
From:	tip-bot for Oleg Nesterov <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	oleg@...hat.com, hpa@...or.com, mguzik@...hat.com,
	linux-kernel@...r.kernel.org, mingo@...nel.org,
	peterz@...radead.org, catalin.marinas@....com, tglx@...utronix.de,
	jmarchan@...hat.com, dave@...olabs.net, darren@...art.com,
	lwoodman@...hat.com, torvalds@...ux-foundation.org
Subject: [tip:locking/core] locking/futex:
  Check PF_KTHREAD rather than !p->mm to filter out kthreads

Commit-ID:  a21294644623ee41034db60e93aaebed4db0e57b
Gitweb:     http://git.kernel.org/tip/a21294644623ee41034db60e93aaebed4db0e57b
Author:     Oleg Nesterov <oleg@...hat.com>
AuthorDate: Mon, 2 Feb 2015 15:05:36 +0100
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 18 Feb 2015 16:57:09 +0100

locking/futex: Check PF_KTHREAD rather than !p->mm to filter out kthreads

attach_to_pi_owner() checks p->mm to prevent attaching to kthreads and
this looks doubly wrong:

1. It should actually check PF_KTHREAD, kthread can do use_mm().

2. If this task is not kthread and it is actually the lock owner we can
   wrongly return -EPERM instead of -ESRCH or retry-if-EAGAIN.

   And note that this wrong EPERM is the likely case unless the exiting
   task is (auto)reaped quickly, we check ->mm before PF_EXITING.

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Darren Hart <darren@...art.com>
Cc: Davidlohr Bueso <dave@...olabs.net>
Cc: Jerome Marchand <jmarchan@...hat.com>
Cc: Larry Woodman <lwoodman@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Mateusz Guzik <mguzik@...hat.com>
Link: http://lkml.kernel.org/r/20150202140536.GA26406@redhat.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 kernel/futex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 4eeb63d..1f6d646 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -900,7 +900,7 @@ static int attach_to_pi_owner(u32 uval, union futex_key *key,
 	if (!p)
 		return -ESRCH;
 
-	if (!p->mm) {
+	if (unlikely(p->flags & PF_KTHREAD)) {
 		put_task_struct(p);
 		return -EPERM;
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ