Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jan 2012 15:12:53 +0000
From:      Mark Murray <markm@FreeBSD.org>
To:        Andrey Chernov <ache@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:  <E1RoG98-000DiP-0Y@groundzero.grondar.org>
In-Reply-To: <20120120055823.GA28177@vniz.net>
References:  <201201162018.q0GKIADK050161@svn.freebsd.org> <20120118061943.GA80874@vniz.net> <E1Rny2A-000C3x-O6@groundzero.grondar.org> <20120120055823.GA28177@vniz.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Andrey Chernov writes:
> > Look at the function random_yarrow_unblock(). Thats where yopu want to
> > be doing this. This function is where the random device is unblocked
> > once safely seeded.
> 
> Thanx for your hint, but I fear one moment using random_yarrow_unblock().
> It is called under mtx_lock(&random_reseed_mtx) in reseed().
> And when arc4rand() seeding is called, it uses read_random(), so I see 
> possible deadlock can happens.

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.

> In my version arc4rand() seeding happens only when this lock is released,
> so no blocking is possible. 

Sure, but the dependancies created are problematic in their own right.

M
--
Mark R V Murray
Cert APS(Open) Dip Phys(Open) BSc Open(Open) BSc(Hons)(Open)
Pi: 132511160




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1RoG98-000DiP-0Y>