Skip to content

Commit c73801a

Browse files
lopsided98Ingo Molnar
authored and
Ingo Molnar
committed
futex: Don't include process MM in futex key on no-MMU
On no-MMU, all futexes are treated as private because there is no need to map a virtual address to physical to match the futex across processes. This doesn't quite work though, because private futexes include the current process's mm_struct as part of their key. This makes it impossible for one process to wake up a shared futex being waited on in another process. Fix this bug by excluding the mm_struct from the key. With a single address space, the futex address is already a unique key. Fixes: 784bdf3 ("futex: Assume all mappings are private on !MMU systems") Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Darren Hart <dvhart@infradead.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: André Almeida <andrealmeid@igalia.com> Link: https://lore.kernel.org/r/20231019204548.1236437-2-ben.wolsieffer@hefring.com
1 parent 184fdf9 commit c73801a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kernel/futex/core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,17 @@ int get_futex_key(u32 __user *uaddr, unsigned int flags, union futex_key *key,
252252
* but access_ok() should be faster than find_vma()
253253
*/
254254
if (!fshared) {
255-
key->private.mm = mm;
255+
/*
256+
* On no-MMU, shared futexes are treated as private, therefore
257+
* we must not include the current process in the key. Since
258+
* there is only one address space, the address is a unique key
259+
* on its own.
260+
*/
261+
if (IS_ENABLED(CONFIG_MMU))
262+
key->private.mm = mm;
263+
else
264+
key->private.mm = NULL;
265+
256266
key->private.address = address;
257267
return 0;
258268
}

0 commit comments

Comments
 (0)