Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org, stable@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Mike Gerow <gerow@google.com>
Subject: Re: [PATCH] crypto: algboss - don't wait during notifier callback
Date: Fri, 12 Jun 2020 16:48:29 +1000
Message-ID: <20200612064829.GD16987@gondor.apana.org.au> (raw)
In-Reply-To: <20200604185253.5119-1-ebiggers@kernel.org>

On Thu, Jun 04, 2020 at 11:52:53AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> When a crypto template needs to be instantiated, CRYPTO_MSG_ALG_REQUEST
> is sent to crypto_chain.  cryptomgr_schedule_probe() handles this by
> starting a thread to instantiate the template, then waiting for this
> thread to complete via crypto_larval::completion.
> 
> This can deadlock because instantiating the template may require loading
> modules, and this (apparently depending on userspace) may need to wait
> for the crc-t10dif module (lib/crc-t10dif.c) to be loaded.  But
> crc-t10dif's module_init function uses crypto_register_notifier() and
> therefore takes crypto_chain.rwsem for write.  That can't proceed until
> the notifier callback has finished, as it holds this semaphore for read.
> 
> Fix this by removing the wait on crypto_larval::completion from within
> cryptomgr_schedule_probe().  It's actually unnecessary because
> crypto_alg_mod_lookup() calls crypto_larval_wait() itself after sending
> CRYPTO_MSG_ALG_REQUEST.
> 
> This only actually became a problem in v4.20 due to commit b76377543b73
> ("crc-t10dif: Pick better transform if one becomes available"), but the
> unnecessary wait was much older.
> 
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207159
> Reported-by: Mike Gerow <gerow@google.com>
> Fixes: 398710379f51 ("crypto: algapi - Move larval completion into algboss")
> Cc: <stable@vger.kernel.org> # v3.6+
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/algboss.c | 2 --
>  1 file changed, 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      parent reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 18:52 Eric Biggers
2020-06-04 20:08 ` Eric Biggers
2020-06-12  6:48 ` Herbert Xu [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=20200612064829.GD16987@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=ebiggers@kernel.org \
    --cc=gerow@google.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    /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

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lkml.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lkml.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git