From owner-svn-src-all@FreeBSD.ORG Wed Jan 18 17:54:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AAF91065672; Wed, 18 Jan 2012 17:54:41 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 1FC1B8FC1B; Wed, 18 Jan 2012 17:54:40 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0IHsei3000426; Wed, 18 Jan 2012 12:54:40 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0IHseaT000425; Wed, 18 Jan 2012 12:54:40 -0500 (EST) (envelope-from das@freebsd.org) Date: Wed, 18 Jan 2012 12:54:40 -0500 From: David Schultz To: Andrey Chernov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <20120118175440.GA365@zim.MIT.EDU> Mail-Followup-To: Andrey Chernov , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG References: <201201162018.q0GKIADK050161@svn.freebsd.org> <20120118061943.GA80874@vniz.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120118061943.GA80874@vniz.net> Cc: Subject: Re: svn commit: r230230 - head/sys/dev/random X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jan 2012 17:54:41 -0000 On Wed, Jan 18, 2012, Andrey Chernov wrote: > On Mon, Jan 16, 2012 at 08:18:10PM +0000, David Schultz wrote: > > Author: das > > Date: Mon Jan 16 20:18:10 2012 > > New Revision: 230230 > > URL: http://svn.freebsd.org/changeset/base/230230 > > > > Log: > > Generate a warning if the kernel's arc4random() is seeded with bogus entropy. > > While you are here, could you review/commit my patch to fix bad 31bit > arc4rand() seeding, please? > > --- yarrow.c.bak 2011-09-26 07:35:48.000000000 +0400 > +++ yarrow.c 2012-01-18 10:13:47.000000000 +0400 > @@ -59,6 +59,8 @@ static void reseed(u_int); > /* The reseed thread mutex */ > struct mtx random_reseed_mtx; > > +static arc4rand_seeded = 0; > + > /* Process a single stochastic event off the harvest queue */ > void > random_process_event(struct harvest *event) > @@ -261,6 +263,11 @@ reseed(u_int fastslow) > > /* Release the reseed mutex */ > mtx_unlock(&random_reseed_mtx); > + > + if (!arc4rand_seeded) { > + arc4rand_seeded = 1; > + arc4rand(NULL, 0, 1); > + } > } > > /* Internal function to return processed entropy from the PRNG */ It appears to reseed arc4random's state exactly once, at whatever unpredictable time devrandom decides to reseed itself. Are you trying to fix the problems that arise if random.ko is loaded too late in the boot process?