diff options
author | Mikael Pettersson <mikpe@it.uu.se> | 2010-01-23 16:36:29 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-02-03 09:13:22 -0500 |
commit | 5ecb01cfdf96c5f465192bdb2a4fd4a61a24c6cc (patch) | |
tree | 718e04a92a89352dd39193f8a2e08d657d80914e | |
parent | d6ad3e286d2c075a60b9f11075a2c55aeeeca2ad (diff) |
futex_lock_pi() key refcnt fix
This fixes a futex key reference count bug in futex_lock_pi(),
where a key's reference count is incremented twice but decremented
only once, causing the backing object to not be released.
If the futex is created in a temporary file in an ext3 file system,
this bug causes the file's inode to become an "undead" orphan,
which causes an oops from a BUG_ON() in ext3_put_super() when the
file system is unmounted. glibc's test suite is known to trigger this,
see <http://bugzilla.kernel.org/show_bug.cgi?id=14256>.
The bug is a regression from 2.6.28-git3, namely Peter Zijlstra's
38d47c1b7075bd7ec3881141bb3629da58f88dab "[PATCH] futex: rely on
get_user_pages() for shared futexes". That commit made get_futex_key()
also increment the reference count of the futex key, and updated its
callers to decrement the key's reference count before returning.
Unfortunately the normal exit path in futex_lock_pi() wasn't corrected:
the reference count is incremented by get_futex_key() and queue_lock(),
but the normal exit path only decrements once, via unqueue_me_pi().
The fix is to put_futex_key() after unqueue_me_pi(), since 2.6.31
this is easily done by 'goto out_put_key' rather than 'goto out'.
Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Darren Hart <dvhltc@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@kernel.org>
-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 d9b3a2228f9d..17828033a639 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -1971,7 +1971,7 @@ retry_private: | |||
1971 | /* Unqueue and drop the lock */ | 1971 | /* Unqueue and drop the lock */ |
1972 | unqueue_me_pi(&q); | 1972 | unqueue_me_pi(&q); |
1973 | 1973 | ||
1974 | goto out; | 1974 | goto out_put_key; |
1975 | 1975 | ||
1976 | out_unlock_put_key: | 1976 | out_unlock_put_key: |
1977 | queue_unlock(&q, hb); | 1977 | queue_unlock(&q, hb); |