mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH]: Fix futex compat bug.
@ 2007-08-23  4:31 David Miller
  0 siblings, 0 replies; only message in thread
From: David Miller @ 2007-08-23  4:31 UTC (permalink / raw)
  To: linux-kernel


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.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index f792136..92af955 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -64,7 +64,7 @@ void compat_exit_robust_list(struct task_struct *curr)
 	if (upending)
 		handle_futex_death((void __user *)pending + futex_offset, curr, pip);
 
-	while (compat_ptr(uentry) != &head->list) {
+	while (entry != (struct robust_list *) &head->list) {
 		/*
 		 * A pending lock might already be on the list, so
 		 * dont process it twice:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-23  4:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-23  4:31 [PATCH]: Fix futex compat bug David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®