Skip to contentSkip to conversation

x86/boot: Validate console=uart8250 baud rate to avoid early boot hang

PATCH RESEND Applied Thorsten Blum 2 participants 2 messages Jul 13 – Jul 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 x86/boot: Validate console=uart8250 baud rate to avoid early boot hang

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")
---
 arch/x86/boot/early_serial_console.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/boot/early_serial_console.c +7 -4
index 023bf1c3de8b..5b83beab89e1 100644
@@ -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,10 +136,13 @@ 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)
 		early_serial_init(port, baud);
merge bot Applied
#1 lore raw

[tip: x86/urgent] x86/boot: Validate console=uart8250 baud rate to fix early boot hang

The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     ffa0aa5b625fe0bed7463ac613f8b06676ff4542
Gitweb:        https://git.kernel.org/tip/ffa0aa5b625fe0bed7463ac613f8b06676ff4542
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Mon, 13 Jul 2026 21:49:25 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 14 Jul 2026 11:01:33 +02:00

x86/boot: Validate console=uart8250 baud rate to fix early boot hang

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 "H. Peter Anvin" <[email protected]>
---
 arch/x86/boot/early_serial_console.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/boot/early_serial_console.c +7 -4
index 023bf1c..5b83bea 100644
@@ -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,10 +136,13 @@ 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)
 		early_serial_init(port, baud);