Re: [PATCH] crypto: drbg - convert to guard(mutex)

From: Herbert Xu

Date: Mon Mar 02 2026 - 07:25:26 EST


On Sun, Mar 01, 2026 at 05:16:24PM +0530, Rajveer Chaudhari wrote:
>
> Yes, this is safe. I traced through all functions called by
> drbg_uninstantiate():

Even if it happens to be safe we still shouldn't do it unless it is
actually required for correctness. We've had many dead-locks
caused by freeing resources while holding a mutex used for
allocation.

> In fact, holding the mutex during drbg_uninstantiate() is
> more correct than the original, as it prevents another thread from
> accessing the drbg state while it is being freed on the error path.

It's either correct or not. If the mutex is required for
freeing resources please point out the race condition without
it.

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