summaryrefslogtreecommitdiff
path: root/source/a/sysvinit-scripts/scripts/rc.S
diff options
context:
space:
mode:
authorPatrick J Volkerding <volkerdi@slackware.com>2022-04-06 20:23:46 +0000
committerEric Hameleers <alien@slackware.com>2022-04-07 06:59:44 +0200
commitbfece22130a1673e30695d7c5e563b9eace2b915 (patch)
tree41979314035e2fd0ac8460dbb7bf4ed505ad7d51 /source/a/sysvinit-scripts/scripts/rc.S
parentdc48df8960b47406124ff6c59af6d6bd54c60eb7 (diff)
downloadcurrent-bfece22130a1673e30695d7c5e563b9eace2b915.tar.gz
Wed Apr 6 20:23:46 UTC 202220220406202346
a/haveged-1.9.17-x86_64-2.txz: Rebuilt. Install /etc/rc.d/rc.haveged as non-executable. For existing installations running a recent kernel, it is safe to turn this off. Back when we added the haveged package we were using the 4.4 kernel, but since Linux 5.4 this same entropy generating algorithm has been built into the kernel, so there's no reason to also run it in userspace. We'll keep the package around (for now, anyway) in case someone might be running an old kernel. Thanks to Jason A. Donenfeld. a/sysvinit-scripts-15.0-noarch-10.txz: Rebuilt. rc.S, rc.6: use the seedrng utility to seed and initialize the kernel random number generator and generate a new seed. If seedrng is missing, we'll attempt to do these things with scripting. Thanks to Jason A. Donenfeld for hints about how to make a modest improvement in that regard (blame me for any problems with my own changes), but because you can't force the kernel RNG to initialize with a script (it needs an ioctl), you won't get the same guarantees that you do when using the new seedrng utility. a/util-linux-2.38-x86_64-2.txz: Rebuilt. Added seedrng utility, used to seed and initialize the kernel random number generator and to generate new seeds for carrying entropy across reboots. Thanks to Jason A. Donenfeld. n/libmnl-1.0.5-x86_64-1.txz: Upgraded. n/libnfnetlink-1.0.2-x86_64-1.txz: Upgraded. xap/mozilla-thunderbird-91.8.0-x86_64-1.txz: Upgraded. This release contains security fixes and improvements. For more information, see: https://www.mozilla.org/en-US/thunderbird/91.8.0/releasenotes/ https://www.mozilla.org/en-US/security/advisories/mfsa2022-15/ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1097 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-28281 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1197 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1196 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-28282 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-28285 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-28286 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24713 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-28289 (* Security fix *)
Diffstat (limited to 'source/a/sysvinit-scripts/scripts/rc.S')
-rw-r--r--source/a/sysvinit-scripts/scripts/rc.S55
1 files changed, 47 insertions, 8 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S
index 5dfa72c5..c4914061 100644
--- a/source/a/sysvinit-scripts/scripts/rc.S
+++ b/source/a/sysvinit-scripts/scripts/rc.S
@@ -463,16 +463,55 @@ if [ -x /etc/rc.d/rc.serial -a -z "$container" ]; then
fi
# Carry an entropy pool between reboots to improve randomness.
+# To do this properly, we need to utilize the "seedrng" utility, since that
+# supports the ioctls in recent kernels that allow the RNG to be initialized
+# after seeding. Otherwise using the script methods that were previously
+# recommended in the kernel source, it could take a long time for entropy
+# written to /dev/urandom to actually add to the entropy, and the new seed
+# that's output immediately afterward might actually have less entropy. This
+# would only be an issue in case a power failure occured before a proper
+# shutdown, or if a proper shutdown happened before enough time had gone by
+# to generate good entropy. We'll favor using seedrng, but if it's missing
+# (shouldn't be) then we'll fall back on using the script method.
if [ -z "$container" ]; then
+ # Make sure the new seed storage directory exists:
+ if [ ! -d /var/lib/seedrng ]; then
+ mkdir -p /var/lib/seedrng
+ chmod 700 /var/lib/seedrng
+ fi
+ # If the old /etc/random-seed exists and no seedrng-generated seeds exist,
+ # then we might as well use it for non-creditable entropy:
if [ -f /etc/random-seed ]; then
- echo "Using /etc/random-seed to initialize /dev/urandom."
- cat /etc/random-seed > /dev/urandom
+ if ! /bin/ls /var/lib/seedrng/seed.* 1> /dev/null 2> /dev/null ; then
+ echo "Moving /etc/random-seed to /var/lib/seedrng/seed.no-credit."
+ mv /etc/random-seed /var/lib/seedrng/seed.no-credit
+ chmod 400 /var/lib/seedrng/seed.no-credit
+ fi
fi
- # Use the pool size from /proc, or 4096 bits:
- if [ -r /proc/sys/kernel/random/poolsize ]; then
- dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(expr $(cat /proc/sys/kernel/random/poolsize) / 8) 2> /dev/null
- else
- dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
+ # If we have the seedrng utility, we will use it to initialize the RNG:
+ if [ -x /usr/sbin/seedrng ]; then
+ /usr/sbin/seedrng
+ else # we have to fall back on the old method:
+ if ! /bin/ls /var/lib/seedrng/seed.* 1> /dev/null 2> /dev/null ; then
+ echo "WARNING: no usable RNG seed was found in /var/lib/seedrng."
+ else
+ echo "The SeedRNG utility was not found. Seeding the RNG with an inferior method."
+ SEED="$(cat /var/lib/seedrng/seed.* | base64)"
+ rm -f /var/lib/seedrng/seed.*
+ sync /var/lib/seedrng
+ echo "$SEED" | base64 -d > /dev/urandom
+ # The seed saved below isn't going to be as large as the pool size, but
+ # it would only be used if the power fails before a proper shutdown is
+ # done. Nevertheless we'll try to get a little entropy saved from our
+ # previous seed(s) plus some bits from /dev/urandom (which *might* have
+ # some additional entropy in it). It's probably better than nothing.
+ echo "Saving a new uncreditable seed: /var/lib/seedrng/seed.no-credit"
+ {
+ head -c 512 /dev/urandom
+ echo "$SEED" | base64 -d
+ } | sha256sum | cut -d ' ' -f 1 > /var/lib/seedrng/seed.no-credit
+ chmod 400 /var/lib/seedrng/seed.no-credit
+ unset SEED
+ fi
fi
- chmod 600 /etc/random-seed
fi