The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrew Murray" <amurray@thegoodpenguin.co.uk>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v3 2/6] printk: add bounds checking to boot_delay
Date: Sun, 12 Jul 2026 10:30:08 +0000	[thread overview]
Message-ID: <20260712103009.2071B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712-printkcleanup-v3-2-574547b8f71b@thegoodpenguin.co.uk>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The local variable `boot_delay_val` is read uninitialized when the `boot_delay` kernel parameter is passed without a value, leading to massive and unpredictable boot delays.
--

--- Patch [2]: [PATCH v3 2/6] printk: add bounds checking to boot_delay ---
commit d84630c2b1ca4df747144242cedfc7df2ff7c068
Author: Andrew Murray <amurray@thegoodpenguin.co.uk>
printk: add bounds checking to boot_delay

This commit changes the boot_delay parameter type to an unsigned int and
adds explicit bounds checking to ensure it remains within a valid range.

> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 31aabdf8248cc..8be562c9be277 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
[ ... ]
>  static int __init boot_delay_setup(char *str)
>  {
>  	unsigned long lpj;
> +	int boot_delay_val;
>  
>  	lpj = preset_lpj ? preset_lpj : 1000000;	/* some guess */
>  	loops_per_msec = (unsigned long long)lpj / 1000 * HZ;
>  
> -	get_option(&str, &boot_delay);
> -	if (boot_delay > 10 * 1000)
> -		boot_delay = 0;
> +	get_option(&str, &boot_delay_val);
> +	if (boot_delay_val < 0 || boot_delay_val > 10 * 1000)
> +		return 0;
> +
> +	boot_delay = (unsigned int)boot_delay_val;

[Severity: High]
Does this code leave boot_delay_val uninitialized if get_option() returns
early?

When the boot_delay parameter is supplied without an assigned value (for
example, just passing "boot_delay" on the kernel command line), parse_args()
and do_early_param() pass a NULL string to boot_delay_setup().

In this scenario, get_option() returns 0 immediately without writing to
boot_delay_val.

If the uninitialized stack value happens to fall between 0 and 10000, it
gets assigned to the global boot_delay. Could this cause unexpected and
massive boot delays after every printk message?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260712-printkcleanup-v3-0-574547b8f71b@thegoodpenguin.co.uk?part=2

  reply	other threads:[~2026-07-12 10:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 10:20 [PATCH v3 0/6] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-07-12 10:20 ` [PATCH v3 1/6] printk: sysctl: use unsigned int for printk_delay Andrew Murray
2026-07-12 10:20 ` [PATCH v3 2/6] printk: add bounds checking to boot_delay Andrew Murray
2026-07-12 10:30   ` sashiko-bot [this message]
2026-07-12 10:20 ` [PATCH v3 3/6] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
2026-07-12 10:20 ` [PATCH v3 4/6] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-07-12 10:20 ` [PATCH v3 5/6] printk: nbcon: move printk_delay to console emiting code Andrew Murray
2026-07-12 10:31   ` sashiko-bot
2026-07-12 10:20 ` [PATCH v3 6/6] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray
2026-07-12 10:32   ` sashiko-bot

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=20260712103009.2071B1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amurray@thegoodpenguin.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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