linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH stable 6.6.y] arm64: kaslr: fix nokaslr cmdline parsing
@ 2025-06-03 12:52 Chen Ridong
  2025-06-04 12:38 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Ridong @ 2025-06-03 12:52 UTC (permalink / raw)
  To: catalin.marinas, will, ardb
  Cc: linux-arm-kernel, linux-kernel, stable, lujialin4, chenridong

From: Chen Ridong <chenridong@huawei.com>

Currently, when the command line contains "nokaslrxxx", it was incorrectly
treated as a request to disable KASLR virtual memory. However, the behavior
is different from physical address handling.

This issue exists before the commit af73b9a2dd39 ("arm64: kaslr: Use
feature override instead of parsing the cmdline again"). This patch 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")
Cc: stable@vger.kernel.org # <= v6.6
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 arch/arm64/kernel/pi/kaslr_early.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/pi/kaslr_early.c b/arch/arm64/kernel/pi/kaslr_early.c
index 17bff6e399e4..731d0a3f1a89 100644
--- a/arch/arm64/kernel/pi/kaslr_early.c
+++ b/arch/arm64/kernel/pi/kaslr_early.c
@@ -35,9 +35,14 @@ static char *__strstr(const char *s1, const char *s2)
 static bool cmdline_contains_nokaslr(const u8 *cmdline)
 {
 	const u8 *str;
+	size_t len = strlen("nokaslr");
+	const char *after = cmdline + len;
 
 	str = __strstr(cmdline, "nokaslr");
-	return str == cmdline || (str > cmdline && *(str - 1) == ' ');
+	if ((str == cmdline || (str > cmdline && *(str - 1) == ' ')) &&
+	    (*after == ' ' || *after == '\0'))
+		return true;
+	return false;
 }
 
 static bool is_kaslr_disabled_cmdline(void *fdt)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-04 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 12:52 [PATCH stable 6.6.y] arm64: kaslr: fix nokaslr cmdline parsing Chen Ridong
2025-06-04 12:38 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).