Patch "powerpc/fsl_book3e: Don't set rodata RO too early" has been added to the 5.18-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

    powerpc/fsl_book3e: Don't set rodata RO too early

to the 5.18-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:
     powerpc-fsl_book3e-don-t-set-rodata-ro-too-early.patch
and it can be found in the queue-5.18 subdirectory.

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



commit ee53f9372e03ea9ff1fbf56b9862e2e056afd601
Author: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
Date:   Thu May 19 19:24:15 2022 +0200

    powerpc/fsl_book3e: Don't set rodata RO too early
    
    [ Upstream commit ad91f66f5fa7c6f9346e721c3159ce818568028b ]
    
    On fsl_book3e, rodata is set read-only at the same time as
    init text is set NX at the end of init. That's too early.
    
    As both action are performed at the same time, delay both
    actions to the time rodata is expected to be made read-only.
    
    It means we will have a small window with init mem freed but
    still executable. It shouldn't be an issue though, especially
    because the said memory gets poisoned and should therefore
    result to a bad instruction fault in case it gets executed.
    
    mmu_mark_initmem_nx() is bailing out before doing anything when
    CONFIG_STRICT_KERNEL_RWX is not selected or rodata_enabled is false.
    
    mmu_mark_rodata_ro() is called only when CONFIG_STRICT_KERNEL_RWX
    is selected and rodata_enabled is true so this is equivalent.
    
    Move code from mmu_mark_initmem_nx() into mmu_mark_rodata_ro() and
    remove the call to strict_kernel_rwx_enabled() which is not needed
    anymore.
    
    Fixes: d5970045cf9e ("powerpc/fsl_booke: Update of TLBCAMs after init")
    Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Tested-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/2e35f0fd649c83c5add17a99514ac040767be93a.1652981047.git.christophe.leroy@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/mm/nohash/fsl_book3e.c b/arch/powerpc/mm/nohash/fsl_book3e.c
index dfe715e0f70a..388f7c7dabd3 100644
--- a/arch/powerpc/mm/nohash/fsl_book3e.c
+++ b/arch/powerpc/mm/nohash/fsl_book3e.c
@@ -287,22 +287,19 @@ void __init adjust_total_lowmem(void)
 
 #ifdef CONFIG_STRICT_KERNEL_RWX
 void mmu_mark_rodata_ro(void)
-{
-	/* Everything is done in mmu_mark_initmem_nx() */
-}
-#endif
-
-void mmu_mark_initmem_nx(void)
 {
 	unsigned long remapped;
 
-	if (!strict_kernel_rwx_enabled())
-		return;
-
 	remapped = map_mem_in_cams(__max_low_memory, CONFIG_LOWMEM_CAM_NUM, false, false);
 
 	WARN_ON(__max_low_memory != remapped);
 }
+#endif
+
+void mmu_mark_initmem_nx(void)
+{
+	/* Everything is done in mmu_mark_rodata_ro() */
+}
 
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
 				phys_addr_t first_memblock_size)



[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