]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - crypto/drbg.c
crypto: drbg - replace spinlock with mutex
authorStephan Mueller <smueller@chronox.de>
Sat, 18 Apr 2015 17:36:17 +0000 (19:36 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 21 Apr 2015 01:14:45 +0000 (09:14 +0800)
commit76899a41f830d17affe6f9c58cc4b23ba26f5e00
treebd110a6cb0612d42fcbc0c70517c9be4c4eec0f6
parent082eb10ba97449a370e58f746522a4b90bcaee78
crypto: drbg - replace spinlock with mutex

The creation of a shadow copy is intended to only hold a short term
lock. But the drawback is that parallel users have a very similar DRBG
state which only differs by a high-resolution time stamp.

The DRBG will now hold a long term lock. Therefore, the lock is changed
to a mutex which implies that the DRBG can only be used in process
context.

The lock now guards the instantiation as well as the entire DRBG
generation operation. Therefore, multiple callers are fully serialized
when generating a random number.

As the locking is changed to use a long-term lock to avoid such similar
DRBG states, the entire creation and maintenance of a shadow copy can be
removed.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/drbg.c
include/crypto/drbg.h