Patch "futex: Don't include process MM in futex key on no-MMU" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    futex: Don't include process MM in futex key on no-MMU

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     futex-don-t-include-process-mm-in-futex-key-on-no-mm.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 694b22e3419c65e7b189c8f495561bb82d8ae5d7
Author: Ben Wolsieffer <ben.wolsieffer@xxxxxxxxxxx>
Date:   Thu Oct 19 16:45:49 2023 -0400

    futex: Don't include process MM in futex key on no-MMU
    
    [ Upstream commit c73801ae4f22b390228ebf471d55668e824198b6 ]
    
    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 <ben.wolsieffer@xxxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
    Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Cc: Darren Hart <dvhart@xxxxxxxxxxxxx>
    Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
    Cc: André Almeida <andrealmeid@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231019204548.1236437-2-ben.wolsieffer@xxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index f10587d1d4817..f30a93e50f65e 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -248,7 +248,17 @@ int get_futex_key(u32 __user *uaddr, bool fshared, 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;
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux