futex: Detect mismatched requeue targets
authorDarren Hart <dvhltc@us.ibm.com>
Fri, 14 Aug 2009 00:36:53 +0000 (17:36 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 16 Aug 2009 08:59:05 +0000 (10:59 +0200)
commit84bc4af59081ee974dd80210e694ab59ebe51ce8
treea07c68106814d0a748e00c75466d741d05d7e908
parentcc6db4e60116c1f76577b6850a35ae7de69a95b6
futex: Detect mismatched requeue targets

There is currently no check to ensure that userspace uses the same
futex requeue target (uaddr2) in futex_requeue() that the waiter used
in futex_wait_requeue_pi().  A mismatch here could very unexpected
results as the waiter assumes it either wakes on uaddr1 or uaddr2. We
could detect this on wakeup in the waiter, but the cleanup is more
intense after the improper requeue has occured.

This patch stores the waiter's expected requeue target in a new
requeue_pi_key pointer in the futex_q which futex_requeue() checks
prior to attempting to do a proxy lock acquistion or a requeue when
requeue_pi=1. If they don't match, return -EINVAL from futex_requeue,
aborting the requeue of any remaining waiters.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: Dinakar Guniguntala <dino@in.ibm.com>
Cc: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <20090814003650.14634.63916.stgit@Aeon>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/futex.c