From: He Zhe <zhe...@windriver.com>

It is more secure to map module memory as not-execute at the beginning.
Memory sections that need to be executable will be turned to executable
later in complete_formation.

This is a corresponding change for ARM to the following commit
commit f2c65fb3221a ("x86/modules: Avoid breaking W^X while loading modules")

Tested with test_bpf:
test_bpf: Summary: 378 PASSED, 0 FAILED, [0/366 JIT'ed]

Signed-off-by: He Zhe <zhe...@windriver.com>
---
 arch/arm/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index deef17f..197b3b9 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -45,12 +45,12 @@ void *module_alloc(unsigned long size)
                gfp_mask |= __GFP_NOWARN;
 
        p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
-                               gfp_mask, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
+                               gfp_mask, PAGE_KERNEL, 0, NUMA_NO_NODE,
                                __builtin_return_address(0));
        if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)
                return p;
        return __vmalloc_node_range(size, 1,  VMALLOC_START, VMALLOC_END,
-                               GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
+                               GFP_KERNEL, PAGE_KERNEL, 0, NUMA_NO_NODE,
                                __builtin_return_address(0));
 }
 #endif
-- 
2.7.4

Reply via email to