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>
diff --git a/crypto/fipsmodule/rand/urandom.c b/crypto/fipsmodule/rand/urandom.c
index 4923fa4..777920e 100644
--- a/crypto/fipsmodule/rand/urandom.c
+++ b/crypto/fipsmodule/rand/urandom.c
@@ -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 @@
       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 */);