Skip to content

Commit f3dae07

Browse files
David HildenbrandIngo Molnar
authored andcommitted
sched/preempt, futex: Disable preemption in UP futex_atomic_op_inuser() explicitly
Let's explicitly disable/enable preemption in the !CONFIG_SMP version of futex_atomic_op_inuser, to prepare for pagefault_disable() not touching preemption anymore. 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 32d8206 commit f3dae07

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/asm-generic/futex.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef CONFIG_SMP
99
/*
1010
* The following implementation only for uniprocessor machines.
11-
* For UP, it's relies on the fact that pagefault_disable() also disables
12-
* preemption to ensure mutual exclusion.
11+
* It relies on preempt_disable() ensuring mutual exclusion.
1312
*
1413
*/
1514

@@ -38,6 +37,7 @@ futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
3837
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
3938
oparg = 1 << oparg;
4039

40+
preempt_disable();
4141
pagefault_disable();
4242

4343
ret = -EFAULT;
@@ -72,6 +72,7 @@ futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
7272

7373
out_pagefault_enable:
7474
pagefault_enable();
75+
preempt_enable();
7576

7677
if (ret == 0) {
7778
switch (cmp) {

0 commit comments

Comments
 (0)