]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/boot/compressed: Use boot_kstrtoul() for hugepages= parsing
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 9 Apr 2026 16:15:59 +0000 (18:15 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 4 May 2026 12:16:11 +0000 (14:16 +0200)
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@linux.dev>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260409161600.152012-2-thorsten.blum@linux.dev
arch/x86/boot/compressed/kaslr.c

index 3b0948ad449f945e5a5ebb85b16cce4166f473d5..8e4bf5365ac630177946f423337eb32f1f4e6d6e 100644 (file)
@@ -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;
        }
 }