summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2007-09-11 15:23:49 -0700
committerWilly Tarreau <w@1wt.eu>2007-10-17 21:30:32 +0200
commit9547f85db4b6007a540dad51aa98dda3af942b25 (patch)
tree9a24b8645a0cd76348f11e0915576be0d626ac95
parent05e3c38409401e00703ee50df8ee989dfa35be63 (diff)
downloadlinux-stable-9547f85db4b6007a540dad51aa98dda3af942b25.tar.gz
linux-stable-9547f85db4b6007a540dad51aa98dda3af942b25.tar.bz2
linux-stable-9547f85db4b6007a540dad51aa98dda3af942b25.zip
[PATCH] futex_compat: fix list traversal bugs
commit 179c85ea53bef807621f335767e41e23f86f01df in mainline. The futex list traversal on the compat side appears to have a bug. It's loop termination condition compares: while (compat_ptr(uentry) != &head->list) But that can't be right because "uentry" has the special "pi" indicator bit still potentially set at bit 0. This is cleared by fetch_robust_entry() into the "entry" return value. What this seems to mean is that the list won't terminate when list iteration gets back to the the head. And we'll also process the list head like a normal entry, which could cause all kinds of problems. So we should check for equality with "entry". That pointer is of the non-compat type so we have to do a little casting to keep the compiler and sparse happy. The same problem can in theory occur with the 'pending' variable, although that has not been reported from users so far. Based on the original patch from David Miller. Acked-by: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: David Miller <davem@davemloft.net> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--kernel/futex_compat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 50f24eea6cd0..5f0115f71b17 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -61,10 +61,10 @@ void compat_exit_robust_list(struct task_struct *curr)
if (fetch_robust_entry(&upending, &pending,
&head->list_op_pending, &pip))
return;
- if (upending)
+ if (pending)
handle_futex_death((void __user *)pending + futex_offset, curr, pip);
- while (compat_ptr(uentry) != &head->list) {
+ while (entry != (struct robust_list __user *) &head->list) {
/*
* A pending lock might already be on the list, so
* dont process it twice: