From: "tip-bot2 for peterz@infradead.org" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
andrealmeid@igalia.com, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: [tip: locking/core] futex: Extend the FUTEX2 flags
Date: Thu, 21 Sep 2023 17:36:06 -0000 [thread overview]
Message-ID: <169531776622.27769.3661853983494438744.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20230921105247.617057368@noisy.programming.kicks-ass.net>
The following commit has been merged into the locking/core branch of tip:
Commit-ID: d6d08d24790e82c69a46ef78ae44fe1b1ed30775
Gitweb: https://git.kernel.org/tip/d6d08d24790e82c69a46ef78ae44fe1b1ed30775
Author: peterz@infradead.org <peterz@infradead.org>
AuthorDate: Thu, 21 Sep 2023 12:45:07 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 21 Sep 2023 19:22:05 +02:00
futex: Extend the FUTEX2 flags
Add the definition for the missing but always intended extra sizes,
and add a NUMA flag for the planned numa extention.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
Link: https://lore.kernel.org/r/20230921105247.617057368@noisy.programming.kicks-ass.net
---
include/uapi/linux/futex.h | 21 ++++++++++++++++++---
kernel/futex/syscalls.c | 9 +++++++--
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
index 21d4eff..d2ee625 100644
--- a/include/uapi/linux/futex.h
+++ b/include/uapi/linux/futex.h
@@ -45,17 +45,32 @@
/*
* Flags for futex2 syscalls.
+ *
+ * NOTE: these are not pure flags, they can also be seen as:
+ *
+ * union {
+ * u32 flags;
+ * struct {
+ * u32 size : 2,
+ * numa : 1,
+ * : 4,
+ * private : 1;
+ * };
+ * };
*/
- /* 0x00 */
- /* 0x01 */
+#define FUTEX2_SIZE_U8 0x00
+#define FUTEX2_SIZE_U16 0x01
#define FUTEX2_SIZE_U32 0x02
- /* 0x04 */
+#define FUTEX2_SIZE_U64 0x03
+#define FUTEX2_NUMA 0x04
/* 0x08 */
/* 0x10 */
/* 0x20 */
/* 0x40 */
#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG
+#define FUTEX2_SIZE_MASK 0x03
+
/* do not use */
#define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index ff696b0..953f0a4 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -183,7 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3);
}
-#define FUTEX2_VALID_MASK (FUTEX2_SIZE_U32 | FUTEX2_PRIVATE)
+#define FUTEX2_VALID_MASK (FUTEX2_SIZE_MASK | FUTEX2_PRIVATE)
/**
* futex_parse_waitv - Parse a waitv array from userspace
@@ -207,7 +207,12 @@ static int futex_parse_waitv(struct futex_vector *futexv,
if ((aux.flags & ~FUTEX2_VALID_MASK) || aux.__reserved)
return -EINVAL;
- if (!(aux.flags & FUTEX2_SIZE_U32))
+ if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) {
+ if ((aux.flags & FUTEX2_SIZE_MASK) == FUTEX2_SIZE_U64)
+ return -EINVAL;
+ }
+
+ if ((aux.flags & FUTEX2_SIZE_MASK) != FUTEX2_SIZE_U32)
return -EINVAL;
futexv[i].w.flags = aux.flags;
parent reply other threads:[~2023-09-21 20:47 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20230921105247.617057368@noisy.programming.kicks-ass.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=169531776622.27769.3661853983494438744.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=andrealmeid@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®