diff options
author | Oleg Nesterov <oleg@redhat.com> | 2015-02-02 09:05:36 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-02-18 10:57:09 -0500 |
commit | a21294644623ee41034db60e93aaebed4db0e57b (patch) | |
tree | 864432246453f636e36544aa601860dde50cc40a /kernel/futex.c | |
parent | be1f7bf217ebb1e42190d7d0b332c89ea7871378 (diff) |
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@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Darren Hart <darren@dvhart.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mateusz Guzik <mguzik@redhat.com>
Link: http://lkml.kernel.org/r/20150202140536.GA26406@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/futex.c')
-rw-r--r-- | kernel/futex.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 4eeb63de7e54..1f6d646eee4a 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, | |||
900 | if (!p) | 900 | if (!p) |
901 | return -ESRCH; | 901 | return -ESRCH; |
902 | 902 | ||
903 | if (!p->mm) { | 903 | if (unlikely(p->flags & PF_KTHREAD)) { |
904 | put_task_struct(p); | 904 | put_task_struct(p); |
905 | return -EPERM; | 905 | return -EPERM; |
906 | } | 906 | } |