[PATCH OLK-5.10] arm64: kaslr: fix nokaslr cmdline parsing

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

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/16860 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/ZP5... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/16860 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/ZP5...
participants (2)
-
Chen Ridong
-
patchwork bot