The Linux Kernel Mailing List
 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>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Yinghai Lu <yinghai@kernel.org>
Cc: stable@vger.kernel.org, "H. Peter Anvin" <hpa@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/boot: validate console=uart8250 baud rate to avoid early boot hang
Date: Thu, 28 May 2026 02:27:32 +0200	[thread overview]
Message-ID: <aheL9BylYvUm_6cP@linux.dev> (raw)
In-Reply-To: <20260514143014.516303-3-thorsten.blum@linux.dev>

On Thu, May 14, 2026 at 04:30:15PM +0200, Thorsten Blum wrote:
> When the baud rate is empty, 0, invalid, or overflows to 0 when stored
> as an int, the system will hang during early boot because of a division
> by zero in early_serial_init().
> 
> Fall back to DEFAULT_BAUD when the resulting baud rate is 0 to prevent
> an early system hang.
> 
> Fixes: ce0aa5dd20e4 ("x86, setup: Make the setup code also accept console=uart8250")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/x86/boot/early_serial_console.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
> index 023bf1c3de8b..28a887af430d 100644
> --- a/arch/x86/boot/early_serial_console.c
> +++ b/arch/x86/boot/early_serial_console.c
> @@ -117,7 +117,7 @@ static unsigned int probe_baud(int port)
>  static void parse_console_uart8250(void)
>  {
>  	char optstr[64], *options;
> -	int baud = DEFAULT_BAUD;
> +	int baud;
>  	int port = 0;
>  
>  	/*
> @@ -136,9 +136,11 @@ static void parse_console_uart8250(void)
>  	else
>  		return;
>  
> -	if (options && (options[0] == ','))
> -		baud = simple_strtoull(options + 1, &options, 0);
> -	else
> +	if (options && (options[0] == ',')) {
> +		baud = simple_strtoull(options + 1, NULL, 0);
> +		if (!baud)
> +			baud = DEFAULT_BAUD;
> +	} else
>  		baud = probe_baud(port);
>  
>  	if (port)

Gentle ping?

I also tested this and verified that it works.

      reply	other threads:[~2026-05-28  0:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 14:30 [PATCH] x86/boot: validate console=uart8250 baud rate to avoid early boot hang Thorsten Blum
2026-05-28  0:27 ` Thorsten Blum [this message]

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=aheL9BylYvUm_6cP@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=yinghai@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