Re: [PATCH 1/1] crypto: jitterentropy - replace long-held spinlock with mutex

From: Herbert Xu

Date: Sun Apr 12 2026 - 04:52:02 EST


On Mon, Mar 30, 2026 at 03:23:46PM +0800, Haixin Xu wrote:
> jent_kcapi_random() serializes the shared jitterentropy state, but it
> currently holds a spinlock across the jent_read_entropy() call. That
> path performs expensive jitter collection and SHA3 conditioning, so
> parallel readers can trigger stalls as contending waiters spin for
> the same lock.
>
> To prevent non-preemptible lock hold, replace rng->jent_lock with a
> mutex so contended readers sleep instead of spinning on a shared lock
> held across expensive entropy generation.
>
> Fixes: bb5530e40824 ("crypto: jitterentropy - add jitterentropy RNG")
> Reported-by: Yifan Wu <yifanwucs@xxxxxxxxx>
> Reported-by: Juefei Pu <tomapufckgml@xxxxxxxxx>
> Reported-by: Yuan Tan <yuantan098@xxxxxxxxx>
> Suggested-by: Xin Liu <bird@xxxxxxxxxx>
> Signed-off-by: Haixin Xu <jerryxucs@xxxxxxxxx>
> ---
> crypto/jitterentropy-kcapi.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)

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