]> Git Repo - linux.git/commitdiff
futex: Don't include process MM in futex key on no-MMU
authorBen Wolsieffer <[email protected]>
Thu, 19 Oct 2023 20:45:49 +0000 (16:45 -0400)
committerIngo Molnar <[email protected]>
Fri, 27 Oct 2023 09:53:42 +0000 (11:53 +0200)
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: 784bdf3bb694 ("futex: Assume all mappings are private on !MMU systems")
Signed-off-by: Ben Wolsieffer <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: AndrĂ© Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
kernel/futex/core.c

index ade7c731972dd5c05fb69c8c7182a62e81b7cc01..52695c59d04114350d29f1bf0403c19b873663d6 100644 (file)
@@ -252,7 +252,17 @@ int get_futex_key(u32 __user *uaddr, unsigned int flags, union futex_key *key,
         *        but access_ok() should be faster than find_vma()
         */
        if (!fshared) {
-               key->private.mm = mm;
+               /*
+                * On no-MMU, shared futexes are treated as private, therefore
+                * we must not include the current process in the key. Since
+                * there is only one address space, the address is a unique key
+                * on its own.
+                */
+               if (IS_ENABLED(CONFIG_MMU))
+                       key->private.mm = mm;
+               else
+                       key->private.mm = NULL;
+
                key->private.address = address;
                return 0;
        }
This page took 0.060373 seconds and 4 git commands to generate.