Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Back out tls-earlyentropy's rnd_add_data.



details:   https://anonhg.NetBSD.org/src/rev/4592e4c92c18
branches:  trunk
changeset: 331456:4592e4c92c18
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 11 04:26:53 2014 +0000

description:
Back out tls-earlyentropy's rnd_add_data.

This caused recursion on rndpool_mtx when called from an rndsource's
callback.

XXX The old and new code here is a minefield demanding another
rototill.

XXX rnd_source_anonymous was not actually used before, and still is
not used now, to be cleaned up later.

diffstat:

 sys/kern/kern_rndq.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (36 lines):

diff -r cb9363155f48 -r 4592e4c92c18 sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Mon Aug 11 04:03:59 2014 +0000
+++ b/sys/kern/kern_rndq.c      Mon Aug 11 04:26:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndq.c,v 1.25 2014/08/10 18:33:41 joerg Exp $     */
+/*     $NetBSD: kern_rndq.c,v 1.26 2014/08/11 04:26:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.25 2014/08/10 18:33:41 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.26 2014/08/11 04:26:53 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -802,12 +802,13 @@
         * itself, random.  Don't estimate entropy based on
         * timestamp, just directly add the data.
         */
-       mutex_spin_enter(&rndpool_mtx);
        if (__predict_false(rs == NULL)) {
-               rs = &rnd_source_anonymous;
+               mutex_spin_enter(&rndpool_mtx);
+               rndpool_add_data(&rnd_pool, data, len, entropy);
+               mutex_spin_exit(&rndpool_mtx);
+       } else {
+               rnd_add_data_ts(rs, data, len, entropy, rnd_counter());
        }
-       rndpool_add_data(&rnd_pool, data, len, entropy);
-       mutex_spin_exit(&rndpool_mtx);
 }
 
 static void



Home | Main Index | Thread Index | Old Index