|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | 2 |
|
3 | | -#include <linux/compat.h> |
4 | 3 | #include <linux/syscalls.h> |
5 | 4 | #include <linux/time_namespace.h> |
6 | 5 |
|
@@ -85,15 +84,12 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, |
85 | 84 | long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, |
86 | 85 | u32 __user *uaddr2, u32 val2, u32 val3) |
87 | 86 | { |
| 87 | + unsigned int flags = futex_to_flags(op); |
88 | 88 | int cmd = op & FUTEX_CMD_MASK; |
89 | | - unsigned int flags = 0; |
90 | 89 |
|
91 | | - if (!(op & FUTEX_PRIVATE_FLAG)) |
92 | | - flags |= FLAGS_SHARED; |
93 | | - |
94 | | - if (op & FUTEX_CLOCK_REALTIME) { |
95 | | - flags |= FLAGS_CLOCKRT; |
96 | | - if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI && |
| 90 | + if (flags & FLAGS_CLOCKRT) { |
| 91 | + if (cmd != FUTEX_WAIT_BITSET && |
| 92 | + cmd != FUTEX_WAIT_REQUEUE_PI && |
97 | 93 | cmd != FUTEX_LOCK_PI2) |
98 | 94 | return -ENOSYS; |
99 | 95 | } |
@@ -201,21 +197,19 @@ static int futex_parse_waitv(struct futex_vector *futexv, |
201 | 197 | unsigned int i; |
202 | 198 |
|
203 | 199 | for (i = 0; i < nr_futexes; i++) { |
| 200 | + unsigned int flags; |
| 201 | + |
204 | 202 | if (copy_from_user(&aux, &uwaitv[i], sizeof(aux))) |
205 | 203 | return -EFAULT; |
206 | 204 |
|
207 | 205 | if ((aux.flags & ~FUTEX2_VALID_MASK) || aux.__reserved) |
208 | 206 | return -EINVAL; |
209 | 207 |
|
210 | | - if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) { |
211 | | - if ((aux.flags & FUTEX2_SIZE_MASK) == FUTEX2_SIZE_U64) |
212 | | - return -EINVAL; |
213 | | - } |
214 | | - |
215 | | - if ((aux.flags & FUTEX2_SIZE_MASK) != FUTEX2_SIZE_U32) |
| 208 | + flags = futex2_to_flags(aux.flags); |
| 209 | + if (!futex_flags_valid(flags)) |
216 | 210 | return -EINVAL; |
217 | 211 |
|
218 | | - futexv[i].w.flags = aux.flags; |
| 212 | + futexv[i].w.flags = flags; |
219 | 213 | futexv[i].w.val = aux.val; |
220 | 214 | futexv[i].w.uaddr = aux.uaddr; |
221 | 215 | futexv[i].q = futex_q_init; |
|
0 commit comments