[tip: x86/cleanups] x86/boot/compressed: Use boot_kstrtoul() for hugepages= parsing

From: tip-bot2 for Thorsten Blum

Date: Mon May 04 2026 - 08:23:35 EST


The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: 7b894dac26e56eb1de7a8e198af4b994c5d6da82
Gitweb: https://git.kernel.org/tip/7b894dac26e56eb1de7a8e198af4b994c5d6da82
Author: Thorsten Blum <thorsten.blum@xxxxxxxxx>
AuthorDate: Thu, 09 Apr 2026 18:15:59 +02:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Mon, 04 May 2026 14:16:11 +02:00

x86/boot/compressed: Use boot_kstrtoul() for hugepages= parsing

Replace simple_strtoull() with boot_kstrtoul() for parsing the hugepages= boot
parameter.

Unlike simple_strtoull(), boot_kstrtoul() performs strict validation and
returns an error on invalid inputs instead of silently accepting partial
input. Use boot_kstrtoul() to reject and warn about invalid hugepages= values.

boot_kstrtoul() also converts the input directly to an unsigned long and
avoids implicit casting as max_gb_huge_pages *is* an unsigned long.

[ bp: Massage commit message. ]

Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/20260409161600.152012-2-thorsten.blum@xxxxxxxxx
---
arch/x86/boot/compressed/kaslr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 3b0948a..8e4bf53 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -219,7 +219,8 @@ static void parse_gb_huge_pages(char *param, char *val)

if (!strcmp(param, "hugepages") && gbpage_sz) {
p = val;
- max_gb_huge_pages = simple_strtoull(p, &p, 0);
+ if (boot_kstrtoul(p, 0, &max_gb_huge_pages))
+ warn("Failed to parse hugepages= boot parameter\n");
return;
}
}