Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jan 2012 22:55:46 +0400
From:      Andrey Chernov <ache@FreeBSD.ORG>
To:        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
Subject:   Re: svn commit: r230230 - head/sys/dev/random
Message-ID:  <20120122185545.GA11874@vniz.net>
In-Reply-To: <E1Rp0lq-000Gly-FT@groundzero.grondar.org>
References:  <201201162018.q0GKIADK050161@svn.freebsd.org> <20120118061943.GA80874@vniz.net> <E1Rny2A-000C3x-O6@groundzero.grondar.org> <20120120055823.GA28177@vniz.net> <E1RoG98-000DiP-0Y@groundzero.grondar.org> <20120120215649.GA40016@vniz.net> <E1Rp0lq-000Gly-FT@groundzero.grondar.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 22, 2012 at 04:59:55PM +0000, Mark Murray wrote:
> Andrey Chernov writes:
> > > The usual way round this is with a flag. Set a static, volatile
> > > flag, defaulting "off", and set it to "on" when the seeding has
> > > happened. Then arc4random() can do the right thing, depending on
> > > this flag.
> >
> > Ok, what about this version, is it right? libkern/arc4rand.c is not a
> > module but always present in the kernel, so "arc4rand_iniseed_state"
> > will be always accessible.
> >
> > --- dev/random/randomdev_soft.c.old	2011-09-26 07:35:48.000000000 +0400
> > +++ dev/random/randomdev_soft.c	2012-01-21 01:41:37.000000000 +0400
> > @@ -55,6 +55,8 @@ __FBSDID("$FreeBSD: src/sys/dev/random/r
> >  
> >  #define RANDOM_FIFO_MAX	256	/* How many events to queue up */
> >  
> > +extern int arc4rand_iniseed_state;
> > +
> 
> Should be in a header file, nad _possibly_ should be volatile. If it
> works without being volatile, then OK.

It was preliminary patch just to confirm/deny my understanding of your 
idea.

I'll put it into header.
In the final version I also plan to move that lines
+               if (arc4rand_iniseed_state == 1)
+                       arc4rand_iniseed_state = -1;
into arc4_randomstir() where they will be protected with mutex lock, so 
volatile will be not needed. It will be more logical, because other 
reseeding conditions are resetted there too.

> The rest is OK. I've not tested it, so this is not a review, simply an
> "OK" :-)

Thanx for review! I'll send final version to this thread a bit 
later when I'll find more free time.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120122185545.GA11874>