lkml.org 
[lkml]   [2005]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 4/10] random pt2: re-init all pools on zero
Re-init all three pools in ioctls
Clear entropy count in init_std_data under a lock
Add kerneldoc comment

Signed-off-by: Matt Mackall <mpm@selenic.com>

Index: rnd/drivers/char/random.c
===================================================================
--- rnd.orig/drivers/char/random.c 2005-01-12 21:28:01.110374382 -0800
+++ rnd/drivers/char/random.c 2005-01-12 21:28:02.593185340 -0800
@@ -1473,16 +1473,14 @@

EXPORT_SYMBOL(get_random_bytes);

-/*********************************************************************
- *
- * Functions to interface with Linux
- *
- *********************************************************************/
-
/*
- * Initialize the random pool with standard stuff.
+ * init_std_data - initialize pool with system data
*
- * NOTE: This is an OS-dependent function.
+ * @r: pool to initialize
+ *
+ * This function clears the pool's entropy count and mixes some system
+ * data into the pool to prepare it for use. The pool is not cleared
+ * as that can only decrease the entropy in the pool.
*/
static void init_std_data(struct entropy_store *r)
{
@@ -1490,6 +1488,11 @@
__u32 words[2];
char *p;
int i;
+ unsigned long flags;
+
+ spin_lock_irqsave(&r->lock, flags);
+ r->entropy_count = 0;
+ spin_unlock_irqrestore(&r->lock, flags);

do_gettimeofday(&tv);
words[0] = tv.tv_sec;
@@ -1752,8 +1755,9 @@
/* Clear the entropy pool counters. */
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- random_state->entropy_count = 0;
init_std_data(random_state);
+ init_std_data(sec_random_state);
+ init_std_data(urandom_state);
return 0;
default:
return -EINVAL;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:09    [W:0.047 / U:1.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site