Re: Random device in 1.3.30

Alain Knaff (
Fri, 13 Oct 95 17:31:16 +0100

>You also have to think about the timing issues carefully. For example,
>let's say the random pool is empty. If you do the
>ioctl(ADD_RANDOM_BITS, 512), then write() the data, if someone read()s
>/dev/random between those two calls, the read might succeed even though
>there's no entropy there. On the other hand, if the pool is full and
>you write() some data, it doesn't actually improve thhe pool's entropy,
>no matter what it is. If someone else *then* reads, they'll knock the
>pool down to not-full status. The ioctl() restores the pool to full
>even though it shouldn't.
>Things will have to be done carefully.

Maybe we could use ioctl(ADD_RANDOM_BITS, &random_struct) instead, where
random_struct would be:
struct random {
int random_bits; /* entropy to be added */
int size; /* actual number of bytes, maybe bigger than the
* entropy if our source is poor */
char *data; /* array containing the random data */
} random_bits;

This ioctl would atomically add the bits to the pool and mark it as full.

> -Colin