Re: [PATCH RESEND] x86/boot: Replace simple_strtoull in parse_gb_huge_pages
From: Thorsten Blum
Date: Mon Mar 02 2026 - 06:14:20 EST
On 1. Mar 2026, at 19:30, David Laight wrote:
> On Sun, 1 Mar 2026 11:44:54 +0100 Borislav Petkov wrote:
>> On Mon, Feb 02, 2026 at 06:32:20PM +0100, Thorsten Blum wrote:
>>> Replace simple_strtoull() with the recommended boot_kstrtoul() for
>>> parsing the 'hugepages=' boot parameter. Unlike simple_strtoull(), which
>>> returns an unsigned long long, boot_kstrtoul() converts the string
>>> directly to an unsigned long and avoids implicit casting.
>>
>> "The respective kstrtol(), kstrtoll(), kstrtoul(), and kstrtoull() functions
>> tend to be the correct replacements, though note that those require the string
>> to be NUL or newline terminated."
>>
>> Where are we making sure of that?
>>
>>> Check the return value of boot_kstrtoul() and warn about invalid values.
>>>
>>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
>>> ---
>>> arch/x86/boot/compressed/kaslr.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>> [...]
>>
>> Make that
>>
>> warn("Failed to parse hugepages= boot parameter\n");
>
> I'd suggest including the 'val' that failed to parse.
warn() isn't variadic and cannot print format arguments. We could add
another helper (e.g., warn_param()) or use error_putstr() manually, but
I'm not sure it's worth it for this case. Any other thoughts on this?
Thanks,
Thorsten