]> Git Repo - linux.git/commit - kernel/futex_compat.c
futex: runtime enable pi and robust functionality
authorThomas Gleixner <[email protected]>
Sat, 23 Feb 2008 23:23:57 +0000 (15:23 -0800)
committerLinus Torvalds <[email protected]>
Sun, 24 Feb 2008 01:12:15 +0000 (17:12 -0800)
commita0c1e9073ef7428a14309cba010633a6cd6719ea
tree05ce792ddcde92e73d1bae4c8e20f607a2e7db40
parent3e4ab747efa8e78562ec6782b08bbf21a00aba1b
futex: runtime enable pi and robust functionality

Not all architectures implement futex_atomic_cmpxchg_inatomic().  The default
implementation returns -ENOSYS, which is currently not handled inside of the
futex guts.

Futex PI calls and robust list exits with a held futex result in an endless
loop in the futex code on architectures which have no support.

Fixing up every place where futex_atomic_cmpxchg_inatomic() is called would
add a fair amount of extra if/else constructs to the already complex code.  It
is also not possible to disable the robust feature before user space tries to
register robust lists.

Compile time disabling is not a good idea either, as there are already
architectures with runtime detection of futex_atomic_cmpxchg_inatomic support.

Detect the functionality at runtime instead by calling
cmpxchg_futex_value_locked() with a NULL pointer from the futex initialization
code.  This is guaranteed to fail, but the call of
futex_atomic_cmpxchg_inatomic() happens with pagefaults disabled.

On architectures, which use the asm-generic implementation or have a runtime
CPU feature detection, a -ENOSYS return value disables the PI/robust features.

On architectures with a working implementation the call returns -EFAULT and
the PI/robust features are enabled.

The relevant syscalls return -ENOSYS and the robust list exit code is blocked,
when the detection fails.

Fixes http://lkml.org/lkml/2008/2/11/149
Originally reported by: Lennart Buytenhek

Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Lennert Buytenhek <[email protected]>
Cc: Riku Voipio <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/futex.h
kernel/futex.c
kernel/futex_compat.c
This page took 0.054762 seconds and 4 git commands to generate.