Skip to content

Commit 4923954

Browse files
futex: Clarify FUTEX2 flags
sys_futex_waitv() is part of the futex2 series (the first and only so far) of syscalls and has a flags field per futex (as opposed to flags being encoded in the futex op). This new flags field has a new namespace, which unfortunately isn't super explicit. Notably it currently takes FUTEX_32 and FUTEX_PRIVATE_FLAG. Introduce the FUTEX2 namespace to clarify this Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Reviewed-by: André Almeida <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c6f4a90 commit 4923954

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

include/uapi/linux/futex.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,20 @@
4444
FUTEX_PRIVATE_FLAG)
4545

4646
/*
47-
* Flags to specify the bit length of the futex word for futex2 syscalls.
48-
* Currently, only 32 is supported.
47+
* Flags for futex2 syscalls.
4948
*/
50-
#define FUTEX_32 2
49+
/* 0x00 */
50+
/* 0x01 */
51+
#define FUTEX2_SIZE_U32 0x02
52+
/* 0x04 */
53+
/* 0x08 */
54+
/* 0x10 */
55+
/* 0x20 */
56+
/* 0x40 */
57+
#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG
58+
59+
/* do not use */
60+
#define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */
5161

5262
/*
5363
* Max numbers of elements in a futex_waitv array

kernel/futex/syscalls.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
183183
return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3);
184184
}
185185

186-
/* Mask of available flags for each futex in futex_waitv list */
187-
#define FUTEXV_WAITER_MASK (FUTEX_32 | FUTEX_PRIVATE_FLAG)
186+
#define FUTEX2_VALID_MASK (FUTEX2_SIZE_U32 | FUTEX2_PRIVATE)
188187

189188
/**
190189
* futex_parse_waitv - Parse a waitv array from userspace
@@ -205,10 +204,10 @@ static int futex_parse_waitv(struct futex_vector *futexv,
205204
if (copy_from_user(&aux, &uwaitv[i], sizeof(aux)))
206205
return -EFAULT;
207206

208-
if ((aux.flags & ~FUTEXV_WAITER_MASK) || aux.__reserved)
207+
if ((aux.flags & ~FUTEX2_VALID_MASK) || aux.__reserved)
209208
return -EINVAL;
210209

211-
if (!(aux.flags & FUTEX_32))
210+
if (!(aux.flags & FUTEX2_SIZE_U32))
212211
return -EINVAL;
213212

214213
futexv[i].w.flags = aux.flags;

0 commit comments

Comments
 (0)