>From 18fbcd9bde20a2b6baf37a7f1bf732dd39bcf3ee Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Sun, 8 Nov 2020 19:32:53 +0300 Subject: [PATCH] Avoid randomness-related udev-induced boot stalls Those responsible for breaking udevd even further don't answer the question: why break what used to work before "improvements"? There are many architectures out there, and even those on x86 aren't really doomed to just trust Intel's hwrng. No reason to toss haveged here as we need a "show starter" here, not a service. So fill the 1024 byte long kernel enthropy pool (512*2 bytes, $RANDOM is 0..2^16-1) with good enough "seed" while getrandom() with GRND_INSECURE flag is not widely available yet (Linux 5.6+). Implemented-by: Andrey Savchenko See-also: http://systemd.io/RANDOM_SEEDS --- data/etc/rc.d/rc.sysinit | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/data/etc/rc.d/rc.sysinit b/data/etc/rc.d/rc.sysinit index e95a6fd..30726b8 100755 --- a/data/etc/rc.d/rc.sysinit +++ b/data/etc/rc.d/rc.sysinit @@ -31,3 +31,14 @@ if shell_var_is_no "$quiet"; then echo "INITRAMFS: version $VERSION_ID" } fi + +{ +# Initialize bash random seed using current time nanoseconds +# to avoid possible kernel pool usage +RANDOM=$((10#$(date "+%N") % 32768)) +for ((i=0; i<512; i++)); do + n=$RANDOM + printf "\x$(printf "%x" $((n>>8)))\x$(printf "%x" $((n%256)))" +done > /dev/random +unset i n +} & -- 2.25.4