svn commit: r230230 - head/sys/dev/random

Andrey Chernov ache at FreeBSD.ORG
Thu Jan 26 18:13:44 UTC 2012

On Thu, Jan 26, 2012 at 12:52:43PM -0500, David Schultz wrote:
> Why complicate things with atomics at all?  A race might result in
> arc4random(9) being seeded multiple times, but that's harmless.

Multiply seeding in line is harmless, just waste of time and resources.
Other case is one missing seeding when variable is set concurrently with
its read. I see no complication using atomic. Latest version is even 
shorter than previous ones.

> The race that worries me is that consumers that call arc4random()
> before it is properly seeded will get predictable numbers.  To fix
> that robustly, we'd either have to move arc4random() into the
> random module (tricky given all the places where it's used), or
> make the random module a mandatory part of the kernel.

I already vote for second option for various reasons. The problem still 
is more complicated, because arc4random() used very early in the net code
and can't wait until yarrow harvests enough entropy, especially for net 
boot cases.


More information about the svn-src-head mailing list