From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Petr Mladek <pmladek@suse.com>
Cc: John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <daniel.thompson@linaro.org>,
Douglas Anderson <dianders@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
kgdb-bugreport@lists.sourceforge.net,
linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: serial: kgdboc: fix mutex locking order for configure_kgdboc()
Date: Fri, 13 Jan 2023 11:32:41 +0900 [thread overview]
Message-ID: <Y8DCyU0v0OUqArab@google.com> (raw)
In-Reply-To: <Y8Ap4B75PNy5/lHo@alley>
On (23/01/12 16:40), Petr Mladek wrote:
> On Wed 2023-01-11 17:23:55, Petr Mladek wrote:
> > On Wed 2023-01-11 15:57:10, 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.
[..]
> > > - console_list_lock();
> > > -
> > > p = tty_find_polling_driver(cptr, &tty_line);
> > > if (!p) {
> > > console_list_unlock();
> >
> > This console_list_unlock() should be removed here as well.
>
> This seems to be the only problem. Otherwise, the patch looks good to
> me.
Good catch.
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
prev parent reply other threads:[~2023-01-13 2:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 14:51 [PATCH] tty: serial: kgdboc: fix mutex locking order for configure_kgdboc() John Ogness
2023-01-11 16:23 ` Petr Mladek
2023-01-12 15:40 ` Petr Mladek
2023-01-13 2:32 ` Sergey Senozhatsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8DCyU0v0OUqArab@google.com \
--to=senozhatsky@chromium.org \
--cc=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jason.wessel@windriver.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).