Date: Mon, 30 Jan 2012 17:26:46 +0400 From: Andrey Chernov <ache@FreeBSD.ORG> To: Mark Murray <mark@grondar.org>, Mark Murray <markm@FreeBSD.ORG> Cc: svn-src-head@FreeBSD.ORG, David Schultz <das@FreeBSD.ORG>, src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, John Baldwin <jhb@FreeBSD.ORG> Subject: Re: svn commit: r230230 - head/sys/dev/random Message-ID: <20120130132645.GA59595@vniz.net> In-Reply-To: <E1RrpR9-0006D5-To@groundzero.grondar.org> References: <E1Rny2A-000C3x-O6@groundzero.grondar.org> <20120126143819.GA88677@vniz.net> <20120126155626.GA92229@vniz.net> <201201261132.38320.jhb@freebsd.org> <20120126165521.GA92622@vniz.net> <20120126175243.GA19199@zim.MIT.EDU> <20120126181340.GA93157@vniz.net> <20120129125738.GA26520@vniz.net> <E1RrpR9-0006D5-To@groundzero.grondar.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120130132645.GA59595>