public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] arm64: fix build error when use rodata_enabled
@ 2022-01-05  3:07 AliOS system security
  2022-01-05  9:21 ` Anshuman Khandual
  2022-01-05 10:22 ` [PATCH] " kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: AliOS system security @ 2022-01-05  3:07 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: linux-arm-kernel, linux-kernel, AliOS system security

rodata_enabled should be used when CONFIG_STRICT_KERNEL_RWX
or CONFIG_STRICT_MODULE_RWX is selected

Signed-off-by: AliOS system security <alios_sys_security@linux.alibaba.com>
---
 arch/arm64/mm/mmu.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index acfae9b..47f8754 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -596,6 +596,7 @@ static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end,
 	vm_area_add_early(vma);
 }
 
+#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
 static int __init parse_rodata(char *arg)
 {
 	int ret = strtobool(arg, &rodata_enabled);
@@ -613,11 +614,16 @@ static int __init parse_rodata(char *arg)
 	return 0;
 }
 early_param("rodata", parse_rodata);
+#endif
 
 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
 static int __init map_entry_trampoline(void)
 {
-	pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
+	pgprot_t prot = PAGE_KERNEL_EXEC;
+#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
+	if (rodata_enabled)
+		prot = PAGE_KERNEL_ROX;
+#endif
 	phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start);
 
 	/* The trampoline is always mapped and can therefore be global */
@@ -672,7 +678,11 @@ static void __init map_kernel(pgd_t *pgdp)
 	 * mapping to install SW breakpoints. Allow this (only) when
 	 * explicitly requested with rodata=off.
 	 */
-	pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
+	pgprot_t text_prot = PAGE_KERNEL_EXEC;
+#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
+	if (rodata_enabled)
+		text_prot = PAGE_KERNEL_ROX;
+#endif
 
 	/*
 	 * If we have a CPU that supports BTI and a kernel built for
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-05 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-05  3:07 [PATCH] arm64: fix build error when use rodata_enabled AliOS system security
2022-01-05  9:21 ` Anshuman Khandual
2022-01-05 10:47   ` Mark Rutland
     [not found]   ` <6f37012b-b082-457f-9aee-2315a461c031.alios_sys_security@linux.alibaba.com>
2022-01-05 12:48     ` 回复:[PATCH] " Anshuman Khandual
2022-01-05 10:22 ` [PATCH] " kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox