freebsd-dev/libexec
Conrad Meyer c849485d90 random(4): Attempt to persist entropy promptly
The goal of saving entropy in Fortuna is two-fold: (1) to provide early
availability of the random device (unblocking) on next boot; and (2), to
have known, high-quality entropy available for that initial seed.  We know
it is high quality because it's output taken from Fortuna.

The FS&K paper makes it clear that Fortuna unblocks when enough bits have
been input that the output //may// be safely seeded.  But they emphasize
that the quality of various entropy sources is unknown, and a saved entropy
file is essential for both availability and ensuring initial
unpredictability.

In FreeBSD we persist entropy using two mechanisms:

1. The /etc/rc.d/random shutdown() function, which is used for ordinary
   shutdowns and reboots; and,

2. A cron job that runs every dozen minutes or so to persist new entropy, in
   case the system suffers from power loss or a crash (bypassing the
   ordinary shutdown path).

Filesystems are free to cache dirty data indefinitely, with arbitrary flush
policy.  Fsync must be used to ensure the data is persisted, especially for
the cron job save-entropy, whose entire goal is power loss and crash safe
entropy persistence.

Ordinary shutdown may not need the fsync because unmount should flush out
the dirty entropy file shortly afterwards.  But it is always possible power
loss or crash occurs during the short window after rc.d/random shutdown runs
and before the filesystem is unmounted, so the additional fsync there seems
harmless.

PR:		230876
Reviewed by:	delphij, markj, markm
Approved by:	secteam (delphij)
Differential Revision:	https://reviews.freebsd.org/D19742
2019-03-31 04:57:50 +00:00
..
atf
atrun
blacklistd-helper
bootpd bootpd: validate hardware type 2018-12-19 18:16:29 +00:00
comsat
dma
fingerd
ftpd Move ftpusers to libexec/ftpd/ 2018-08-21 17:07:52 +00:00
getty Fix potential buffer overflow and undefined behavior. 2019-01-26 20:43:28 +00:00
hyperv
mail.local
makewhatis.local makewhatis: do not try to operate on read-only mounted directories 2018-10-27 17:15:58 +00:00
mknetid
pppoed
rbootd
rc random(4): Attempt to persist entropy promptly 2019-03-31 04:57:50 +00:00
revnetgroup
rpc.rquotad
rpc.rstatd
rpc.rusersd
rpc.rwalld
rpc.sprayd
rtld-aout
rtld-elf Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
save-entropy random(4): Attempt to persist entropy promptly 2019-03-31 04:57:50 +00:00
smrsh
talkd Remove All Rights Reserved 2019-02-05 21:37:34 +00:00
tcpd
telnetd
tests
tftp-proxy
tftpd Drop "All rights reserved" from the files I own 2019-03-11 22:23:56 +00:00
ulog-helper
ypxfr
Makefile Move the rc framework out of sbin/init into libexec/rc. 2018-10-17 16:49:11 +00:00
Makefile.amd64
Makefile.i386
Makefile.inc