Skip to content

Commit d9b9ff8

Browse files
David HildenbrandIngo Molnar
authored andcommitted
sched/preempt, futex: Disable preemption in UP futex_atomic_cmpxchg_inatomic() explicitly
Let's explicitly disable/enable preemption in the !CONFIG_SMP version of futex_atomic_cmpxchg_inatomic(), to prepare for pagefault_disable() not touching preemption anymore. This is needed for this function to be callable from both, atomic and non-atomic context. Otherwise we might break mutual exclusion when relying on a get_user()/ put_user() implementation. Reviewed-and-tested-by: Thomas Gleixner <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f3dae07 commit d9b9ff8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/asm-generic/futex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
107107
{
108108
u32 val;
109109

110+
preempt_disable();
110111
if (unlikely(get_user(val, uaddr) != 0))
111112
return -EFAULT;
112113

113114
if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
114115
return -EFAULT;
115116

116117
*uval = val;
118+
preempt_enable();
117119

118120
return 0;
119121
}

0 commit comments

Comments
 (0)