summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2026-03-26 13:35:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-02 13:09:54 +0200
commit027145ace09fad4c7cbcd6c61fe9b429c63eb0e5 (patch)
tree3568ed9ac9808075f8d573b2555ddf56d7a743aa /kernel
parent33dce5758914b5c6efe2a974581a7719b100efea (diff)
downloadlinux-027145ace09fad4c7cbcd6c61fe9b429c63eb0e5.tar.gz
linux-027145ace09fad4c7cbcd6c61fe9b429c63eb0e5.tar.bz2
linux-027145ace09fad4c7cbcd6c61fe9b429c63eb0e5.zip
futex: Require sys_futex_requeue() to have identical flags
[ Upstream commit 19f94b39058681dec64a10ebeb6f23fe7fc3f77a ] Nicholas reported that his LLM found it was possible to create a UaF when sys_futex_requeue() is used with different flags. The initial motivation for allowing different flags was the variable sized futex, but since that hasn't been merged (yet), simply mandate the flags are identical, as is the case for the old style sys_futex() requeue operations. Fixes: 0f4b5f972216 ("futex: Add sys_futex_requeue()") Reported-by: Nicholas Carlini <npc@anthropic.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/futex/syscalls.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 880c9bf2f315..99723189c8cf 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -459,6 +459,14 @@ SYSCALL_DEFINE4(futex_requeue,
if (ret)
return ret;
+ /*
+ * For now mandate both flags are identical, like the sys_futex()
+ * interface has. If/when we merge the variable sized futex support,
+ * that patch can modify this test to allow a difference in size.
+ */
+ if (futexes[0].w.flags != futexes[1].w.flags)
+ return -EINVAL;
+
cmpval = futexes[0].w.val;
return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags,