svn commit: r230230 - head/sys/dev/random

Mark Murray mark at grondar.org
Fri Jan 20 15:20:33 UTC 2012


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



More information about the svn-src-all mailing list