diff options
author | Arnd Bergmann <arnd@arndb.de> | 2007-09-11 18:23:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-09-11 20:21:20 -0400 |
commit | 179c85ea53bef807621f335767e41e23f86f01df (patch) | |
tree | 6320c1478ebe988b5251a92498836bf3d045642a /kernel | |
parent | a570ab6f10462b062c28188b64377b8034235761 (diff) |
futex_compat: fix list traversal bugs
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>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/futex_compat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c index f7921360efad..7e52eb051f22 100644 --- a/kernel/futex_compat.c +++ b/kernel/futex_compat.c | |||
@@ -61,10 +61,10 @@ void compat_exit_robust_list(struct task_struct *curr) | |||
61 | if (fetch_robust_entry(&upending, &pending, | 61 | if (fetch_robust_entry(&upending, &pending, |
62 | &head->list_op_pending, &pip)) | 62 | &head->list_op_pending, &pip)) |
63 | return; | 63 | return; |
64 | if (upending) | 64 | if (pending) |
65 | handle_futex_death((void __user *)pending + futex_offset, curr, pip); | 65 | handle_futex_death((void __user *)pending + futex_offset, curr, pip); |
66 | 66 | ||
67 | while (compat_ptr(uentry) != &head->list) { | 67 | while (entry != (struct robust_list __user *) &head->list) { |
68 | /* | 68 | /* |
69 | * A pending lock might already be on the list, so | 69 | * A pending lock might already be on the list, so |
70 | * dont process it twice: | 70 | * dont process it twice: |