[PATCH 8/22] /dev/random: BUG on premature random users

From: Matt Mackall
Date: Thu Mar 25 2004 - 20:31:26 EST



/dev/random BUG on premature random users

Generate a fatal error if we try to use the get_random_bytes before
we're initialized.


tiny-mpm/drivers/char/random.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)

diff -puN drivers/char/random.c~bug-on-grb drivers/char/random.c
--- tiny/drivers/char/random.c~bug-on-grb 2004-03-20 13:38:22.000000000 -0600
+++ tiny-mpm/drivers/char/random.c 2004-03-20 13:38:22.000000000 -0600
@@ -1412,13 +1412,8 @@ static ssize_t extract_entropy(struct en
*/
void get_random_bytes(void *buf, int nbytes)
{
- if (blocking_pool)
- extract_entropy(blocking_pool, buf, nbytes, 0);
- else if (input_pool)
- extract_entropy(input_pool, buf, nbytes, 0);
- else
- printk(KERN_NOTICE "get_random_bytes called before "
- "random driver initialization\n");
+ BUG_ON(!blocking_pool);
+ extract_entropy(blocking_pool, buf, nbytes, 0);
}

EXPORT_SYMBOL(get_random_bytes);

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/