Blame SOURCES/chrony-getrandom.patch

dabfaa
commit 7c5bd948bb7e21fa0ee22f29e97748b2d0360319
dabfaa
Author: Miroslav Lichvar <mlichvar@redhat.com>
dabfaa
Date:   Thu May 17 14:16:58 2018 +0200
dabfaa
dabfaa
    util: fall back to reading /dev/urandom when getrandom() blocks
dabfaa
    
dabfaa
    With recent changes in the Linux kernel, the getrandom() system call may
dabfaa
    block for a long time after boot on machines that don't have enough
dabfaa
    entropy. It blocks the chronyd's initialization before it can detach
dabfaa
    from the terminal and may cause a chronyd service to fail to start due
dabfaa
    to a timeout.
dabfaa
    
dabfaa
    At least for now, enable the GRND_NONBLOCK flag to make the system call
dabfaa
    non-blocking and let the code fall back to reading /dev/urandom (which
dabfaa
    never blocks) if the system call failed with EAGAIN or any other error.
dabfaa
    
dabfaa
    This makes the start of chronyd non-deterministic with respect to files
dabfaa
    that it needs to open and possibly also makes it slightly easier to
dabfaa
    guess the transmit/receive timestamp in client requests until the
dabfaa
    urandom source is fully initialized.
dabfaa
dabfaa
diff --git a/util.c b/util.c
dabfaa
index 4b3e455..76417d5 100644
dabfaa
--- a/util.c
dabfaa
+++ b/util.c
dabfaa
@@ -1224,7 +1224,7 @@ get_random_bytes_getrandom(char *buf, unsigned int len)
dabfaa
       if (disabled)
dabfaa
         break;
dabfaa
 
dabfaa
-      if (getrandom(rand_buf, sizeof (rand_buf), 0) != sizeof (rand_buf)) {
dabfaa
+      if (getrandom(rand_buf, sizeof (rand_buf), GRND_NONBLOCK) != sizeof (rand_buf)) {
dabfaa
         disabled = 1;
dabfaa
         break;
dabfaa
       }