Skip to content

Commit 894a9dd

Browse files
ofrobotsBethGriggs
authored andcommitted
deps: cherry-pick c19c5a6 from openssl upstream
Original commit message: Revert the DEVRANDOM_WAIT feature The DEVRANDOM_WAIT feature added a select() call to wait for the `/dev/random` device to become readable before reading from the `/dev/urandom` device. It was introduced in commit 38023b8 in order to mitigate the fact that the `/dev/urandom` device does not block until the initial seeding of the kernel CSPRNG has completed, contrary to the behaviour of the `getrandom()` system call. It turned out that this change had negative side effects on the performance which were not acceptable. After some discussion it was decided to revert this feature and leave it up to the OS resp. the platform maintainer to ensure a proper initialization during early boot time. Fixes 9078 This partially reverts commit 38023b8. Refs: openssl/openssl#9084 Fixes: #28932 PR-URL: #28983 Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent f025f85 commit 894a9dd

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

deps/openssl/openssl/crypto/rand/rand_unix.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -510,29 +510,6 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool)
510510
bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
511511
{
512512
size_t i;
513-
#ifdef DEVRANDOM_WAIT
514-
static int wait_done = 0;
515-
516-
/*
517-
* On some implementations reading from /dev/urandom is possible
518-
* before it is initialized. Therefore we wait for /dev/random
519-
* to be readable to make sure /dev/urandom is initialized.
520-
*/
521-
if (!wait_done && bytes_needed > 0) {
522-
int f = open(DEVRANDOM_WAIT, O_RDONLY);
523-
524-
if (f >= 0) {
525-
fd_set fds;
526-
527-
FD_ZERO(&fds);
528-
FD_SET(f, &fds);
529-
while (select(f+1, &fds, NULL, NULL, NULL) < 0
530-
&& errno == EINTR);
531-
close(f);
532-
}
533-
wait_done = 1;
534-
}
535-
#endif
536513

537514
for (i = 0; bytes_needed > 0 && i < OSSL_NELEM(random_device_paths); i++) {
538515
ssize_t bytes = 0;

deps/openssl/openssl/e_os.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
* default, we will try to read at least one of these files
2929
*/
3030
# define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom"
31-
# ifdef __linux
32-
# define DEVRANDOM_WAIT "/dev/random"
33-
# endif
3431
# endif
3532
# if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)
3633
/*

0 commit comments

Comments
 (0)