public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/boot/compressed: use boot_kstrtoul() for hugepages= parsing
@ 2026-04-09 16:15 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-04-09 16:15 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Changyuan Lyu, Andrew Morton, Alexander Graf,
	Mike Rapoport (Microsoft)
  Cc: Thorsten Blum, linux-kernel

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.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Adjust warning message (Boris)
- The value pointer cannot be NULL after [1] has been applied (Boris)
- Update patch subject and description
- Link to v1: https://lore.kernel.org/lkml/20260202173223.865709-1-thorsten.blum@linux.dev/

[1] https://lore.kernel.org/lkml/20260409105437.108686-4-thorsten.blum@linux.dev/
---
 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 3b0948ad449f..8e4bf5365ac6 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;
 	}
 }

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-09 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-09 16:15 [PATCH v2] x86/boot/compressed: use boot_kstrtoul() for hugepages= parsing Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox