s390/ftrace: do not assume module_alloc() returns executable memory
authorHeiko Carstens <hca@linux.ibm.com>
Sun, 2 Apr 2023 18:55:19 +0000 (20:55 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 13 Apr 2023 15:36:26 +0000 (17:36 +0200)
The ftrace code assumes at two places that module_alloc() returns
executable memory. While this is currently true, this will be changed
with a subsequent patch to follow other architectures which implement
ARCH_HAS_STRICT_MODULE_RWX.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/ftrace.c
arch/s390/kernel/module.c

index 6f6c44b7af89690e4524eef59cc190aa2daf8f33..c46381ea04ecb1328e9f06d186ca1aa65ce07a34 100644 (file)
@@ -226,7 +226,7 @@ static int __init ftrace_plt_init(void)
 
        start = ftrace_shared_hotpatch_trampoline(&end);
        memcpy(ftrace_plt, start, end - start);
-       set_memory_ro((unsigned long)ftrace_plt, 1);
+       set_memory_rox((unsigned long)ftrace_plt, 1);
        return 0;
 }
 device_initcall(ftrace_plt_init);
index 6588f4efe378b14e2fcb3e19d55d131174ab3acd..57c13e30e66d339c47677f12df5b46943fc28b70 100644 (file)
@@ -509,7 +509,7 @@ static int module_alloc_ftrace_hotpatch_trampolines(struct module *me,
        start = module_alloc(numpages * PAGE_SIZE);
        if (!start)
                return -ENOMEM;
-       set_memory_ro((unsigned long)start, numpages);
+       set_memory_rox((unsigned long)start, numpages);
        end = start + size;
 
        me->arch.trampolines_start = (struct ftrace_hotpatch_trampoline *)start;