Commit Graph

65 Commits

Author SHA1 Message Date
riastradh 8603ff52c2 Clarify wording further based on private feedback. 2021-04-06 22:02:40 +00:00
riastradh cfdaa93ec8 Clarify security model of rndctl -S files. 2021-04-06 12:32:39 +00:00
nia 9ff36a0c40 rndctl(8): to -l, add a "samples" column separate to "bits"
rename the "bits" column to "estimated bits".

this provides a clear indication when a source is being used, but
not increasing the entropy counter.

this commit fixes an unrelated bug where verbose output functioned
incorrectly when a class of device was specified with -t.

while here, reduce code duplication.

"gofer it" riastradh@
2021-04-04 13:37:17 +00:00
nia 8a1f05e369 rndctl(8): remove no-longer-useful stats from -s
these are always 0 now.

"gofer it" riastradh@
2021-04-04 12:50:31 +00:00
nia 2843dad115 rndctl: make -l's "Flags" field reflect current reality
don't print "legacy options" RND_FLAG_ESTIMATE_TIME and
"RND_FLAG_ESTIMATE_VALUE"

only print "estimate" if we have actually counted any bits from
something, since it's no longer really possible to "enable estimation".

ideally, there should also be a "samples" field so it's clear
collected bits are not being counted.
2021-04-02 07:17:56 +00:00
nia a712f2f75f rndctl.8: reflect current reality 2021-04-02 07:04:05 +00:00
simonb da20e95aa9 Whitespace alignment nits. 2020-05-12 09:48:44 +00:00
riastradh 3fb2c51c3c Trigger entropy consolidation before saving seed.
This way, whenever /etc/security runs infrequently (daily), or the
operator manually issues rndctl -S, we ensure that all samples taken
during the entire boot are hashed together in the seed for the next
boot.

This should be infrequent enough that it's unlikely to enable the
iterative-guessing attacks that we try to mitigate by not frequently
consolidating entropy.
2020-05-07 19:13:38 +00:00
riastradh c2a3429284 Rework rndctl seed load sequence again.
Go back to the book's order, now that writing to /dev/random
guarantees to consolidate entropy -- this way the _next_ boot is no
less secure than the current boot, in the event that entropy sources
like interrupt timings provided any security that we just don't know
how to measure honestly.

Make sure to open the old seed to overwrite and the new seed to write
anew first so that we can determine whether the medium is read-only
before accepting the file's entropy estimate.
2020-05-07 19:12:45 +00:00
riastradh 97603a72a0 Touch up rndctl(8) a bit. 2020-05-07 19:09:26 +00:00
wiz fecac516fe Add -i to SYNOPSIS. 2020-05-07 12:58:09 +00:00
riastradh 1e65f60a58 Tweak logic to decide whether a medium is safe for an rndseed.
- Teach rndctl to load the seed, but treat it as zero entropy, if the
  medium is read-only or if the update fails.

- Teach rndctl to accept `-i' flag instructing it to ignore the
  entropy estimate in the seed.

- Teach /etc/rc.d/random_seed to:
  (a) assume nonlocal file systems are unsafe, and use -i, but
  (b) assume / is safe, even if it is nonlocal.
  If the medium is nonwritable, leave it to rndctl to detect that.
  (Could use statvfs and check for ST_LOCAL in rndctl, I guess, but I
  already implemented it this way.)

Treating nonlocal / as safe is a compromise: it's up to the operator
to secure the network for (e.g.) nfs mounts, but that's true whether
we're talking entropy or not -- if the adversary has access to the
network that you've mounted / from, they can do a lot more damage
anyway; this reduces warning fatigue for diskless systems, e.g. test
racks.
2020-05-06 18:49:26 +00:00
riastradh 1154c4b65f Sort includes. 2020-04-30 03:27:15 +00:00
riastradh 825d46aec4 Accept both byte orders for random seed in `rndctl -L'.
The file format was defined with a machine-dependent 32-bit integer
field (the estimated number of bits of entropy in the process that
generated it).  Take whichever byte order gives a number that is
reasonable, i.e. lower than the number of bits in the buffer.

Continue to have `rndctl -S' generate it in machine-dependent byte
order for now, so that if you roll back to an older rndctl(8) then
`rndctl -L' on the same machine will still be able to load it with
the right entropy estimate.  In a future revision, perhaps we can
change it to be little-endian.
2020-04-30 03:24:48 +00:00
christos 1c0459f7c5 .include bsd.own.mk for ${NETBSDSRCDIR} 2020-01-14 23:13:36 +00:00
riastradh 5af49f98fe Teach `rndctl -L' to update the seed file, not just delete it.
The seed file is updated by entering the old seed into the system and
then hashing the old seed together with data from /dev/urandom, and
writing it atomically with write-to-temporary/rename-to-permanent.

This way, interruption by crash or power loss does not obliterate
your persistent entropy (unless it causes file system corruption).
2019-12-06 14:43:18 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
riastradh db8ca554ec Use <sys/rndio.h> instead of <sys/rnd.h>. 2015-04-13 22:18:50 +00:00
wiz d3df20dd66 Sync usage with manpage a bit more. 2014-08-10 17:13:14 +00:00
wiz 233b62b2e9 Sort options and mark them as optional.
Bump date for previous.
2014-08-10 17:13:02 +00:00
tls ea6af427bd Merge tls-earlyentropy branch into HEAD. 2014-08-10 16:44:32 +00:00
apb 81c929ad04 Overwrite the seed file from the beginning, using pwrite(2). 2014-01-15 15:05:27 +00:00
joerg 8e1ba910ea Fix arguments for write. 2014-01-15 10:13:25 +00:00
jruoho dd68a56f79 Use _PATH_URANDOM from paths(3). 2012-08-14 14:41:07 +00:00
tls 7b0b7dedd9 Entropy-pool implementation move and cleanup.
1) Move core entropy-pool code and source/sink/sample management code
   to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
   source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
   avoid expensive operations on disabled entropy sources; make the
   rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
   have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
   system events, and skew between clocks, with a sample implementation
   for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files).  Tested with release
builds on amd64 and evbarm and live testing on amd64.
2012-02-02 19:42:57 +00:00
apb d560323cc4 Make "rndctl -L" overwrite the file with zeros, not with the
same data that was just read from the file.
2011-12-17 13:18:20 +00:00
tls aae64c95c0 Make the rndsave structure public -- the kernel will learn to read it
and sysinst may learn to write it (since, on some systems, most of
the keyboard input they ever get happens to be during install).  Fix a
couple of minor problems with the random_seed rc script addition.
2011-11-26 01:17:17 +00:00
wiz 69d02ecf2f Sort option descriptions, bump date for previous. 2011-11-23 12:15:30 +00:00
tls 4924aa205a Load entropy at system boot (only works at securelevel < 1); save
at system shutdown.  Disable with random_seed=NO in rc.conf if desired.

Goes to some trouble to never load or save to network filesystems.

Entropy should really be loaded by the boot loader but I am still
sorting out how to pass it to the kernel.
2011-11-23 10:47:48 +00:00
pgoyette 0b5ef36c08 Fix typo 2011-10-01 02:55:00 +00:00
joerg fdbae3b9b7 static + const + __dead 2011-08-27 18:48:59 +00:00
lukem 7b61bfdc7c fix sign-compare issues 2009-04-05 12:06:33 +00:00
apb cf9d39220a Add a list of device types for use with "rndctl -t ${typename}". 2009-01-04 12:01:43 +00:00
apb 88ba92672f * Instead of silently ignoring extra args, print a usage error. This
adddresses the silent failure reported in PR 39862 by Brian A. Seklecki
* Adjust usage message to match the synopsis in the man page.
2008-11-06 16:01:54 +00:00
apb 046bb95d46 Adjust synopsis and description to make it clear that -d devname and
-t devtype are mutually exclusive.
2008-11-06 15:58:16 +00:00
christos 2c6eadc9ce Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
2005-06-27 01:00:04 +00:00
itojun b5bc655b98 strlcat 2003-07-13 07:59:24 +00:00
agc c2a3b5ec84 Add NetBSD RCS Ids. 2003-06-23 11:53:35 +00:00
itojun 262bdee727 do not hardcode buffer size 2003-05-17 23:16:47 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
wiz 09cbac4e7f New sentence, new line. From Robert Elz. 2002-10-03 15:41:44 +00:00
wiz 90158afe92 Sort options. Fix grammar. Use more mdoc. 2002-10-01 14:39:51 +00:00
gmcgarry a104b7da81 Type 'network' was an alias for 'net' and was changed to "net" in
rev 1.5.  Remove duplicate.  Reported by Christian Biere in PR17976.
2002-08-18 23:45:48 +00:00
enami 1fd6d975ac Since all members in rndpoolstat_t are unsigned, print them so. PR#14584. 2002-05-19 09:47:10 +00:00
ross dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
wiz e8e51dce31 Sort sections, use standard headers, sort SEE ALSO. 2001-11-16 12:08:19 +00:00
wiz 4ce43ae0cd Whitespace nits 2001-11-16 10:25:42 +00:00
enami 36c88aab99 - Recognize new type `rng'.
- Use getprogname().
2001-09-11 05:52:37 +00:00
enami db33b671a9 Don't punt on really unknown type of device when fetching name of it.
Instead, warn and just print it as ???.
2001-09-08 23:29:05 +00:00
enami d5b9e6ab8a Cosmetic changes. 2001-09-08 23:20:37 +00:00