Skip to content

Commit cf226c4

Browse files
committed
Merge branch 'uaccess.futex' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into locking/core
Pull uaccess futex cleanups for Al Viro: Consolidate access_ok() usage and the futex uaccess function zoo.
2 parents 9e86035 + f5544ba commit cf226c4

File tree

22 files changed

+94
-184
lines changed

22 files changed

+94
-184
lines changed

arch/alpha/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
3131
{
3232
int oldval = 0, ret;
3333

34-
pagefault_disable();
34+
if (!access_ok(uaddr, sizeof(u32)))
35+
return -EFAULT;
3536

3637
switch (op) {
3738
case FUTEX_OP_SET:
@@ -53,8 +54,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
5354
ret = -ENOSYS;
5455
}
5556

56-
pagefault_enable();
57-
5857
if (!ret)
5958
*oval = oldval;
6059

arch/arc/include/asm/futex.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
7575
{
7676
int oldval = 0, ret;
7777

78+
if (!access_ok(uaddr, sizeof(u32)))
79+
return -EFAULT;
80+
7881
#ifndef CONFIG_ARC_HAS_LLSC
7982
preempt_disable(); /* to guarantee atomic r-m-w of futex op */
8083
#endif
81-
pagefault_disable();
8284

8385
switch (op) {
8486
case FUTEX_OP_SET:
@@ -101,7 +103,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
101103
ret = -ENOSYS;
102104
}
103105

104-
pagefault_enable();
105106
#ifndef CONFIG_ARC_HAS_LLSC
106107
preempt_enable();
107108
#endif

arch/arm/include/asm/futex.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
134134
{
135135
int oldval = 0, ret, tmp;
136136

137+
if (!access_ok(uaddr, sizeof(u32)))
138+
return -EFAULT;
139+
137140
#ifndef CONFIG_SMP
138141
preempt_disable();
139142
#endif
140-
pagefault_disable();
141143

142144
switch (op) {
143145
case FUTEX_OP_SET:
@@ -159,7 +161,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
159161
ret = -ENOSYS;
160162
}
161163

162-
pagefault_enable();
163164
#ifndef CONFIG_SMP
164165
preempt_enable();
165166
#endif

arch/arm64/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr)
4848
int oldval = 0, ret, tmp;
4949
u32 __user *uaddr = __uaccess_mask_ptr(_uaddr);
5050

51-
pagefault_disable();
51+
if (!access_ok(_uaddr, sizeof(u32)))
52+
return -EFAULT;
5253

5354
switch (op) {
5455
case FUTEX_OP_SET:
@@ -75,8 +76,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr)
7576
ret = -ENOSYS;
7677
}
7778

78-
pagefault_enable();
79-
8079
if (!ret)
8180
*oval = oldval;
8281

arch/hexagon/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
3636
{
3737
int oldval = 0, ret;
3838

39-
pagefault_disable();
39+
if (!access_ok(uaddr, sizeof(u32)))
40+
return -EFAULT;
4041

4142
switch (op) {
4243
case FUTEX_OP_SET:
@@ -62,8 +63,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
6263
ret = -ENOSYS;
6364
}
6465

65-
pagefault_enable();
66-
6766
if (!ret)
6867
*oval = oldval;
6968

arch/ia64/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
5050
{
5151
int oldval = 0, ret;
5252

53-
pagefault_disable();
53+
if (!access_ok(uaddr, sizeof(u32)))
54+
return -EFAULT;
5455

5556
switch (op) {
5657
case FUTEX_OP_SET:
@@ -74,8 +75,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
7475
ret = -ENOSYS;
7576
}
7677

77-
pagefault_enable();
78-
7978
if (!ret)
8079
*oval = oldval;
8180

arch/microblaze/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
3434
{
3535
int oldval = 0, ret;
3636

37-
pagefault_disable();
37+
if (!access_ok(uaddr, sizeof(u32)))
38+
return -EFAULT;
3839

3940
switch (op) {
4041
case FUTEX_OP_SET:
@@ -56,8 +57,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
5657
ret = -ENOSYS;
5758
}
5859

59-
pagefault_enable();
60-
6160
if (!ret)
6261
*oval = oldval;
6362

arch/mips/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
8989
{
9090
int oldval = 0, ret;
9191

92-
pagefault_disable();
92+
if (!access_ok(uaddr, sizeof(u32)))
93+
return -EFAULT;
9394

9495
switch (op) {
9596
case FUTEX_OP_SET:
@@ -116,8 +117,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
116117
ret = -ENOSYS;
117118
}
118119

119-
pagefault_enable();
120-
121120
if (!ret)
122121
*oval = oldval;
123122

arch/nds32/include/asm/futex.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
6666
{
6767
int oldval = 0, ret;
6868

69-
70-
pagefault_disable();
69+
if (!access_ok(uaddr, sizeof(u32)))
70+
return -EFAULT;
7171
switch (op) {
7272
case FUTEX_OP_SET:
7373
__futex_atomic_op("move %0, %3", ret, oldval, tmp, uaddr,
@@ -93,8 +93,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
9393
ret = -ENOSYS;
9494
}
9595

96-
pagefault_enable();
97-
9896
if (!ret)
9997
*oval = oldval;
10098

arch/openrisc/include/asm/futex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
3535
{
3636
int oldval = 0, ret;
3737

38-
pagefault_disable();
38+
if (!access_ok(uaddr, sizeof(u32)))
39+
return -EFAULT;
3940

4041
switch (op) {
4142
case FUTEX_OP_SET:
@@ -57,8 +58,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
5758
ret = -ENOSYS;
5859
}
5960

60-
pagefault_enable();
61-
6261
if (!ret)
6362
*oval = oldval;
6463

0 commit comments

Comments
 (0)