futex: catch certain assymetric (get|put)_futex_key calls

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, January 6, 2009 - 7:13 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=90621c...
Commit:     90621c40cc4ab7b0a414311ce37e7cc7173403b6
Parent:     42d35d48ce7cefb9429880af19d1c329d1554e7a
Author:     Darren Hart <dvhltc@us.ibm.com>
AuthorDate: Mon Dec 29 19:43:21 2008 -0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri Jan 2 23:10:44 2009 +0100

    futex: catch certain assymetric (get|put)_futex_key calls
    
    Impact: add debug check
    
    Following up on my previous key reference accounting patches, this patch
    will catch puts on keys that haven't been "got".  This won't catch nested
    get/put mismatches though.
    
    Build and boot tested, with minimal desktop activity and a run of the
    open_posix_testsuite in LTP for testing.  No warnings logged.
    
    Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
    Cc: <stable@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/futex.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index c5ac55c..206d4c9 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -170,8 +170,11 @@ static void get_futex_key_refs(union futex_key *key)
  */
 static void drop_futex_key_refs(union futex_key *key)
 {
-	if (!key->both.ptr)
+	if (!key->both.ptr) {
+		/* If we're here then we tried to put a key we failed to get */
+		WARN_ON_ONCE(1);
 		return;
+	}
 
 	switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
 	case FUT_OFF_INODE:
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
futex: catch certain assymetric (get|put)_futex_key calls, Linux Kernel Mailing ..., (Tue Jan 6, 7:13 pm)