[tip:core/urgent] futex: Fix locking imbalance

From: tip-bot for Thomas Gleixner
Date: Sun Oct 04 2009 - 11:50:57 EST


Commit-ID: bfeed8fcf9970d2c3bcd7950124e77fd49930e36
Gitweb: http://git.kernel.org/tip/bfeed8fcf9970d2c3bcd7950124e77fd49930e36
Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
AuthorDate: Sun, 4 Oct 2009 09:34:17 +0200
Committer: Ingo Molnar <mingo@xxxxxxx>
CommitDate: Sun, 4 Oct 2009 17:46:13 +0200

futex: Fix locking imbalance

Rich reported a lock imbalance in the futex code:

http://bugzilla.kernel.org/show_bug.cgi?id=14288

It's caused by the displacement of the retry_private label in
futex_wake_op(). The code unlocks the hash bucket locks in the
error handling path and retries without locking them again which
makes the next unlock fail.

Move retry_private so we lock the hash bucket locks when we retry.

Reported-by: Rich Ercolany <rercola@xxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Darren Hart <dvhltc@xxxxxxxxxx>
Cc: stable-2.6.31 <stable@xxxxxxxxxx>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
kernel/futex.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 463af2e..1e176f3 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -916,8 +916,8 @@ retry:
hb1 = hash_futex(&key1);
hb2 = hash_futex(&key2);

- double_lock_hb(hb1, hb2);
retry_private:
+ double_lock_hb(hb1, hb2);
op_ret = futex_atomic_op_inuser(op, uaddr2);
if (unlikely(op_ret < 0)) {

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