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

Andrey Chernov ache at FreeBSD.ORG
Mon Jan 30 13:26:50 UTC 2012


On Mon, Jan 30, 2012 at 11:30:15AM +0000, Mark Murray wrote:
> > Well, I almost forget about my special case: I have personal prohibition 
> > from @secteam (5 years old already) to commit anything to all RNG areas.
> > 
> > So, the question is: could anyone of you commit some version from this 
> > thread, please? 
> 
> Sure; I'll do it. Please give me your test code/cases.
> 
> > I don't insist of atomics in this sutuation, so you can peek any version 
> > you like.
> 
> I'll need to clearly see what works.

Both works:)

Version with atomic cmpsets works 100% correct, but it seems people 
dislike it just for using atomics.

Version without atomics works slightly incorrectly in edge cases, but no 
harm happens. Worst possible scenario for version without atomics:

1) Several arc4random() fired at once (i.e. concurrently) exact in 
the moment when random_yarrow_unblock() modifies this variable.

2) Such of them who catch the variable after modification and see that 
reseed is needed simultaneously put themselves into reseeding chain, 
because arc4_randomstir() is protected with mutex. There is no harm can be 
done to this PRNG by reseeding it many times sequentially, just waste of 
CPU & time.

3) Such of them who miss the modification skips this step, and PRNG will 
be reseded when any other arc4random() call happens afterwards.

The rest of arc4rand() function code is protected by mutex too, so it will 
stay sequentially-aligned in any case.

-- 
http://ache.vniz.net/


More information about the svn-src-all mailing list