futex: Fix pi_state->owner serialization
authorPeter Zijlstra <peterz@infradead.org>
Fri, 22 Sep 2017 15:48:06 +0000 (17:48 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 14:37:11 +0000 (16:37 +0200)
commitc74aef2d06a9f59cece89093eecc552933cba72a
tree2f67fc86ee37ac10e61a58199b8667eb1c97bbdc
parente19b205be43d11bff638cad4487008c48d21c103
futex: Fix pi_state->owner serialization

There was a reported suspicion about a race between exit_pi_state_list()
and put_pi_state(). The same report mentioned the comment with
put_pi_state() said it should be called with hb->lock held, and it no
longer is in all places.

As it turns out, the pi_state->owner serialization is indeed broken. As per
the new rules:

  734009e96d19 ("futex: Change locking rules")

pi_state->owner should be serialized by pi_state->pi_mutex.wait_lock.
For the sites setting pi_state->owner we already hold wait_lock (where
required) but exit_pi_state_list() and put_pi_state() were not and
raced on clearing it.

Fixes: 734009e96d19 ("futex: Change locking rules")
Reported-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: dvhart@infradead.org
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20170922154806.jd3ffltfk24m4o4y@hirez.programming.kicks-ass.net
kernel/futex.c