
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICBCH8 ---------------------------------------------------------------------- Currently, when the command line contains "nokaslrxxx", it was incorrectly treated as a request to disable KASLR. This fixes the parsing logic for the 'nokaslr' command line argument. Only the exact strings 'nokaslr' will disable KASLR. Other inputs such as 'xxnokaslr', 'xxnokaslrxx', or 'xxnokaslr=xx' will not disable KASLR. Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") Signed-off-by: Chen Ridong <chenridong@huawei.com> --- arch/arm64/kernel/kaslr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c index d612ac8ae855..513743d81f60 100644 --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c @@ -84,8 +84,9 @@ u64 __init kaslr_early_init(void) { void *fdt; u64 seed, offset, mask, module_range; - const u8 *cmdline, *str; + const u8 *cmdline, *str, *after; unsigned long raw; + int len; /* * Set a reasonable default for module_alloc_base in case @@ -116,7 +117,10 @@ u64 __init kaslr_early_init(void) */ cmdline = kaslr_get_cmdline(fdt); str = strstr(cmdline, "nokaslr"); - if (str == cmdline || (str > cmdline && *(str - 1) == ' ')) { + len = strlen("nokaslr"); + after = str + len; + if ((str == cmdline || (str > cmdline && *(str - 1) == ' ')) && + (*after == ' ' || *after == '\0')) { kaslr_status = KASLR_DISABLED_CMDLINE; return 0; } -- 2.34.1