]> err.no Git - linux-2.6/commitdiff
[PATCH] pi-futex: Validate futex type instead of oopsing
authorThomas Gleixner <tglx@linutronix.de>
Mon, 10 Jul 2006 11:44:30 +0000 (04:44 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 10 Jul 2006 20:24:18 +0000 (13:24 -0700)
Calling futex_lock_pi is called with a reference to a non PI futex and
waiters exist already, lookup_pi_state() oopses due to pi_state == NULL.
Check this condition and return -EINVAL to userspace.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/futex.c

index 1dc98e4dd287ec95872c7c771aab7f14e0d9ca42..cf0c8e21d1abaae85c17a816dbd42a8ed3132dd5 100644 (file)
@@ -476,6 +476,12 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, struct futex_q *me)
                         * the refcount and return its pi_state:
                         */
                        pi_state = this->pi_state;
+                       /*
+                        * Userspace might have messed up non PI and PI futexes
+                        */
+                       if (unlikely(!pi_state))
+                               return -EINVAL;
+
                        atomic_inc(&pi_state->refcount);
                        me->pi_state = pi_state;