From owner-svn-src-head@FreeBSD.ORG Mon Jan 30 13:26:50 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 396521065676; Mon, 30 Jan 2012 13:26:50 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 98A5F8FC0C; Mon, 30 Jan 2012 13:26:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id q0UDQlpV059943; Mon, 30 Jan 2012 17:26:47 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id q0UDQkju059942; Mon, 30 Jan 2012 17:26:47 +0400 (MSK) (envelope-from ache) Date: Mon, 30 Jan 2012 17:26:46 +0400 From: Andrey Chernov To: Mark Murray , Mark Murray Message-ID: <20120130132645.GA59595@vniz.net> Mail-Followup-To: Andrey Chernov , Mark Murray , Mark Murray , David Schultz , John Baldwin , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.ORG, David Schultz , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, John Baldwin Subject: Re: svn commit: r230230 - head/sys/dev/random X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2012 13:26:50 -0000 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/