[PATCH 1/2] futex: fix init order

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Thomas Gleixner
Date: Thursday, February 14, 2008 - 6:23 pm

When the futex init code fails to initialize the futex pseudo file
system it returns early without initializing the hash queues. Should
the boot succeed then a futex syscall which tries to enqueue a waiter
on the hashqueue will crash due to the unitilialized plist heads.

Initialize the hash queues before the filesystem.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>

---
 kernel/futex.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Index: linux-2.6/kernel/futex.c
===================================================================
--- linux-2.6.orig/kernel/futex.c
+++ linux-2.6/kernel/futex.c
@@ -2145,8 +2145,14 @@ static struct file_system_type futex_fs_
 
 static int __init init(void)
 {
-	int i = register_filesystem(&futex_fs_type);
+	int i;
 
+	for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
+		plist_head_init(&futex_queues[i].chain, &futex_queues[i].lock);
+		spin_lock_init(&futex_queues[i].lock);
+	}
+
+	i = register_filesystem(&futex_fs_type);
 	if (i)
 		return i;
 
@@ -2156,10 +2162,6 @@ static int __init init(void)
 		return PTR_ERR(futex_mnt);
 	}
 
-	for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
-		plist_head_init(&futex_queues[i].chain, &futex_queues[i].lock);
-		spin_lock_init(&futex_queues[i].lock);
-	}
 	return 0;
 }
 __initcall(init);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
futex local DoS on most architectures, Adrian Bunk, (Mon Feb 11, 6:07 am)
Re: futex local DoS on most architectures, Mikael Pettersson, (Mon Feb 11, 6:56 am)
Re: futex local DoS on most architectures, Thomas Gleixner, (Mon Feb 11, 6:59 am)
Re: futex local DoS on most architectures, Lennert Buytenhek, (Mon Feb 11, 7:16 am)
Re: futex local DoS on most architectures, Riku Voipio, (Tue Feb 12, 5:50 am)
Re: futex local DoS on most architectures, Andrew Morton, (Thu Feb 14, 2:46 pm)
Re: futex local DoS on most architectures, Thomas Gleixner, (Thu Feb 14, 6:19 pm)
[PATCH 1/2] futex: fix init order, Thomas Gleixner, (Thu Feb 14, 6:23 pm)