Skip to content

Commit c8168b4

Browse files
tangyoulingchenhuacai
authored andcommitted
LoongArch: Automatically disable kaslr if boot from kexec_file
Automatically disable kaslr when the kernel loads from kexec_file. kexec_file loads the secondary kernel image to a non-linked address, inherently providing KASLR-like randomization. However, on LoongArch where System RAM may be non-contiguous, enabling KASLR for the second kernel may relocate it to an invalid memory region and cause a boot failure. Thus, we disable KASLR when "kexec_file" is detected in the command line. To ensure compatibility with older kernels loaded via kexec_file, this patch should be backported to stable branches. Cc: stable@vger.kernel.org Signed-off-by: Youling Tang <tangyouling@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 1bcca86 commit c8168b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/loongarch/kernel/relocate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ static inline __init bool kaslr_disabled(void)
166166
return true;
167167
#endif
168168

169+
str = strstr(boot_command_line, "kexec_file");
170+
if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
171+
return true;
172+
169173
return false;
170174
}
171175

0 commit comments

Comments
 (0)