forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/arm64/include/asm/futex.h
....@@ -1,22 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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/>.
154 */
165 #ifndef __ASM_FUTEX_H
176 #define __ASM_FUTEX_H
18
-
19
-#ifdef __KERNEL__
207
218 #include <linux/futex.h>
229 #include <linux/uaccess.h>
....@@ -29,7 +16,7 @@
2916 do { \
3017 unsigned int loops = FUTEX_MAX_LOOPS; \
3118 \
32
- uaccess_enable(); \
19
+ uaccess_enable_privileged(); \
3320 asm volatile( \
3421 " prfm pstl1strm, %2\n" \
3522 "1: ldxr %w1, %2\n" \
....@@ -52,7 +39,7 @@
5239 "+r" (loops) \
5340 : "r" (oparg), "Ir" (-EFAULT), "Ir" (-EAGAIN) \
5441 : "memory"); \
55
- uaccess_disable(); \
42
+ uaccess_disable_privileged(); \
5643 } while (0)
5744
5845 static inline int
....@@ -61,7 +48,8 @@
6148 int oldval = 0, ret, tmp;
6249 u32 __user *uaddr = __uaccess_mask_ptr(_uaddr);
6350
64
- pagefault_disable();
51
+ if (!access_ok(_uaddr, sizeof(u32)))
52
+ return -EFAULT;
6553
6654 switch (op) {
6755 case FUTEX_OP_SET:
....@@ -88,8 +76,6 @@
8876 ret = -ENOSYS;
8977 }
9078
91
- pagefault_enable();
92
-
9379 if (!ret)
9480 *oval = oldval;
9581
....@@ -105,11 +91,11 @@
10591 u32 val, tmp;
10692 u32 __user *uaddr;
10793
108
- if (!access_ok(VERIFY_WRITE, _uaddr, sizeof(u32)))
94
+ if (!access_ok(_uaddr, sizeof(u32)))
10995 return -EFAULT;
11096
11197 uaddr = __uaccess_mask_ptr(_uaddr);
112
- uaccess_enable();
98
+ uaccess_enable_privileged();
11399 asm volatile("// futex_atomic_cmpxchg_inatomic\n"
114100 " prfm pstl1strm, %2\n"
115101 "1: ldxr %w1, %2\n"
....@@ -132,7 +118,7 @@
132118 : "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp), "+r" (loops)
133119 : "r" (oldval), "r" (newval), "Ir" (-EFAULT), "Ir" (-EAGAIN)
134120 : "memory");
135
- uaccess_disable();
121
+ uaccess_disable_privileged();
136122
137123 if (!ret)
138124 *uval = val;
....@@ -140,5 +126,4 @@
140126 return ret;
141127 }
142128
143
-#endif /* __KERNEL__ */
144129 #endif /* __ASM_FUTEX_H */