From: Thomas Gleixner <t...@linutronix.de>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

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 <da...@redhat.com>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Reviewed-by: Darren Hart <dvh...@linux.intel.com>
Reviewed-by: Davidlohr Bueso <d...@stgolabs.net>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1409112318500.4178@nanos
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Signed-off-by: Jiri Slaby <jsl...@suse.cz>
---
 kernel/futex.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index f94695c9d38b..e4b9b60e25b1 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2465,6 +2465,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, 
unsigned int flags,
         * shared futexes. We need to compare the keys:
         */
        if (match_futex(&q.key, &key2)) {
+               queue_unlock(&q, hb);
                ret = -EINVAL;
                goto out_put_keys;
        }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to