Re: [PATCH 1/1] crypto: jitterentropy - replace long-held spinlock with mutex
From: Haixin Xu
Date: Mon Mar 30 2026 - 09:59:47 EST
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