Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Hardik Gohil <hgohil@mvista.com>
Cc: stable@vger.kernel.org, broonie@kernel.org,
	linux-spi@vger.kernel.org, u.kleine-koenig@pengutronix.de
Subject: Re: [PATCH] spi: Fix deadlock when adding SPI controllers on SPI buses
Date: Sun, 10 Nov 2024 05:56:24 +0100	[thread overview]
Message-ID: <2024111013-foster-tipped-3f12@gregkh> (raw)
In-Reply-To: <1729781771-14089-1-git-send-email-hgohil@mvista.com>

On Thu, Oct 24, 2024 at 08:26:11PM +0530, Hardik Gohil wrote:
> From: Mark Brown <broonie@kernel.org>
> 
> [ Upstream commit 6098475d4cb48d821bdf453c61118c56e26294f0 ]
> 
> Currently we have a global spi_add_lock which we take when adding new
> devices so that we can check that we're not trying to reuse a chip
> select that's already controlled.  This means that if the SPI device is
> itself a SPI controller and triggers the instantiation of further SPI
> devices we trigger a deadlock as we try to register and instantiate
> those devices while in the process of doing so for the parent controller
> and hence already holding the global spi_add_lock.  Since we only care
> about concurrency within a single SPI bus move the lock to be per
> controller, avoiding the deadlock.
> 
> This can be easily triggered in the case of spi-mux.
> 
> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Hardik Gohil <hgohil@mvista.com>
> ---
> This fix was not backported to v5.4 and 5.10
> 
> Along with this fix please also apply this fix on top of this
> 
> spi: fix use-after-free of the add_lock mutex
> commit 6c53b45c71b4920b5e62f0ea8079a1da382b9434 upstream.
> 
> Commit 6098475d4cb4 ("spi: Fix deadlock when adding SPI controllers on
> SPI buses") introduced a per-controller mutex. But mutex_unlock() of
> said lock is called after the controller is already freed:

Now both queued up, thanks.

greg k-h

  reply	other threads:[~2024-11-10  4:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24 14:56 [PATCH] spi: Fix deadlock when adding SPI controllers on SPI buses Hardik Gohil
2024-11-10  4:56 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-13 12:26 Mark Brown
2021-10-13 13:00 ` Uwe Kleine-König
2021-10-13 14:10   ` Mark Brown
2021-10-14 13:18 ` Mark Brown

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=2024111013-foster-tipped-3f12@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=broonie@kernel.org \
    --cc=hgohil@mvista.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.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