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: <847c38irb4.fsf@jogness.linutronix.de>
Date: Fri, 25 Apr 2025 10:28:23 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Yunhui Cui <cuiyunhui@...edance.com>, arnd@...db.de,
 andriy.shevchenko@...ux.intel.com, benjamin.larsson@...exis.eu,
 cuiyunhui@...edance.com, gregkh@...uxfoundation.org,
 heikki.krogerus@...ux.intel.com, ilpo.jarvinen@...ux.intel.com,
 jirislaby@...nel.org, jkeeping@...usicbrands.com,
 linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
 markus.mayer@...aro.org, matt.porter@...aro.org, namcao@...utronix.de,
 paulmck@...nel.org, pmladek@...e.com, schnelle@...ux.ibm.com,
 sunilvl@...tanamicro.com, tim.kryger@...aro.org
Subject: Re: [PATCH v4 2/4] serial: 8250: introduce serial8250_discard_data()

On 2025-04-25, Yunhui Cui <cuiyunhui@...edance.com> wrote:
> To prevent triggering PSLVERR, it is necessary to check whether the
> UART_LSR_DR bit of UART_LSR is set before reading UART_RX.
> Ensure atomicity of UART_LSR and UART_RX, put serial8250_discard_data()
> under port->lock.
>
> Signed-off-by: Yunhui Cui <cuiyunhui@...edance.com>
> ---
>  drivers/tty/serial/8250/8250.h      | 15 +++++++++++
>  drivers/tty/serial/8250/8250_port.c | 42 ++++++++++++++---------------
>  2 files changed, 36 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index a913135d5217..802ac50357c0 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -2137,25 +2136,21 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits)
>  static int serial8250_get_poll_char(struct uart_port *port)
>  {
>  	struct uart_8250_port *up = up_to_u8250p(port);
> -	int status;
> +	int status = NO_POLL_CHAR;
>  	u16 lsr;
>  
>  	serial8250_rpm_get(up);
>  
> +	uart_port_lock_irqsave(port, &flags);
>  	lsr = serial_port_in(port, UART_LSR);

The ->poll_get_char() callback is used for kdb/kgdb.

Adding a spinlock here could lead to deadlock. However, I see that
serial8250_rpm_get() is already in there, which goes down a rabbit hole
of possible issues. So I guess we really don't care about possible
kdb/kgdb deadlocks for now.

I can look into cleaning this up with my next 8250 nbcon console
series. So for now, I am OK with you adding the spin_lock() in this
callback.

John Ogness

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ