mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
Cc: Eric Biggers <ebiggers@kernel.org>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
	regressions@lists.linux.dev, kernel@collabora.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [v2 PATCH] crypto: api - Do not load modules if called by async probing
Date: Tue, 21 May 2024 10:53:18 +0800	[thread overview]
Message-ID: <ZkwMnrTR_CbXcjWe@gondor.apana.org.au> (raw)
In-Reply-To: <00bcfa65-384d-46ae-ab8b-30f12487928b@notapiano>

On Mon, May 20, 2024 at 11:49:56AM -0400, Nícolas F. R. A. Prado wrote:
>
> Unfortunately this patch didn't work either. The warning is still there
> unchanged.

OK perhaps we can do it by calling current_is_async ourselves.
But this is really a nasty hack because it basically defeats
the whole point of loading optional algorithm by module.

Linus/Tejun, is it time perhaps to remove the warning introduced
by commit 0fdff3ec6d87856cdcc99e69cf42143fdd6c56b4 since it's
been ten years since the warning caused a real problem?

For the Crypto API, if it is called by some random driver via the
async context, this warning stops us from loading any modules
without printing a nasty warning that isn't relevant as the Crypto
API never calls async_synchronize_full.

---8<---
Do not call request_module if this is the case or a warning will
be printed.

Reported-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reported-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/crypto/api.c b/crypto/api.c
index 22556907b3bc..7c4b9f86c1ad 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -10,6 +10,7 @@
  * and Nettle, by Niels Möller.
  */
 
+#include <linux/async.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/jump_label.h>
@@ -280,7 +281,8 @@ static struct crypto_alg *crypto_larval_lookup(const char *name, u32 type,
 	mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD);
 
 	alg = crypto_alg_lookup(name, type, mask);
-	if (!alg && !(mask & CRYPTO_NOLOAD)) {
+	if (!alg && !(mask & CRYPTO_NOLOAD) &&
+	    (!IS_BUILTIN(CONFIG_CRYPTO) || !current_is_async())) {
 		request_module("crypto-%s", name);
 
 		if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask &
-- 
2.39.2

-- 
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

       reply	other threads:[~2024-05-21  2:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0f68c283ff4bbb89b8a019d47891f798c6fff287.camel@HansenPartnership.com>
     [not found] ` <CAMj1kXHi4r8KY9GvX573kwqvLpMfX-J=K2hWiGAKkf5bnicwYQ@mail.gmail.com>
     [not found]   ` <0d260c2f7a9f67ec8bd2305919636678d06000d1.camel@HansenPartnership.com>
     [not found]     ` <CAMj1kXFE_R_x10BVkU+8vrMz0RHiX0+rz-ZL+w08FH2CLQHZXA@mail.gmail.com>
     [not found]       ` <66ec985f3ee229135bf748f1b0874d5367a74d7f.camel@HansenPartnership.com>
     [not found]         ` <dfb0d930-7cbe-46c5-be19-d132b4906ecf@notapiano>
     [not found]           ` <D1C2NPOBHAHK.20O4IME8OK1FH@kernel.org>
     [not found]             ` <20240518043115.GA53815@sol.localdomain>
     [not found]               ` <ZkhS1zrobNwAuANI@gondor.apana.org.au>
     [not found]                 ` <00bcfa65-384d-46ae-ab8b-30f12487928b@notapiano>
2024-05-21  2:53                   ` Herbert Xu [this message]
2024-05-21 19:37                     ` Nícolas F. R. A. Prado
2024-05-22  5:37                       ` [v3 PATCH] hwrng: core - Remove add_early_randomness Herbert Xu
2024-05-22 11:51                         ` Jarkko Sakkinen
2024-05-23  4:50                           ` Herbert Xu
2024-05-22 19:19                         ` Nícolas F. R. A. Prado
2024-05-22 22:53                         ` Linus Torvalds
2024-05-23  4:49                           ` Herbert Xu
2024-05-23  9:53                             ` Jarkko Sakkinen
2024-05-23  9:58                               ` Herbert Xu
2024-05-23 10:07                                 ` Jarkko Sakkinen
2024-05-23 10:02                               ` Jarkko Sakkinen
2024-05-23 10:40                             ` Torsten Duwe

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=ZkwMnrTR_CbXcjWe@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=ardb@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=jarkko@kernel.org \
    --cc=kernel@collabora.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfraprado@collabora.com \
    --cc=regressions@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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
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

all inboxes | Powered by JetHome®