2002-08-15 18:09:30

by henrique

[permalink] [raw]
Subject: Problem with random.c and PPC

Hello !!!

I am trying to use a program (ipsec newhostkey) that uses the random device
provided by the linux-kernel. In a x86 machine the program works fine but
when I tried to run the program in a PPC machine it doesn't work.

Looking carefully I have discovered that the problem is in the driver
random.c. When the program tries to read any amount of data it locks and
never returns. It happens because the variable "random_state->entropy_count"
is always zero, that is, any random number is generated at all !!!??.

Does anyone know anything about this problem ? Any sort of help is very
welcomed.

Thanks
Henrique Gobbi


2002-08-15 18:23:46

by Andreas Dilger

[permalink] [raw]
Subject: Re: Problem with random.c and PPC

On Aug 15, 2002 15:14 +0000, henrique wrote:
> Hello !!!
>
> I am trying to use a program (ipsec newhostkey) that uses the random device
> provided by the linux-kernel. In a x86 machine the program works fine but
> when I tried to run the program in a PPC machine it doesn't work.
>
> Looking carefully I have discovered that the problem is in the driver
> random.c. When the program tries to read any amount of data it locks and
> never returns. It happens because the variable "random_state->entropy_count"
> is always zero, that is, any random number is generated at all !!!??.
>
> Does anyone know anything about this problem ? Any sort of help is very
> welcomed.

Maybe the PPC keyboard/mouse drivers do not add randomness? You should
also get randomness from disk I/O. If your PPC system is diskless,
mouseless, and keyboardless, there is also a patch for 2.4 which allows
you to get randomness from network card interrupts, which is good enough
for all but the most incredibly paranoid people.

Cheers, Andreas
--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

2002-08-15 18:59:49

by Tom Rini

[permalink] [raw]
Subject: Re: Problem with random.c and PPC

On Thu, Aug 15, 2002 at 12:25:56PM -0600, Andreas Dilger wrote:

> On Aug 15, 2002 15:14 +0000, henrique wrote:
> > Hello !!!
> >
> > I am trying to use a program (ipsec newhostkey) that uses the random device
> > provided by the linux-kernel. In a x86 machine the program works fine but
> > when I tried to run the program in a PPC machine it doesn't work.
> >
> > Looking carefully I have discovered that the problem is in the driver
> > random.c. When the program tries to read any amount of data it locks and
> > never returns. It happens because the variable "random_state->entropy_count"
> > is always zero, that is, any random number is generated at all !!!??.
> >
> > Does anyone know anything about this problem ? Any sort of help is very
> > welcomed.
>
> Maybe the PPC keyboard/mouse drivers do not add randomness?

Well, how is this set for the i386 ones? I grepped around and I didn't
really see anything, so I'm sort-of confused.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

2002-08-15 19:57:59

by Andreas Dilger

[permalink] [raw]
Subject: Re: Problem with random.c and PPC

On Aug 15, 2002 12:03 -0700, Tom Rini wrote:
> On Thu, Aug 15, 2002 at 12:25:56PM -0600, Andreas Dilger wrote:
> > Maybe the PPC keyboard/mouse drivers do not add randomness?
>
> Well, how is this set for the i386 ones? I grepped around and I didn't
> really see anything, so I'm sort-of confused.

I think it is something like "add_mouse_entropy" and "add_keyboard_entropy"
or similar. If you look at the random.c sources you can find the actual
function names and work backwards from there.

Cheers, Andreas
--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

2002-08-15 21:00:56

by Tom Rini

[permalink] [raw]
Subject: Re: Problem with random.c and PPC

On Thu, Aug 15, 2002 at 01:59:33PM -0600, Andreas Dilger wrote:
> On Aug 15, 2002 12:03 -0700, Tom Rini wrote:
> > On Thu, Aug 15, 2002 at 12:25:56PM -0600, Andreas Dilger wrote:
> > > Maybe the PPC keyboard/mouse drivers do not add randomness?
> >
> > Well, how is this set for the i386 ones? I grepped around and I didn't
> > really see anything, so I'm sort-of confused.
>
> I think it is something like "add_mouse_entropy" and "add_keyboard_entropy"
> or similar. If you look at the random.c sources you can find the actual
> function names and work backwards from there.

Ah, thanks. In that case, no. It doesn't look like the input-layer USB
keyboards contribute to entropy (but mice do), and I don't think the ADB
ones do. I'll take a crack at adding this to keyboards monday maybe.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

2002-08-16 16:24:15

by Oliver Xymoron

[permalink] [raw]
Subject: Re: Problem with random.c and PPC

On Thu, Aug 15, 2002 at 02:04:49PM -0700, Tom Rini wrote:
> On Thu, Aug 15, 2002 at 01:59:33PM -0600, Andreas Dilger wrote:
> > On Aug 15, 2002 12:03 -0700, Tom Rini wrote:
> > > On Thu, Aug 15, 2002 at 12:25:56PM -0600, Andreas Dilger wrote:
> > > > Maybe the PPC keyboard/mouse drivers do not add randomness?
> > >
> > > Well, how is this set for the i386 ones? I grepped around and I didn't
> > > really see anything, so I'm sort-of confused.
> >
> > I think it is something like "add_mouse_entropy" and "add_keyboard_entropy"
> > or similar. If you look at the random.c sources you can find the actual
> > function names and work backwards from there.
>
> Ah, thanks. In that case, no. It doesn't look like the input-layer USB
> keyboards contribute to entropy (but mice do), and I don't think the ADB
> ones do. I'll take a crack at adding this to keyboards monday maybe.

Tom, I'm working on a set of patches that completely change this
interface because there are a bunch of problems with the current
entropy accounting.

What PPC and other arches really need in this area is a higher
resolution timing source. The jiffies-based timing is rather
limiting, especially after the entropy accounting stops overestimating
things by orders of magnitude. Does the PPC port have a convenient way
to access the TBR or something similar?

--
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."