aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtish Patra <[email protected]>2021-01-29 11:00:36 -0800
committerPalmer Dabbelt <[email protected]>2021-02-02 18:35:42 -0800
commitf105ea9890f42137344f8c08548c895dc9294bd8 (patch)
treef15e209e644cc6aaf11c7d6ea10b33012e97dbc8
parent2ab543823322b564f205cb15d0f0302803c87d11 (diff)
RISC-V: Fix .init section permission update
.init section permission should only updated to non-execute if STRICT_KERNEL_RWX is enabled. Otherwise, this will lead to a kernel hang. Fixes: 19a00869028f ("RISC-V: Protect all kernel sections including init early") Cc: [email protected] Suggested-by: Geert Uytterhoeven <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Atish Patra <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
-rw-r--r--arch/riscv/kernel/setup.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 3fa3f26dde85..c7c0655dd45b 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -293,6 +293,8 @@ void free_initmem(void)
unsigned long init_begin = (unsigned long)__init_begin;
unsigned long init_end = (unsigned long)__init_end;
- set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+ if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
+ set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+
free_initmem_default(POISON_FREE_INITMEM);
}