From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385732; b=jSZIpFyScBv/Ek6x/JSG8cJ0drD6zSabmFYaNWPYp/eslk9gf2e/iJsDiRGYKAwGCbn+ 1dv7HkKuSr7goW1aB3r9BHY5pc2sKvBSqRWbDHApfrHBksY0TVEz+OfJYWp10Aw7qXw5A 9cC2PiXVwSA/TQu7u9bcNOTdIxvVEAAS9Uh7baETX8/ge/HJFQkgtWGrAQhH61prR9IyJ Gef1jSlLvvpKxu9S77HQt2nP//h++Pmh68Q5wiQ8fpwjJsMtrGl6YkQ++p+zhOyORvRoJ oumqTbZQ/I7/VfDWCLQ3GkR/dZhhASzViapYngpQ4UgsQ6E/8eFsct2pohATnbozlUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385732; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=dRT6PNvjEK4pnT3XogR7JeSjWSbNjfx4ODovRuCPzWs=; b=SjUoUostqUMFLWwtHa9pdvA6KqKDiGL65jZoc9qpRhDuF21o+QzryxV8X0tOolNVieKL TldjDCrRg9bj8iBZLXoSOA2IswtUMc90khb6gtStJODokD5++gUjbDOcylYW9FFl7aK98 PgabxJlFzYAz68Rl00cm+595ULaTV3TGIuR+m4JHu+KJLwka8jN9BGsBTXLh1W6wJMpt0 wOiOMcW+u5TEhFl5KU1qAfS5zwRCRE692wo0v4b0zs5of9m4wt00Gp9QpZ+dTyljQ2UF3 0ELQs85X7RELPjxs3//dRNnEKl9JKSE5acDw5sEa+Nv8k6Atf3o4Yr74/L0zln5axtQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="hiTHD/g7"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E296606A322; Fri, 4 Dec 2026 12:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=hiTHD/g7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD0DB1F000CE; Fri, 4 Dec 2026 12:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385732; bh=dRT6PNvjEK4pnT3XogR7JeSjWSbNjfx4ODovRuCPzWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hiTHD/g7je1XNtzsjH53Go2IciacstIlCLzN50cP1LwpYhb3hMcNaBYdsb9ZBauYk v8gKENhKgRcgNBY5gzDQK5+dx0fOwAs3FnGefCHv7O2+dwRPAXzuKhlaT3uLK2hTaH V49gpXqKUMtW/qZQRiyXcQE18jsQBSkU3U1tta8s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Andy Shevchenko , Jiri Slaby , Heikki Krogerus , Peter Hurley , Josef Bacik Subject: [PATCH 6.6 0634/1167] serial: 8250_lpss: dont divide by 0 above 6.25 Mbaud Date: Fri, 4 Dec 2026 19:01:01 +0900 Message-ID: <20261204100718.570904196@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit 08daebfd63e9054e097eb2653eff9381de43a422 upstream. byt_set_termios() derives the clock of the UART from the baud rate in the termios, which nobody has looked at yet: fuart = baud * 16; ... fuart *= rounddown_pow_of_two(fref / fuart); ... p->uartclk = fuart; fref is 100 MHz. For a baud rate above 6250000, which BOTHER allows, fref / fuart is 0, and rounddown_pow_of_two(0) shifts 1UL by -1. On x86 that is 1UL << 63, the product with a multiple of 16 is 0, and so is uartclk. serial8250_get_baud_rate() then passes 0 for both limits, uart_get_baud_rate() finds no rate which fits, WARNs and returns 0, and uart_get_divisor() or dw8250_get_divisor() divide by 16 * 0. Everybody who may open the tty can oops the kernel with one TCSETS2. Don't ask for more than fref. The limits are those of a 100 MHz clock then, and uart_get_baud_rate() falls back to the old rate as for any other rate that the port cannot do. 8250_mid, which has the same formula, treats this case separately. Fixes: 21947ba654a6 ("serial: 8250_pci: replace switch-case by formula") Cc: stable Cc: "Ilpo Järvinen" Cc: Andy Shevchenko Cc: Jiri Slaby Cc: Heikki Krogerus Cc: Peter Hurley Signed-off-by: Josef Bacik Signed-off-by: Greg Kroah-Hartman Link: https://patch.msgid.link/20261027-tty-llm-v1-16-99b0202ae546@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_lpss.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/tty/serial/8250/8250_lpss.c +++ b/drivers/tty/serial/8250/8250_lpss.c @@ -82,6 +82,9 @@ static void byt_set_termios(struct uart_ /* Gracefully handle the B0 case: fall back to B9600 */ fuart = fuart ? fuart : 9600 * 16; + /* Fuart <= Fref: leave it to the core to refuse a higher baud rate */ + fuart = min(fuart, fref); + /* Get Fuart closer to Fref */ fuart *= rounddown_pow_of_two(fref / fuart);