public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Changyuan Lyu <changyuanl@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexander Graf <graf@amazon.com>,
	"Mike Rapoport (Microsoft)" <rppt@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/boot/compressed: use boot_kstrtoul() for hugepages= parsing
Date: Mon, 27 Apr 2026 10:17:58 +0200	[thread overview]
Message-ID: <ae8btjiRIbgSYDGX@linux.dev> (raw)
In-Reply-To: <20260409161600.152012-2-thorsten.blum@linux.dev>

On Thu, Apr 09, 2026 at 06:15:59PM +0200, Thorsten Blum wrote:
> 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;
>  	}
>  }

Hi Boris,

Could you give this another look now that [1] is in mainline and 'val'
can no longer be NULL?

Thanks,
Thorsten

  reply	other threads:[~2026-04-27  8:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 16:15 [PATCH v2] x86/boot/compressed: use boot_kstrtoul() for hugepages= parsing Thorsten Blum
2026-04-27  8:17 ` Thorsten Blum [this message]
2026-05-04 10:14   ` Borislav Petkov
2026-05-04 10:27     ` Thorsten Blum
2026-05-04 12:14       ` Borislav Petkov
2026-05-04 12:23 ` [tip: x86/cleanups] x86/boot/compressed: Use " tip-bot2 for Thorsten Blum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae8btjiRIbgSYDGX@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=changyuanl@google.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=graf@amazon.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rppt@kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox