Skip to content

Commit f105ea9

Browse files
atishp04palmer-dabbelt
authored andcommitted
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: 19a0086 ("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]>
1 parent 2ab5438 commit f105ea9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/riscv/kernel/setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ void free_initmem(void)
293293
unsigned long init_begin = (unsigned long)__init_begin;
294294
unsigned long init_end = (unsigned long)__init_end;
295295

296-
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
296+
if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
297+
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
298+
297299
free_initmem_default(POISON_FREE_INITMEM);
298300
}

0 commit comments

Comments
 (0)