Skip to content

Commit ad91f66

Browse files
chleroympe
authored andcommitted
powerpc/fsl_book3e: Don't set rodata RO too early
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: d597004 ("powerpc/fsl_booke: Update of TLBCAMs after init") Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/2e35f0fd649c83c5add17a99514ac040767be93a.1652981047.git.christophe.leroy@csgroup.eu
1 parent 0ef1ffc commit ad91f66

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

arch/powerpc/mm/nohash/fsl_book3e.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,19 @@ void __init adjust_total_lowmem(void)
286286

287287
#ifdef CONFIG_STRICT_KERNEL_RWX
288288
void mmu_mark_rodata_ro(void)
289-
{
290-
/* Everything is done in mmu_mark_initmem_nx() */
291-
}
292-
#endif
293-
294-
void mmu_mark_initmem_nx(void)
295289
{
296290
unsigned long remapped;
297291

298-
if (!strict_kernel_rwx_enabled())
299-
return;
300-
301292
remapped = map_mem_in_cams(__max_low_memory, CONFIG_LOWMEM_CAM_NUM, false, false);
302293

303294
WARN_ON(__max_low_memory != remapped);
304295
}
296+
#endif
297+
298+
void mmu_mark_initmem_nx(void)
299+
{
300+
/* Everything is done in mmu_mark_rodata_ro() */
301+
}
305302

306303
void setup_initial_memory_limit(phys_addr_t first_memblock_base,
307304
phys_addr_t first_memblock_size)

0 commit comments

Comments
 (0)