From: Herbert Xu <herbert@gondor.apana.org.au>
To: Sean Anderson <sean.anderson@linux.dev>
Cc: "Horia Geantă" <horia.geanta@nxp.com>,
"Pankaj Gupta" <pankaj.gupta@nxp.com>,
"Gaurav Jain" <gaurav.jain@nxp.com>,
linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org,
"Valentin Ciocoi Radulescu" <valentin.ciocoi@nxp.com>
Subject: Re: [PATCH] crypto: caam/qi - Fix drv_ctx refcount bug
Date: Wed, 9 Apr 2025 10:58:04 +0800 [thread overview]
Message-ID: <Z_XiPLmSVs8PGTZD@gondor.apana.org.au> (raw)
In-Reply-To: <e3dd2f83-8451-47b0-a774-a697b861ceb3@linux.dev>
On Tue, Apr 08, 2025 at 11:44:27AM -0400, Sean Anderson wrote:
>
> However, note that the following error is still present:
>
> [ 3.294978] alg: sig: sign test failed: invalid output
That just looks like a bug in the driver. I'll leave it in the
caam maintainers' capable hands :)
> as well as another error on reboot (present before but I forgot to post it):
>
> [ 98.514208] ------------[ cut here ]------------
> [ 98.518823] WARNING: CPU: 3 PID: 1 at crypto/algapi.c:464 crypto_unregister_alg (crypto/algapi.c:464 (discriminator 1))
> [ 98.527100] Modules linked in:
> [ 98.530153] CPU: 3 UID: 0 PID: 1 Comm: systemd-shutdow Tainted: G W 6.14.0-seco+ #163 NONE
> [ 98.539899] Tainted: [W]=WARN
> [ 98.542859] Hardware name: LS1046A RDB Board (DT)
> [ 98.547559] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [ 98.554520] pc : crypto_unregister_alg (crypto/algapi.c:464 (discriminator 1))
> [ 98.559224] lr : crypto_unregister_alg (include/linux/atomic/atomic-arch-fallback.h:457 include/linux/atomic/atomic-instrumented.h:33 include/linux/refcount.h:136 crypto/algapi.c:464)
Yes that's a long-standing design fault in the crypto_unregister
mechanism for drivers.
The unregister mechanism was designed for software crypto, so it
relied on module refcounts to prevent unregistering something
that's still in use. For hardware that follows the device model
where things get unplugged at random, this obviously doesn't work.
What I'll do is make the crypto_unregister call wait for the users
to go away. That matches how the network device unregistration works
and hopefully should solve this problem. But keep your eyes for
dead locks that used to plague netdev unregistration :)
Cheers,
--
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
next prev parent reply other threads:[~2025-04-09 3:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 23:16 [BUG] CAAM refcount warnings Sean Anderson
2025-04-08 5:17 ` [PATCH] crypto: caam/qi - Fix drv_ctx refcount bug Herbert Xu
2025-04-08 7:59 ` Horia Geanta
2025-04-08 15:44 ` Sean Anderson
2025-04-09 2:58 ` Herbert Xu [this message]
2025-04-09 3:29 ` [PATCH] crypto: api - Allow delayed algorithm destruction Herbert Xu
2025-04-10 23:24 ` Sean Anderson
2025-04-11 1:36 ` Herbert Xu
2025-04-12 5:16 ` [PATCH] crypto: api - Add support for duplicating algorithms before registration Herbert Xu
2025-04-13 16:03 ` Eric Biggers
2025-04-14 5:16 ` Herbert Xu
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=Z_XiPLmSVs8PGTZD@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=horia.geanta@nxp.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pankaj.gupta@nxp.com \
--cc=sean.anderson@linux.dev \
--cc=valentin.ciocoi@nxp.com \
/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