.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2012 ARM Ltd. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | 4 | */ |
---|
16 | 5 | #ifndef __ASM_FUTEX_H |
---|
17 | 6 | #define __ASM_FUTEX_H |
---|
18 | | - |
---|
19 | | -#ifdef __KERNEL__ |
---|
20 | 7 | |
---|
21 | 8 | #include <linux/futex.h> |
---|
22 | 9 | #include <linux/uaccess.h> |
---|
.. | .. |
---|
29 | 16 | do { \ |
---|
30 | 17 | unsigned int loops = FUTEX_MAX_LOOPS; \ |
---|
31 | 18 | \ |
---|
32 | | - uaccess_enable(); \ |
---|
| 19 | + uaccess_enable_privileged(); \ |
---|
33 | 20 | asm volatile( \ |
---|
34 | 21 | " prfm pstl1strm, %2\n" \ |
---|
35 | 22 | "1: ldxr %w1, %2\n" \ |
---|
.. | .. |
---|
52 | 39 | "+r" (loops) \ |
---|
53 | 40 | : "r" (oparg), "Ir" (-EFAULT), "Ir" (-EAGAIN) \ |
---|
54 | 41 | : "memory"); \ |
---|
55 | | - uaccess_disable(); \ |
---|
| 42 | + uaccess_disable_privileged(); \ |
---|
56 | 43 | } while (0) |
---|
57 | 44 | |
---|
58 | 45 | static inline int |
---|
.. | .. |
---|
61 | 48 | int oldval = 0, ret, tmp; |
---|
62 | 49 | u32 __user *uaddr = __uaccess_mask_ptr(_uaddr); |
---|
63 | 50 | |
---|
64 | | - pagefault_disable(); |
---|
| 51 | + if (!access_ok(_uaddr, sizeof(u32))) |
---|
| 52 | + return -EFAULT; |
---|
65 | 53 | |
---|
66 | 54 | switch (op) { |
---|
67 | 55 | case FUTEX_OP_SET: |
---|
.. | .. |
---|
88 | 76 | ret = -ENOSYS; |
---|
89 | 77 | } |
---|
90 | 78 | |
---|
91 | | - pagefault_enable(); |
---|
92 | | - |
---|
93 | 79 | if (!ret) |
---|
94 | 80 | *oval = oldval; |
---|
95 | 81 | |
---|
.. | .. |
---|
105 | 91 | u32 val, tmp; |
---|
106 | 92 | u32 __user *uaddr; |
---|
107 | 93 | |
---|
108 | | - if (!access_ok(VERIFY_WRITE, _uaddr, sizeof(u32))) |
---|
| 94 | + if (!access_ok(_uaddr, sizeof(u32))) |
---|
109 | 95 | return -EFAULT; |
---|
110 | 96 | |
---|
111 | 97 | uaddr = __uaccess_mask_ptr(_uaddr); |
---|
112 | | - uaccess_enable(); |
---|
| 98 | + uaccess_enable_privileged(); |
---|
113 | 99 | asm volatile("// futex_atomic_cmpxchg_inatomic\n" |
---|
114 | 100 | " prfm pstl1strm, %2\n" |
---|
115 | 101 | "1: ldxr %w1, %2\n" |
---|
.. | .. |
---|
132 | 118 | : "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp), "+r" (loops) |
---|
133 | 119 | : "r" (oldval), "r" (newval), "Ir" (-EFAULT), "Ir" (-EAGAIN) |
---|
134 | 120 | : "memory"); |
---|
135 | | - uaccess_disable(); |
---|
| 121 | + uaccess_disable_privileged(); |
---|
136 | 122 | |
---|
137 | 123 | if (!ret) |
---|
138 | 124 | *uval = val; |
---|
.. | .. |
---|
140 | 126 | return ret; |
---|
141 | 127 | } |
---|
142 | 128 | |
---|
143 | | -#endif /* __KERNEL__ */ |
---|
144 | 129 | #endif /* __ASM_FUTEX_H */ |
---|