]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
crypto: jitterentropy - replace long-held spinlock with mutex
authorHaixin Xu <jerryxucs@gmail.com>
Mon, 30 Mar 2026 07:23:46 +0000 (15:23 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 12 Apr 2026 08:46:29 +0000 (16:46 +0800)
commit01d798e9feb30212952d4e992801ba6bd6a82351
tree49b64877c9ca26395ebc1129b4948ca9e7539808
parent06c42142cf8aaeba3fa3c4336717b87ca4eebf8a
crypto: jitterentropy - replace long-held spinlock with mutex

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@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Yuan Tan <yuantan098@gmail.com>
Suggested-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Haixin Xu <jerryxucs@gmail.com>
Reviewed-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/jitterentropy-kcapi.c