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] [day] [month] [year] [list]
Message-ID: <Yno4Eo6ZcmQRqs1B@alley>
Date:   Tue, 10 May 2022 12:01:54 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Sergey Senozhatsky <senozhatsky@...omium.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-kernel@...r.kernel.org, Andy Gross <agross@...nel.org>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        linux-arm-msm@...r.kernel.org, linux-serial@...r.kernel.org,
        Marek Szyprowski <m.szyprowski@...sung.com>
Subject: Re: [PATCH next v1] serial: msm_serial: disable interrupts in
 __msm_console_write()

On Fri 2022-05-06 23:39:24, John Ogness wrote:
> __msm_console_write() assumes that interrupts are disabled, but
> with threaded console printers it is possible that the write()
> callback of the console is called with interrupts enabled.

IMHO, it would be nice to include the lockdep splat from
https://lore.kernel.org/r/bb5cadc3-0940-7f5c-7a1b-8120ddac9039@samsung.com


> Explicitly disable interrupts using local_irq_save() to preserve
> the assumed context.
> 
> Reported-by: Marek Szyprowski <m.szyprowski@...sung.com>
> Signed-off-by: John Ogness <john.ogness@...utronix.de>

Otherwise, it looks good to me:

Reviewed-by: Petr Mladek <pmladek@...e.com>


>  Note: I checked the other serial drivers and this was the only
>        one that assumed interrupts off for write().

Great.

Best Regards,
Petr




>  drivers/tty/serial/msm_serial.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index 23c94b927776..e676ec761f18 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -1599,6 +1599,7 @@ static inline struct uart_port *msm_get_port_from_line(unsigned int line)
>  static void __msm_console_write(struct uart_port *port, const char *s,
>  				unsigned int count, bool is_uartdm)
>  {
> +	unsigned long flags;
>  	int i;
>  	int num_newlines = 0;
>  	bool replaced = false;
> @@ -1616,6 +1617,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,
>  			num_newlines++;
>  	count += num_newlines;
>  
> +	local_irq_save(flags);
> +
>  	if (port->sysrq)
>  		locked = 0;
>  	else if (oops_in_progress)
> @@ -1661,6 +1664,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,
>  
>  	if (locked)
>  		spin_unlock(&port->lock);
> +
> +	local_irq_restore(flags);
>  }
>  
>  static void msm_console_write(struct console *co, const char *s,
> 
> base-commit: 38a288f5941ef03752887ad86f2d85442358c99a
> -- 
> 2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ