From: Haixin Xu <jerryxucs@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
davem@davemloft.net, smueller@chronox.de, yifanwucs@gmail.com,
tomapufckgml@gmail.com, yuantan098@gmail.com, bird@lzu.edu.cn
Subject: Re: [PATCH 1/1] crypto: jitterentropy - replace long-held spinlock with mutex
Date: Mon, 30 Mar 2026 21:50:56 +0800 [thread overview]
Message-ID: <b2da7a03-ed78-4d2e-af5b-797bd4fa59b3@gmail.com> (raw)
In-Reply-To: <aco5ijLVPL8EjS8g@gondor.apana.org.au>
Hi Herbert,
On 3/30/26 16:51, Herbert Xu wrote:
> Are you sure that this function never gets called from softirq
> context?
Yes, for this implementation and its current call paths, I believe using
a mutex here is safe.
As `jitterentropy_rng` is not used as the generic `crypto_default_rng`
directly, i found only two users of it in tree:
1. AF_ALG RNG sockets via crypto/algif_rng.c
`_rng_recvmsg()` calls `crypto_rng_generate()` from the calling
task's syscall context.
2. DRBG seeding via crypto/drbg.c
`drbg_seed()` calls `crypto_rng_get_bytes()`, `dbrg_seed()` requires
holding `drbg->drbg_mutex`.
There are also other RNG implementations in tree that hold a mutex in
the generate function. For example:
- crypto/drbg.c uses `drbg->drbg_mutex` in `drbg_generate_long`
- drivers/crypto/qcom-rng.c uses `rng->lock` in `qcom_rng_generate`
So my reasoning is that using a mutex here should be safe.
Best regards
Haixin Xu
prev parent reply other threads:[~2026-03-30 13:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 7:23 [PATCH 0/1] crypto: jitterentropy - fix long-held spinlock contention Haixin Xu
2026-03-30 7:23 ` [PATCH 1/1] crypto: jitterentropy - replace long-held spinlock with mutex Haixin Xu
2026-03-30 7:36 ` Stephan Mueller
2026-03-30 8:51 ` Herbert Xu
2026-03-30 13:50 ` Haixin 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=b2da7a03-ed78-4d2e-af5b-797bd4fa59b3@gmail.com \
--to=jerryxucs@gmail.com \
--cc=bird@lzu.edu.cn \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=smueller@chronox.de \
--cc=tomapufckgml@gmail.com \
--cc=yifanwucs@gmail.com \
--cc=yuantan098@gmail.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