]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
futex: Require sys_futex_requeue() to have identical flags
authorPeter Zijlstra <peterz@infradead.org>
Thu, 26 Mar 2026 12:35:53 +0000 (13:35 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 26 Mar 2026 15:13:48 +0000 (16:13 +0100)
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>
kernel/futex/syscalls.c

index 743c7a7282378272091c56e80acfa4f8bdde5d01..77ad9691f6a613960bdaec9e50c6a84373876dee 100644 (file)
@@ -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,