History

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.

Thomas Gleixner committed 6 years ago

Commit cf226c42 parents 9e86035 f5544ba22 files · +94 −184Browse files

Unified · Split

22 files
  1. arch/alpha/include/asm/futex.h +2 −3
  2. arch/arc/include/asm/futex.h +3 −2
  3. arch/arm/include/asm/futex.h +3 −2
  4. arch/arm64/include/asm/futex.h +2 −3
  5. arch/hexagon/include/asm/futex.h +2 −3
  6. arch/ia64/include/asm/futex.h +2 −3
  7. arch/microblaze/include/asm/futex.h +2 −3
  8. arch/mips/include/asm/futex.h +2 −3
  9. arch/nds32/include/asm/futex.h +2 −4
  10. arch/openrisc/include/asm/futex.h +2 −3
  11. arch/parisc/include/asm/futex.h +0 −2
  12. arch/powerpc/include/asm/futex.h +2 −3
  13. arch/riscv/include/asm/futex.h +2 −3
  14. arch/s390/include/asm/futex.h +0 −2
  15. arch/sh/include/asm/futex.h +0 −4
  16. arch/sparc/include/asm/futex_64.h +0 −4
  17. arch/x86/include/asm/futex.h +63 −36
  18. arch/x86/include/asm/uaccess.h +0 −93
  19. arch/xtensa/include/asm/futex.h +2 −3
  20. include/asm-generic/futex.h +0 −2
  21. kernel/futex.c +2 −3
  22. tools/objtool/check.c +1 −0
arch/alpha/include/asm/futex.h+2−3
@@ -31,7 +31,8 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 30 unmodified lines
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, · 15 unmodified lines
5354 ret = -ENOSYS;
5455 }
5556
56− pagefault_enable();
57−
5857 if (!ret)
5958 *oval = oldval;
6059
arch/arc/include/asm/futex.h+3−2
@@ -75,10 +75,12 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 74 unmodified lines
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, · 16 unmodified lines
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+3−2
@@ -134,10 +134,12 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 133 unmodified lines
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) · 15 unmodified lines
159161 ret = -ENOSYS;
160162 }
161163
162− pagefault_enable();
163164 #ifndef CONFIG_SMP
164165 preempt_enable();
165166 #endif
arch/arm64/include/asm/futex.h+2−3
@@ -48,7 +48,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr) · 47 unmodified lines
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) · 20 unmodified lines
7576 ret = -ENOSYS;
7677 }
7778
78− pagefault_enable();
79−
8079 if (!ret)
8180 *oval = oldval;
8281
arch/hexagon/include/asm/futex.h+2−3
@@ -36,7 +36,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 35 unmodified lines
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) · 19 unmodified lines
6263 ret = -ENOSYS;
6364 }
6465
65− pagefault_enable();
66−
6766 if (!ret)
6867 *oval = oldval;
6968
arch/ia64/include/asm/futex.h+2−3
@@ -50,7 +50,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 49 unmodified lines
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) · 17 unmodified lines
7475 ret = -ENOSYS;
7576 }
7677
77− pagefault_enable();
78−
7978 if (!ret)
8079 *oval = oldval;
8180
arch/microblaze/include/asm/futex.h+2−3
@@ -34,7 +34,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 33 unmodified lines
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) · 15 unmodified lines
5657 ret = -ENOSYS;
5758 }
5859
59− pagefault_enable();
60−
6160 if (!ret)
6261 *oval = oldval;
6362
arch/mips/include/asm/futex.h+2−3
@@ -89,7 +89,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 88 unmodified lines
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) · 20 unmodified lines
116117 ret = -ENOSYS;
117118 }
118119
119− pagefault_enable();
120−
121120 if (!ret)
122121 *oval = oldval;
123122
arch/nds32/include/asm/futex.h+2−4
@@ -66,8 +66,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 65 unmodified lines
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) · 19 unmodified lines
9393 ret = -ENOSYS;
9494 }
9595
96− pagefault_enable();
97−
9896 if (!ret)
9997 *oval = oldval;
10098
arch/openrisc/include/asm/futex.h+2−3
@@ -35,7 +35,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 34 unmodified lines
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) · 15 unmodified lines
5758 ret = -ENOSYS;
5859 }
5960
60− pagefault_enable();
61−
6261 if (!ret)
6362 *oval = oldval;
6463
arch/parisc/include/asm/futex.h+0−2
@@ -40,7 +40,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 39 unmodified lines
4040 u32 tmp;
4141
4242 _futex_spin_lock_irqsave(uaddr, &flags);
43− pagefault_disable();
4443
4544 ret = -EFAULT;
4645 if (unlikely(get_user(oldval, uaddr) != 0))
@@ -73,7 +72,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 26 unmodified lines
7372 ret = -EFAULT;
7473
7574 out_pagefault_enable:
76− pagefault_enable();
7775 _futex_spin_unlock_irqrestore(uaddr, &flags);
7876
7977 if (!ret)
arch/powerpc/include/asm/futex.h+2−3
@@ -35,8 +35,9 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 34 unmodified lines
3535 {
3636 int oldval = 0, ret;
3737
38+ if (!access_ok(uaddr, sizeof(u32)))
39+ return -EFAULT;
3840 allow_read_write_user(uaddr, uaddr, sizeof(*uaddr));
39− pagefault_disable();
4041
4142 switch (op) {
4243 case FUTEX_OP_SET:
@@ -58,8 +59,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 15 unmodified lines
5859 ret = -ENOSYS;
5960 }
6061
61− pagefault_enable();
62−
6362 *oval = oldval;
6463
6564 prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr));
arch/riscv/include/asm/futex.h+2−3
@@ -46,7 +46,8 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 45 unmodified lines
4646 {
4747 int oldval = 0, ret = 0;
4848
49− pagefault_disable();
49+ if (!access_ok(uaddr, sizeof(u32)))
50+ return -EFAULT;
5051
5152 switch (op) {
5253 case FUTEX_OP_SET:
@@ -73,8 +74,6 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) · 20 unmodified lines
7374 ret = -ENOSYS;
7475 }
7576
76− pagefault_enable();
77−
7877 if (!ret)
7978 *oval = oldval;
8079
arch/s390/include/asm/futex.h+0−2
@@ -29,7 +29,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 28 unmodified lines
2929 mm_segment_t old_fs;
3030
3131 old_fs = enable_sacf_uaccess();
32− pagefault_disable();
3332 switch (op) {
3433 case FUTEX_OP_SET:
3534 __futex_atomic_op("lr %2,%5\n",
@@ -54,7 +53,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 18 unmodified lines
5453 default:
5554 ret = -ENOSYS;
5655 }
57− pagefault_enable();
5856 disable_sacf_uaccess(old_fs);
5957
6058 if (!ret)
arch/sh/include/asm/futex.h+0−4
@@ -34,8 +34,6 @@ static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, · 33 unmodified lines
3434 u32 oldval, newval, prev;
3535 int ret;
3636
37− pagefault_disable();
38−
3937 do {
4038 ret = get_user(oldval, uaddr);
4139
@@ -67,8 +65,6 @@ static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, · 25 unmodified lines
6765 ret = futex_atomic_cmpxchg_inatomic(&prev, uaddr, oldval, newval);
6866 } while (!ret && prev != oldval);
6967
70− pagefault_enable();
71−
7268 if (!ret)
7369 *oval = oldval;
7470
arch/sparc/include/asm/futex_64.h+0−4
@@ -38,8 +38,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 37 unmodified lines
3838 if (unlikely((((unsigned long) uaddr) & 0x3UL)))
3939 return -EINVAL;
4040
41− pagefault_disable();
42−
4341 switch (op) {
4442 case FUTEX_OP_SET:
4543 __futex_cas_op("mov\t%4, %1", ret, oldval, uaddr, oparg);
@@ -60,8 +58,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 14 unmodified lines
6058 ret = -ENOSYS;
6159 }
6260
63− pagefault_enable();
64−
6561 if (!ret)
6662 *oval = oldval;
6763
arch/x86/include/asm/futex.h+63−36
@@ -12,76 +12,103 @@ · 11 unmodified lines
1212 #include <asm/processor.h>
1313 #include <asm/smap.h>
1414
15−#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16− asm volatile("\t" ASM_STAC "\n" \
17− "1:\t" insn "\n" \
18− "2:\t" ASM_CLAC "\n" \
15+#define unsafe_atomic_op1(insn, oval, uaddr, oparg, label) \
16+do { \
17+ int oldval = 0, ret; \
18+ asm volatile("1:\t" insn "\n" \
19+ "2:\n" \
1920 "\t.section .fixup,\"ax\"\n" \
2021 "3:\tmov\t%3, %1\n" \
2122 "\tjmp\t2b\n" \
2223 "\t.previous\n" \
2324 _ASM_EXTABLE_UA(1b, 3b) \
2425 : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
25− : "i" (-EFAULT), "0" (oparg), "1" (0))
26+ : "i" (-EFAULT), "0" (oparg), "1" (0)); \
27+ if (ret) \
28+ goto label; \
29+ *oval = oldval; \
30+} while(0)
2631
27−#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
28− asm volatile("\t" ASM_STAC "\n" \
29− "1:\tmovl %2, %0\n" \
30− "\tmovl\t%0, %3\n" \
32+
33+#define unsafe_atomic_op2(insn, oval, uaddr, oparg, label) \
34+do { \
35+ int oldval = 0, ret, tem; \
36+ asm volatile("1:\tmovl %2, %0\n" \
37+ "2:\tmovl\t%0, %3\n" \
3138 "\t" insn "\n" \
32− "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
33− "\tjnz\t1b\n" \
34− "3:\t" ASM_CLAC "\n" \
39+ "3:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
40+ "\tjnz\t2b\n" \
41+ "4:\n" \
3542 "\t.section .fixup,\"ax\"\n" \
36− "4:\tmov\t%5, %1\n" \
37− "\tjmp\t3b\n" \
43+ "5:\tmov\t%5, %1\n" \
44+ "\tjmp\t4b\n" \
3845 "\t.previous\n" \
39− _ASM_EXTABLE_UA(1b, 4b) \
40− _ASM_EXTABLE_UA(2b, 4b) \
46+ _ASM_EXTABLE_UA(1b, 5b) \
47+ _ASM_EXTABLE_UA(3b, 5b) \
4148 : "=&a" (oldval), "=&r" (ret), \
4249 "+m" (*uaddr), "=&r" (tem) \
43− : "r" (oparg), "i" (-EFAULT), "1" (0))
50+ : "r" (oparg), "i" (-EFAULT), "1" (0)); \
51+ if (ret) \
52+ goto label; \
53+ *oval = oldval; \
54+} while(0)
4455
45−static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
56+static __always_inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
4657 u32 __user *uaddr)
4758 {
48− int oldval = 0, ret, tem;
49−
50− pagefault_disable();
59+ if (!user_access_begin(uaddr, sizeof(u32)))
60+ return -EFAULT;
5161
5262 switch (op) {
5363 case FUTEX_OP_SET:
54− __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
64+ unsafe_atomic_op1("xchgl %0, %2", oval, uaddr, oparg, Efault);
5565 break;
5666 case FUTEX_OP_ADD:
57− __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
58− uaddr, oparg);
67+ unsafe_atomic_op1(LOCK_PREFIX "xaddl %0, %2", oval,
68+ uaddr, oparg, Efault);
5969 break;
6070 case FUTEX_OP_OR:
61− __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr, oparg);
71+ unsafe_atomic_op2("orl %4, %3", oval, uaddr, oparg, Efault);
6272 break;
6373 case FUTEX_OP_ANDN:
64− __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr, ~oparg);
74+ unsafe_atomic_op2("andl %4, %3", oval, uaddr, ~oparg, Efault);
6575 break;
6676 case FUTEX_OP_XOR:
67− __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr, oparg);
77+ unsafe_atomic_op2("xorl %4, %3", oval, uaddr, oparg, Efault);
6878 break;
6979 default:
70− ret = -ENOSYS;
80+ user_access_end();
81+ return -ENOSYS;
7182 }
72−
73− pagefault_enable();
74−
75− if (!ret)
76− *oval = oldval;
77−
78− return ret;
83+ user_access_end();
84+ return 0;
85+Efault:
86+ user_access_end();
87+ return -EFAULT;
7988 }
8089
8190 static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
8291 u32 oldval, u32 newval)
8392 {
84− return user_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval);
93+ int ret = 0;
94+
95+ if (!user_access_begin(uaddr, sizeof(u32)))
96+ return -EFAULT;
97+ asm volatile("\n"
98+ "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
99+ "2:\n"
100+ "\t.section .fixup, \"ax\"\n"
101+ "3:\tmov %3, %0\n"
102+ "\tjmp 2b\n"
103+ "\t.previous\n"
104+ _ASM_EXTABLE_UA(1b, 3b)
105+ : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
106+ : "i" (-EFAULT), "r" (newval), "1" (oldval)
107+ : "memory"
108+ );
109+ user_access_end();
110+ *uval = oldval;
111+ return ret;
85112 }
86113
87114 #endif
arch/x86/include/asm/uaccess.h+0−93
@@ -584,99 +584,6 @@ extern __must_check long strnlen_user(const char __user *str, long n); · 583 unmodified lines
584584 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
585585 unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
586586
587−extern void __cmpxchg_wrong_size(void)
588− __compiletime_error("Bad argument size for cmpxchg");
589−
590−#define __user_atomic_cmpxchg_inatomic(uval, ptr, old, new, size) \
591−({ \
592− int __ret = 0; \
593− __typeof__(*(ptr)) __old = (old); \
594− __typeof__(*(ptr)) __new = (new); \
595− __uaccess_begin_nospec(); \
596− switch (size) { \
597− case 1: \
598− { \
599− asm volatile("\n" \
600− "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
601− "2:\n" \
602− "\t.section .fixup, \"ax\"\n" \
603− "3:\tmov %3, %0\n" \
604− "\tjmp 2b\n" \
605− "\t.previous\n" \
606− _ASM_EXTABLE_UA(1b, 3b) \
607− : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
608− : "i" (-EFAULT), "q" (__new), "1" (__old) \
609− : "memory" \
610− ); \
611− break; \
612− } \
613− case 2: \
614− { \
615− asm volatile("\n" \
616− "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
617− "2:\n" \
618− "\t.section .fixup, \"ax\"\n" \
619− "3:\tmov %3, %0\n" \
620− "\tjmp 2b\n" \
621− "\t.previous\n" \
622− _ASM_EXTABLE_UA(1b, 3b) \
623− : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
624− : "i" (-EFAULT), "r" (__new), "1" (__old) \
625− : "memory" \
626− ); \
627− break; \
628− } \
629− case 4: \
630− { \
631− asm volatile("\n" \
632− "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
633− "2:\n" \
634− "\t.section .fixup, \"ax\"\n" \
635− "3:\tmov %3, %0\n" \
636− "\tjmp 2b\n" \
637− "\t.previous\n" \
638− _ASM_EXTABLE_UA(1b, 3b) \
639− : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
640− : "i" (-EFAULT), "r" (__new), "1" (__old) \
641− : "memory" \
642− ); \
643− break; \
644− } \
645− case 8: \
646− { \
647− if (!IS_ENABLED(CONFIG_X86_64)) \
648− __cmpxchg_wrong_size(); \
649− \
650− asm volatile("\n" \
651− "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
652− "2:\n" \
653− "\t.section .fixup, \"ax\"\n" \
654− "3:\tmov %3, %0\n" \
655− "\tjmp 2b\n" \
656− "\t.previous\n" \
657− _ASM_EXTABLE_UA(1b, 3b) \
658− : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
659− : "i" (-EFAULT), "r" (__new), "1" (__old) \
660− : "memory" \
661− ); \
662− break; \
663− } \
664− default: \
665− __cmpxchg_wrong_size(); \
666− } \
667− __uaccess_end(); \
668− *(uval) = __old; \
669− __ret; \
670−})
671−
672−#define user_atomic_cmpxchg_inatomic(uval, ptr, old, new) \
673−({ \
674− access_ok((ptr), sizeof(*(ptr))) ? \
675− __user_atomic_cmpxchg_inatomic((uval), (ptr), \
676− (old), (new), sizeof(*(ptr))) : \
677− -EFAULT; \
678−})
679−
680587 /*
681588 * movsl can be slow when source and dest are not both 8-byte aligned
682589 */
arch/xtensa/include/asm/futex.h+2−3
@@ -72,7 +72,8 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 71 unmodified lines
7272 #if XCHAL_HAVE_S32C1I || XCHAL_HAVE_EXCLUSIVE
7373 int oldval = 0, ret;
7474
75− pagefault_disable();
75+ if (!access_ok(uaddr, sizeof(u32)))
76+ return -EFAULT;
7677
7778 switch (op) {
7879 case FUTEX_OP_SET:
@@ -99,8 +100,6 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, · 20 unmodified lines
99100 ret = -ENOSYS;
100101 }
101102
102− pagefault_enable();
103−
104103 if (!ret)
105104 *oval = oldval;
106105
include/asm-generic/futex.h+0−2
@@ -34,7 +34,6 @@ arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr) · 33 unmodified lines
3434 u32 tmp;
3535
3636 preempt_disable();
37− pagefault_disable();
3837
3938 ret = -EFAULT;
4039 if (unlikely(get_user(oldval, uaddr) != 0))
@@ -67,7 +66,6 @@ arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr) · 26 unmodified lines
6766 ret = -EFAULT;
6867
6968 out_pagefault_enable:
70− pagefault_enable();
7169 preempt_enable();
7270
7371 if (ret == 0)
kernel/futex.c+2−3
@@ -1665,10 +1665,9 @@ static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr) · 1664 unmodified lines
16651665 oparg = 1 << oparg;
16661666 }
16671667
1668− if (!access_ok(uaddr, sizeof(u32)))
1669− return -EFAULT;
1670−
1668+ pagefault_disable();
16711669 ret = arch_futex_atomic_op_inuser(op, oparg, &oldval, uaddr);
1670+ pagefault_enable();
16721671 if (ret)
16731672 return ret;
16741673
tools/objtool/check.c+1−0
@@ -478,6 +478,7 @@ static const char *uaccess_safe_builtin[] = { · 477 unmodified lines
478478 "__sanitizer_cov_trace_cmp2",
479479 "__sanitizer_cov_trace_cmp4",
480480 "__sanitizer_cov_trace_cmp8",
481+ "__sanitizer_cov_trace_switch",
481482 /* UBSAN */
482483 "ubsan_type_mismatch_common",
483484 "__ubsan_handle_type_mismatch",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t