From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 475D43D8910 for ; Thu, 14 May 2026 14:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778769068; cv=none; b=pYc4NRBLK0eb61Hhu8KqmXzh4cyI1zNtDls65eQfD62qIGqb/qYKukgLuXnXXcb4OTOJLobNb0qWfcroPd+4QWc9VDfYNa8ruVMgWM9uyR6D/VbPqW2cuXsfN98t6y3VHobjRx4BFRzjN/clyM2ZI1Zysms5r6O4cNvd8hOREc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778769068; c=relaxed/simple; bh=YyWaZMeiJz9T5X4EUNvY6ADsp4aJr7uTDn7N6DZe6RU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UHSkSisDZ3p7WYx7YG2iw1KpwGgDOkwC5rE05DaJ3aM3D83j+SeVI0kbnKd3/5sYsHnOAmt2wBXPrIqPFvc4ZQja/kmIyjZS7T+nBkBsmG88D8/343A56JLV+xD4ieSHrKif/vx8DYD90RRguBTEXElCeS4w06P5tBNr9FEGZI4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PdtbCsXA; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PdtbCsXA" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778769065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0PjiDFNRvDjNvFgEga9MgPvmaO5o63mGNwkS79Mluow=; b=PdtbCsXA12Gkq6L3hTdX6JBUToS00HIJtduGODTT0haoxSppG43+sL9QmCYl4lQUmyIX8b +Sq+cZ/Tps6umikht/yOYZG+0WpY03SNb09fzJSRp2r7/c6n6/NKDCMmYsobcVmRxhvbhb AQz3OAfA/qqH/lHmCvRZc37ctbrES5k= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Pekka Enberg , Yinghai Lu Cc: Thorsten Blum , stable@vger.kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] x86/boot: validate console=uart8250 baud rate to avoid early boot hang Date: Thu, 14 May 2026 16:30:15 +0200 Message-ID: <20260514143014.516303-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1358; i=thorsten.blum@linux.dev; h=from:subject; bh=YyWaZMeiJz9T5X4EUNvY6ADsp4aJr7uTDn7N6DZe6RU=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFmsd8pEv8/X7bj3+Lvvli8e9T3hRrPakthOmvllrIkSa +9+G3mvo5SFQYyLQVZMkeXBrB8zfEtrKjeZROyEmcPKBDKEgYtTACYSFc/wv+KXxJ/nlidqJ9xL iGtsXbMuVk7QmvNJjTDfpmjDrFseOxn+V6pm2j16cvCW2IWHmRwNb4180/u087z+8qzbnKkaJaX ACgA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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)