Skip to content

Commit ffa0aa5

Browse files
tobluxingomolnar
authored andcommitted
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: ce0aa5d ("x86, setup: Make the setup code also accept console=uart8250") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260713194924.126472-3-thorsten.blum@linux.dev
1 parent d130041 commit ffa0aa5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

arch/x86/boot/early_serial_console.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static unsigned int probe_baud(int port)
117117
static void parse_console_uart8250(void)
118118
{
119119
char optstr[64], *options;
120-
int baud = DEFAULT_BAUD;
120+
int baud;
121121
int port = 0;
122122

123123
/*
@@ -136,10 +136,13 @@ static void parse_console_uart8250(void)
136136
else
137137
return;
138138

139-
if (options && (options[0] == ','))
140-
baud = simple_strtoull(options + 1, &options, 0);
141-
else
139+
if (options && (options[0] == ',')) {
140+
baud = simple_strtoull(options + 1, NULL, 0);
141+
if (!baud)
142+
baud = DEFAULT_BAUD;
143+
} else {
142144
baud = probe_baud(port);
145+
}
143146

144147
if (port)
145148
early_serial_init(port, baud);

0 commit comments

Comments
 (0)