From 7c2a3f904425466b66095bfcfdec906b26f9961d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 8 Oct 2002 09:59:27 +0000 Subject: [PATCH] mix in another counter when the psuedo-device attachment is called, this actually happens *after* most of the sources have attached, so microtime is as safe now as it was when they attached. --- sys/dev/rnd.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 90fa0fc8b42e..d8f0b814a72e 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $ */ +/* $NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $"); #include #include @@ -286,8 +286,19 @@ rnd_estimate_entropy(rndsource_t *rs, u_int32_t t) void rndattach(int num) { + u_int32_t c; + /* + * rnd_init() is actually called very early on in the boot + * process, pseudo's don't get attached until much later + * (after many of the sources have been attached). + * XXX Maybe this is left "in case", maybe it should be an assert? + */ rnd_init(); + + /* mix in another counter */ + c = rnd_counter(); + rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0); } void @@ -298,6 +309,10 @@ rnd_init(void) if (rnd_ready) return; + /* + * take a counter early, hoping that there's some variance in + * the following operations + */ c = rnd_counter(); LIST_INIT(&rnd_sources);