Patch "riscv: mm: Ensure prot of VM_WRITE and VM_EXEC must be readable" has been added to the 6.3-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

    riscv: mm: Ensure prot of VM_WRITE and VM_EXEC must be readable

to the 6.3-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:
     riscv-mm-ensure-prot-of-vm_write-and-vm_exec-must-be.patch
and it can be found in the queue-6.3 subdirectory.

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



commit 39e88c7b8e3250bd4d518e50dd0f988db42b6b32
Author: Hsieh-Tseng Shen <woodrow.shen@xxxxxxxxxx>
Date:   Tue Apr 25 18:28:28 2023 +0800

    riscv: mm: Ensure prot of VM_WRITE and VM_EXEC must be readable
    
    [ Upstream commit 6569fc12e442ea973d96db39e542aa19a7bc3a79 ]
    
    Commit 8aeb7b17f04e ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
    allows riscv to use mmap with PROT_WRITE only, and meanwhile mmap with w+x
    is also permitted. However, when userspace tries to access this page with
    PROT_WRITE|PROT_EXEC, which causes infinite loop at load page fault as
    well as it triggers soft lockup. According to riscv privileged spec,
    "Writable pages must also be marked readable". The fix to drop the
    `PAGE_COPY_READ_EXEC` and then `PAGE_COPY_EXEC` would be just used instead.
    This aligns the other arches (i.e arm64) for protection_map.
    
    Fixes: 8aeb7b17f04e ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
    Signed-off-by: Hsieh-Tseng Shen <woodrow.shen@xxxxxxxxxx>
    Reviewed-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230425102828.1616812-1-woodrow.shen@xxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index f641837ccf31d..05eda3281ba90 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -165,8 +165,7 @@ extern struct pt_alloc_ops pt_ops __initdata;
 					 _PAGE_EXEC | _PAGE_WRITE)
 
 #define PAGE_COPY		PAGE_READ
-#define PAGE_COPY_EXEC		PAGE_EXEC
-#define PAGE_COPY_READ_EXEC	PAGE_READ_EXEC
+#define PAGE_COPY_EXEC		PAGE_READ_EXEC
 #define PAGE_SHARED		PAGE_WRITE
 #define PAGE_SHARED_EXEC	PAGE_WRITE_EXEC
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index dc1793bf01796..309d685d70267 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -286,7 +286,7 @@ static const pgprot_t protection_map[16] = {
 	[VM_EXEC]					= PAGE_EXEC,
 	[VM_EXEC | VM_READ]				= PAGE_READ_EXEC,
 	[VM_EXEC | VM_WRITE]				= PAGE_COPY_EXEC,
-	[VM_EXEC | VM_WRITE | VM_READ]			= PAGE_COPY_READ_EXEC,
+	[VM_EXEC | VM_WRITE | VM_READ]			= PAGE_COPY_EXEC,
 	[VM_SHARED]					= PAGE_NONE,
 	[VM_SHARED | VM_READ]				= PAGE_READ,
 	[VM_SHARED | VM_WRITE]				= PAGE_SHARED,



[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