random: identify lockless and lock-protected data

Signed-off-by: Greg Price <price@mit.edu>
DRAFT random: prevent starvation of urandom and kernel randomness

Since v2.6.12 ("random: Reservation flag in pool struct", 2fb4f725e in
tglx's history repo) we ensure that no matter how much is read from
nonblocking_pool (through /dev/urandom and the kernel's internal use),
blocking_pool aka /dev/random will not be starved of entropy.  But the
reverse isn't true: if userspace draws from /dev/random, it can starve
/dev/urandom and the kernel of reseeds from the input pool.

This commit divides the entropy in the input pool into entropy
reserved for each output pool and (implicitly) entropy not reserved.
Incoming entropy is divided evenly between the reserves, up to the
maximum reserved.  Each output pool draws first from its own reserve,
then from the unreserved entropy.  The effect is that if both output
pools are busy, they each get half the input entropy, and if only one
is busy it can use all but the limited amount reserved for the other.

In principle the natural place for this accounting might be
credit_entropy_bits(), but it's convenient to use the lock to keep
things straightforward.  So we do it in account(), out of the
interrupt path.
random: count only catastrophic reseed as initializing pool

If the pool has received only small amounts of entropy at a time,
then its randomness is potentially compromised if an attacker has
been able to see some of the output in between those inputs, no
matter how much the total of all the inputs comes to.  So as long
as we're in that state, we can use all the help we can get.

Previously we waited for 129 total bits across potentially many
small inputs; now we wait for 64 bits (by default) in one input,
which is the minimum reseed size as set in xfer_secondary_pool.

At present this controls only where add_interrupt_randomness mixes
its input, but we'll also it to make /dev/urandom block at boot
until initialized.

Signed-off-by: Greg Price <price@mit.edu>
DRAFT random: block /dev/urandom until seeded