Ver código fonte

Print the name of the binary when blocking in getrandom.

If a startup process blocks, it's very useful to know which it was.

Change-Id: I04dd541695a61cfceb8142ea45d4bd5e3492c6ec
Update-note: updates internal bug 117227663.
Reviewed-on: https://boringssl-review.googlesource.com/c/32544
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
kris/onging/CECPQ3_patch15
Adam Langley 6 anos atrás
committed by CQ bot account: commit-bot@chromium.org
pai
commit
dd412c428a
1 arquivos alterados com 16 adições e 5 exclusões
  1. +16
    -5
      crypto/fipsmodule/rand/urandom.c

+ 16
- 5
crypto/fipsmodule/rand/urandom.c Ver arquivo

@@ -33,6 +33,7 @@
#include <linux/random.h>
#include <sys/ioctl.h>
#endif
#include <sys/auxv.h>
#include <sys/syscall.h>
#endif

@@ -133,11 +134,21 @@ static void init_once(void) {
boringssl_getrandom(&dummy, sizeof(dummy), GRND_NONBLOCK);

if (getrandom_ret == -1 && errno == EAGAIN) {
fprintf(
stderr,
"getrandom indicates that the entropy pool has not been initialized. "
"Rather than continue with poor entropy, this process will block until "
"entropy is available.\n");
// Attempt to get the path of the current process to aid in debugging when
// something blocks.
const char *current_process = "<unknown>";
#if !defined(OPENSSL_ANDROID)
const unsigned long getauxval_ret = getauxval(AT_EXECFN);
if (getauxval_ret != 0) {
current_process = (const char *)getauxval_ret;
}
#endif

fprintf(stderr,
"%s: getrandom indicates that the entropy pool has not been "
"initialized. Rather than continue with poor entropy, this process "
"will block until entropy is available.\n",
current_process);

getrandom_ret =
boringssl_getrandom(&dummy, sizeof(dummy), 0 /* no flags */);


Carregando…
Cancelar
Salvar