* Rich Felker: > On Sat, Jul 23, 2022 at 02:39:29PM -0300, Adhemerval Zanella Netto via Libc-alpha wrote: >> On 23/07/22 13:25, Jason A. Donenfeld wrote: >> > Firstly, for what use cases does this actually help? As of recent >> > changes to the Linux kernels -- now backported all the way to 4.9! -- >> > getrandom() and /dev/urandom are extremely fast and operate over per-cpu >> > states locklessly. Sure you avoid a syscall by doing that in userspace, >> > but does it really matter? Who exactly benefits from this? >> >> Mainly performance, since glibc both export getrandom and getentropy. >> There were some discussion on maillist and we also decided to explicit >> state this is not a CSRNG on our documentation. > > This is an extreme documentation/specification bug that *hurts* > portability and security. The core contract of the historical > arc4random function is that it *is* a CSPRNG. Having a function by > that name that's allowed not to be one means now all software using it > has to add detection for the broken glibc variant. > > If the glibc implementation has flaws that actually make it not a > CSPRNG, this absolutely needs to be fixed. Not doing so is > irresponsible and will set everyone back a long ways. The core issue is that on some kernels/architectures, reading from /dev/urandom can degrade to GRND_INSECURE (approximately), and while the result is likely still unpredictable, not everyone would label that as a CSPRNG. If we document arc4random as a CSPRNG, this means that we would have to ditch the fallback code and abort the process if the getrandom system call is not available: when reading from /dev/urandom as a fallback, we have no way of knowing if we are in any of the impacted execution environments. Based on your other comments, it seems that you are interested in such fallbacks, too, but I don't think you can actually have both (CSPRNG + fallback). And then there is the certification issue. We really want applications that already use OpenSSL for other cryptography to use RAND_bytes instead of arc4random. Likewise for GNUTLS and gnutls_rnd. What should authors of those cryptographic libraries? That's less clear, and really depends on the constraints they operate in (e.g., they may target only a subset of architectures and kernel versions). Thanks, Florian