Skip to content

Commit 027145a

Browse files
Peter Zijlstragregkh
authored andcommitted
futex: Require sys_futex_requeue() to have identical flags
[ Upstream commit 19f94b3 ] 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: 0f4b5f9 ("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>
1 parent 33dce57 commit 027145a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

kernel/futex/syscalls.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,14 @@ SYSCALL_DEFINE4(futex_requeue,
459459
if (ret)
460460
return ret;
461461

462+
/*
463+
* For now mandate both flags are identical, like the sys_futex()
464+
* interface has. If/when we merge the variable sized futex support,
465+
* that patch can modify this test to allow a difference in size.
466+
*/
467+
if (futexes[0].w.flags != futexes[1].w.flags)
468+
return -EINVAL;
469+
462470
cmpval = futexes[0].w.val;
463471

464472
return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags,

0 commit comments

Comments
 (0)