Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/chfs Timestamps are bad sources of entropy, so just ...



details:   https://anonhg.NetBSD.org/src/rev/5206d187289e
branches:  trunk
changeset: 802282:5206d187289e
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Sep 08 17:41:11 2014 +0000

description:
Timestamps are bad sources of entropy, so just use cprng_fast32.

diffstat:

 sys/ufs/chfs/chfs_gc.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (29 lines):

diff -r 5ea1b2eabe3a -r 5206d187289e sys/ufs/chfs/chfs_gc.c
--- a/sys/ufs/chfs/chfs_gc.c    Mon Sep 08 17:40:02 2014 +0000
+++ b/sys/ufs/chfs/chfs_gc.c    Mon Sep 08 17:41:11 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs_gc.c,v 1.6 2014/09/01 16:46:56 he Exp $   */
+/*     $NetBSD: chfs_gc.c,v 1.7 2014/09/08 17:41:11 joerg Exp $        */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -32,6 +32,7 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/cprng.h>
 #include "chfs.h"
 
 void chfs_gc_release_inode(struct chfs_mount *,
@@ -351,10 +352,7 @@
        KASSERT(mutex_owned(&chmp->chm_lock_mountfields));
 
        /* Get a random number. */
-       struct timespec now;
-       vfs_timestamp(&now);
-
-       int n = now.tv_nsec % 128;
+       uint32_t n = cprng_fast32() % 128;
 
 again:
        /* Find an eraseblock queue. */



Home | Main Index | Thread Index | Old Index