LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: adrian.bunk@movial.fi, mingo@elte.hu,
	linux-kernel@vger.kernel.org, riku.voipio@movial.fi,
	mikpe@it.uu.se, buytenh@wantstofly.org, rusty@rustcorp.com.au,
	stable@kernel.org
Subject: [PATCH 1/2] futex: fix init order
Date: Fri, 15 Feb 2008 02:23:25 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.1.00.0802150219370.12988@apollo.tec.linutronix.de> (raw)
In-Reply-To: <alpine.LFD.1.00.0802150216350.12988@apollo.tec.linutronix.de>

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);

  reply	other threads:[~2008-02-15  1:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11 13:07 futex local DoS on most architectures Adrian Bunk
2008-02-11 13:56 ` Mikael Pettersson
2008-02-11 13:59 ` Thomas Gleixner
2008-02-11 14:16   ` Lennert Buytenhek
2008-02-12 12:50   ` Riku Voipio
2008-02-14 21:46   ` Andrew Morton
2008-02-15  1:19     ` Thomas Gleixner
2008-02-15  1:23       ` Thomas Gleixner [this message]
2008-02-15  1:36       ` [PATCH 2/2] futex: runtime enable pi and robust functionality Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.00.0802150219370.12988@apollo.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=adrian.bunk@movial.fi \
    --cc=akpm@linux-foundation.org \
    --cc=buytenh@wantstofly.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikpe@it.uu.se \
    --cc=mingo@elte.hu \
    --cc=riku.voipio@movial.fi \
    --cc=rusty@rustcorp.com.au \
    --cc=stable@kernel.org \
    --subject='Re: [PATCH 1/2] futex: fix init order' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).