[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y8Eg1wDOOkSCAh2E@alley>
Date: Fri, 13 Jan 2023 10:13:59 +0100
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org,
Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <daniel.thompson@...aro.org>,
Douglas Anderson <dianders@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
kgdb-bugreport@...ts.sourceforge.net, linux-serial@...r.kernel.org
Subject: Re: [PATCH v2] tty: serial: kgdboc: fix mutex locking order for
configure_kgdboc()
On Thu 2023-01-12 17:18:13, John Ogness wrote:
> Several mutexes are taken while setting up console serial ports. In
> particular, the tty_port->mutex and @console_mutex are taken:
>
> serial_pnp_probe
> serial8250_register_8250_port
> uart_add_one_port (locks tty_port->mutex)
> uart_configure_port
> register_console (locks @console_mutex)
>
> In order to synchronize kgdb's tty_find_polling_driver() with
> register_console(), commit 6193bc90849a ("tty: serial: kgdboc:
> synchronize tty_find_polling_driver() and register_console()") takes
> the @console_mutex. However, this leads to the following call chain
> (with locking):
>
> platform_probe
> kgdboc_probe
> configure_kgdboc (locks @console_mutex)
> tty_find_polling_driver
> uart_poll_init (locks tty_port->mutex)
> uart_set_options
>
> This is clearly deadlock potential due to the reverse lock ordering.
>
> Since uart_set_options() requires holding @console_mutex in order to
> serialize early initialization of the serial-console lock, take the
> @console_mutex in uart_poll_init() instead of configure_kgdboc().
>
> Since configure_kgdboc() was using @console_mutex for safe traversal
> of the console list, change it to use the SRCU iterator instead.
>
> Add comments to uart_set_options() kerneldoc mentioning that it
> requires holding @console_mutex (aka the console_list_lock).
>
> Fixes: 6193bc90849a ("tty: serial: kgdboc: synchronize tty_find_polling_driver() and register_console()")
> Signed-off-by: John Ogness <john.ogness@...utronix.de>
> Reviewed-by: Petr Mladek <pmladek@...e.com>
JFYI, the patch has been committed into printk/linux.git,
branch rework/console-list-lock.
I am going to give it few days in linux-next. If there is no problem
I will send a pull request for 6.2-rc5 later the following week.
Please, let me known if you have another preference.
Best Regards,
Petr
Powered by blists - more mailing lists