lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.2105200232090.29169@angie.orcam.me.uk>
Date:   Thu, 10 Jun 2021 20:38:39 +0200 (CEST)
From:   "Maciej W. Rozycki" <macro@...am.me.uk>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>
cc:     linux-mips@...r.kernel.org, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 3/5] serial: 8250: Handle custom baud rates in UPF_MAGIC_MULTIPLIER
 range

Handle custom baud rates requested in the UPF_MAGIC_MULTIPLIER range 
with BOTHER.  Currently matching is exact, that is if a baud rate that 
is not either of clk/4 or clk/8 is requested, then we fall through to 
the default case, which will just divide the clock rate by 16 times the 
rate requested, round it to closest integer, and possibly yield even 
worse results then if clamping to the extra baud rates was chosen.

So for example if we have the usual base rate of 115200 and request a 
rate of 230399, then the fall-through divisor calculation will yield 1, 
and consequently the baud rate of 115200 will be programmed even though 
obviously the magic rate of 230400 would be more appropriate.

Make the selection of the magic rates range-qualified then and use clk/4 
for rates from clk/6 up (assuming `serial8250_get_baud_rate' has already 
rejected any rates too far beyond clk/4), and otherwise use clk/8 for 
rates from clk/12 up, and finally fall through to the standard divisor 
calculation.  Explicitly void using the undocumented rate of 153600bps 
and stick to documented divisor values only.

Signed-off-by: Maciej W. Rozycki <macro@...am.me.uk>
---
 drivers/tty/serial/8250/8250_port.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

linux-serial-8250-magic-multiplier-bother.diff
Index: linux-malta-cbus-uart/drivers/tty/serial/8250/8250_port.c
===================================================================
--- linux-malta-cbus-uart.orig/drivers/tty/serial/8250/8250_port.c
+++ linux-malta-cbus-uart/drivers/tty/serial/8250/8250_port.c
@@ -2515,6 +2515,7 @@ static unsigned int serial8250_do_get_di
 					      unsigned int baud,
 					      unsigned int *frac)
 {
+	upf_t magic_multiplier = port->flags & UPF_MAGIC_MULTIPLIER;
 	struct uart_8250_port *up = up_to_u8250p(port);
 	unsigned int quot;
 
@@ -2550,11 +2551,9 @@ static unsigned int serial8250_do_get_di
 	 * Baud Rate Generator is capable of dividing the internal PLL
 	 * clock by any divisor from 1 to 65535.
 	 */
-	if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
-	    baud == (port->uartclk/4))
+	if (magic_multiplier && baud >= port->uartclk / 6)
 		quot = 0x8001;
-	else if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
-		 baud == (port->uartclk/8))
+	else if (magic_multiplier && baud >= port->uartclk / 12)
 		quot = 0x8002;
 	else if (up->port.type == PORT_NPCM)
 		quot = npcm_get_divisor(up, baud);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ