futex: Unlock hb->lock in futex_wait_requeue_pi() error path
authorThomas Gleixner <tglx@linutronix.de>
Thu, 11 Sep 2014 21:44:35 +0000 (23:44 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 5 Nov 2014 20:27:43 +0000 (20:27 +0000)
commit2e10b8a67f891a1d9b86ca72321259a7f63d3b42
treecff4d6f743386922c0ff0611eda19b0abdb71387
parent29a8d1a41767ad86f7caca17762a7fddf3207201
futex: Unlock hb->lock in futex_wait_requeue_pi() error path

commit 13c42c2f43b19aab3195f2d357db00d1e885eaa8 upstream.

futex_wait_requeue_pi() calls futex_wait_setup(). If
futex_wait_setup() succeeds it returns with hb->lock held and
preemption disabled. Now the sanity check after this does:

        if (match_futex(&q.key, &key2)) {
    ret = -EINVAL;
goto out_put_keys;
}

which releases the keys but does not release hb->lock.

So we happily return to user space with hb->lock held and therefor
preemption disabled.

Unlock hb->lock before taking the exit route.

Reported-by: Dave "Trinity" Jones <davej@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1409112318500.4178@nanos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bwh: Backported to 3.2: queue_unlock() takes two parameters]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
kernel/futex.c