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

2012-01-30 Thread Andrey Chernov
On Mon, Jan 30, 2012 at 11:30:15AM +, 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 >

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

2012-01-30 Thread Mark Murray
Andrey Chernov writes: > On Thu, Jan 26, 2012 at 10:13:41PM +0400, Andrey Chernov wrote: > > On Thu, Jan 26, 2012 at 12:52:43PM -0500, David Schultz wrote: > > > Why complicate things with atomics at all? A race might result in > > > arc4random(9) being seeded multiple times, but that's harmless.

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

2012-01-29 Thread Andrey Chernov
On Thu, Jan 26, 2012 at 10:13:41PM +0400, Andrey Chernov wrote: > On Thu, Jan 26, 2012 at 12:52:43PM -0500, David Schultz wrote: > > Why complicate things with atomics at all? A race might result in > > arc4random(9) being seeded multiple times, but that's harmless. > > Multiply seeding in line

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

2012-01-28 Thread Andrey Chernov
On Sat, Jan 28, 2012 at 06:47:50PM +1100, Bruce Evans wrote: > > --- sys/libkern.h.old 2012-01-16 07:15:12.0 +0400 > > +++ sys/libkern.h 2012-01-28 08:49:19.0 +0400 > > @@ -70,6 +70,11 @@ static __inline int abs(int a) { return > > static __inline long labs(long a) { return

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

2012-01-27 Thread Bruce Evans
On Sat, 28 Jan 2012, Andrey Chernov wrote: New verson addressed bde's style things: Thanks, but ... --- sys/libkern.h.old 2012-01-16 07:15:12.0 +0400 +++ sys/libkern.h 2012-01-28 08:49:19.0 +0400 @@ -70,6 +70,11 @@ static __inline int abs(int a) { return static __inli

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

2012-01-27 Thread Andrey Chernov
New verson addressed bde's style things: --- sys/libkern.h.old 2012-01-16 07:15:12.0 +0400 +++ sys/libkern.h 2012-01-28 08:49:19.0 +0400 @@ -70,6 +70,11 @@ static __inline int abs(int a) { return static __inline long labs(long a) { return (a < 0 ? -a : a); } static __inl

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

2012-01-27 Thread Andrey Chernov
On Fri, Jan 27, 2012 at 08:34:35PM +1100, Bruce Evans wrote: > On Thu, 26 Jan 2012, Andrey Chernov wrote: > > >> On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: > >>> Atomics don't operate on enums. You'll need to make it an int and just > >>> use > >>> #define's for the 3 states.

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

2012-01-27 Thread Bruce Evans
On Thu, 26 Jan 2012, Andrey Chernov wrote: On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: Atomics don't operate on enums. You'll need to make it an int and just use #define's for the 3 states. This restores some style bugs and keeps old ones. --- sys/libkern.h.old 2012-01-

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

2012-01-26 Thread Mark Murray
David Schultz writes: > > Although current version with current kernel flags works, I forget > > it is implementation defined in general and not always equal to > > sizeof(int), f.e. with gcc --short-enums. I'll remade it with > > #defines, thanx again. > > Why complicate things with atomics at all

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

2012-01-26 Thread Andrey Chernov
On Thu, Jan 26, 2012 at 12:52:43PM -0500, David Schultz wrote: > Why complicate things with atomics at all? A race might result in > arc4random(9) being seeded multiple times, but that's harmless. Multiply seeding in line is harmless, just waste of time and resources. Other case is one missing se

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

2012-01-26 Thread Stefan Farfeleder
On Thu, Jan 26, 2012 at 06:34:13PM +0100, Stefan Farfeleder wrote: > > The type of an enumerator actually is `int', so it should be fine. Please ignore that, I misread the diff. Stefan ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/

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

2012-01-26 Thread Stefan Farfeleder
On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: > On Thursday, January 26, 2012 10:56:27 am Andrey Chernov wrote: > > > On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > > > > atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, > ARC4_ENTER_HAVE); > > > >

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

2012-01-26 Thread David Schultz
On Thu, Jan 26, 2012, Andrey Chernov wrote: > On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: > > On Thursday, January 26, 2012 10:56:27 am Andrey Chernov wrote: > > > > On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > > > > > atomic_cmpset_int(&iniseed_st

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

2012-01-26 Thread Andrey Chernov
> On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: > > Atomics don't operate on enums. You'll need to make it an int and just use > > #define's for the 3 states. --- sys/libkern.h.old 2012-01-16 07:15:12.0 +0400 +++ sys/libkern.h 2012-01-26 21:40:21.0 +0400 @

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

2012-01-26 Thread Andrey Chernov
On Thu, Jan 26, 2012 at 11:32:38AM -0500, John Baldwin wrote: > On Thursday, January 26, 2012 10:56:27 am Andrey Chernov wrote: > > > On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > > > > atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, > ARC4_ENTER_HAVE); > > > >

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

2012-01-26 Thread John Baldwin
On Thursday, January 26, 2012 10:56:27 am Andrey Chernov wrote: > > On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > > > atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, ARC4_ENTER_HAVE); > > > break; > > Updated version (I hope, final): > > --- sys/libkern.h

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

2012-01-26 Thread Andrey Chernov
> On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > > atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, > > ARC4_ENTER_HAVE); > > break; Updated version (I hope, final): --- sys/libkern.h.old 2012-01-16 07:15:12.0 +0400 +++ sys/libkern.h 201

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

2012-01-26 Thread Andrey Chernov
On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > What is the purpose of the atomics? Doing atomic_load/atomic_store > is just as racy as if you had not used atomics at all. Thanx for a hint. Protecting comparison itself isn't essential as protecting variable consitency because r

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

2012-01-26 Thread John Baldwin
On Wednesday, January 25, 2012 10:39:50 pm Andrey Chernov wrote: > On Thu, Jan 26, 2012 at 07:03:05AM +0400, Andrey Chernov wrote: > > On Wed, Jan 25, 2012 at 07:16:41PM +, Mark Murray wrote: > > > I thought you were going to do this as a function? It would be > > > slightly neater to do it tha

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

2012-01-25 Thread Andrey Chernov
On Thu, Jan 26, 2012 at 07:03:05AM +0400, Andrey Chernov wrote: > On Wed, Jan 25, 2012 at 07:16:41PM +, Mark Murray wrote: > > I thought you were going to do this as a function? It would be > > slightly neater to do it that way. > > > > Looks good! Are you sure this needs no locking or volatil

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

2012-01-25 Thread Andrey Chernov
On Wed, Jan 25, 2012 at 07:16:41PM +, Mark Murray wrote: > I thought you were going to do this as a function? It would be > slightly neater to do it that way. > > Looks good! Are you sure this needs no locking or volatile > variables? Now with function, volatile, atomic and even enum: --- sy

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

2012-01-25 Thread Mark Murray
Andrey Chernov writes: > On Sun, Jan 22, 2012 at 09:43:02PM +, Mark Murray wrote: > > > Thanx for review! I'll send final version to this thread a bit > > > later when I'll find more free time. > > Final, unless something else noticed. Cool. NOTE: I am only eyeballing this, not testing it.

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

2012-01-25 Thread Andrey Chernov
On Sun, Jan 22, 2012 at 09:43:02PM +, Mark Murray wrote: > > Thanx for review! I'll send final version to this thread a bit > > later when I'll find more free time. Final, unless something else noticed. --- sys/libkern.h.bak 2012-01-16 07:15:12.0 +0400 +++ sys/libkern.h 2012-

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

2012-01-22 Thread Mark Murray
Andrey Chernov writes: > > 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. Ah, OK - in which case you got the idea correctly! > I'll put it into hea

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

2012-01-22 Thread Andrey Chernov
On Sun, Jan 22, 2012 at 04:59:55PM +, 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 >

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

2012-01-22 Thread Mark Murray
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/ar

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

2012-01-20 Thread Andrey Chernov
On Fri, Jan 20, 2012 at 03:12:53PM +, Mark Murray wrote: > 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

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

2012-01-20 Thread Mark Murray
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_

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

2012-01-19 Thread Andrey Chernov
On Thu, Jan 19, 2012 at 07:52:30PM +, Mark Murray wrote: > Andrey Chernov writes: > > On Mon, Jan 16, 2012 at 08:18:10PM +, David Schultz wrote: > > > Author: das > > > Date: Mon Jan 16 20:18:10 2012 > > > New Revision: 230230 > > > URL: http://svn.freebsd.org/changeset/base/230230 > > > >

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

2012-01-19 Thread Mark Murray
Andrey Chernov writes: > On Mon, Jan 16, 2012 at 08:18:10PM +, 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 wit

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

2012-01-18 Thread Andrey Chernov
On Wed, Jan 18, 2012 at 12:54:40PM -0500, David Schultz wrote: > It appears to reseed arc4random's state exactly once, at whatever > unpredictable time devrandom decides to reseed itself. Are you As fast as possible, immediatelly when we have enough good entropy. > trying to fix the problems tha

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

2012-01-18 Thread David Schultz
On Wed, Jan 18, 2012, Andrey Chernov wrote: > On Mon, Jan 16, 2012 at 08:18:10PM +, 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 arc4r

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

2012-01-17 Thread Andrey Chernov
On Mon, Jan 16, 2012 at 08:18:10PM +, 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