Module Name:    src
Committed By:   riastradh
Date:           Mon Aug 11 04:26:53 UTC 2014

Modified Files:
        src/sys/kern: kern_rndq.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/kern_rndq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.25 src/sys/kern/kern_rndq.c:1.26
--- src/sys/kern/kern_rndq.c:1.25	Sun Aug 10 18:33:41 2014
+++ src/sys/kern/kern_rndq.c	Mon Aug 11 04:26:53 2014
@@ -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 @@ rnd_add_data(krndsource_t *rs, const voi
 	 * 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

Reply via email to