From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 7/22] /dev/random: simplify reseed logic
Date: Thu, 25 Mar 2004 17:57:43 -0600 [thread overview]
Message-ID: <8.524465763@selenic.com> (raw)
In-Reply-To: <7.524465763@selenic.com>
/dev/random simplify reseed logic
Automatically reseed from input pool when pulling from output pools.
tiny-mpm/drivers/char/random.c | 20 ++++++--------------
1 files changed, 6 insertions(+), 14 deletions(-)
diff -puN drivers/char/random.c~kill-extract-secondary drivers/char/random.c
--- tiny/drivers/char/random.c~kill-extract-secondary 2004-03-20 13:38:20.000000000 -0600
+++ tiny-mpm/drivers/char/random.c 2004-03-20 13:38:20.000000000 -0600
@@ -1259,8 +1259,7 @@ static void MD5Transform(__u32 buf[HASH_
*********************************************************************/
#define EXTRACT_ENTROPY_USER 1
-#define EXTRACT_ENTROPY_SECONDARY 2
-#define EXTRACT_ENTROPY_LIMIT 4
+#define EXTRACT_ENTROPY_LIMIT 2
#define TMP_BUF_SIZE (HASH_BUFFER_SIZE + HASH_EXTRA_SIZE)
#define SEC_XFER_SIZE (TMP_BUF_SIZE*4)
@@ -1298,10 +1297,6 @@ static inline void xfer_secondary_pool(s
* number of bytes that are actually obtained. If the EXTRACT_ENTROPY_USER
* flag is given, then the buf pointer is assumed to be in user space.
*
- * If the EXTRACT_ENTROPY_SECONDARY flag is given, then we are actually
- * extracting entropy from the secondary pool, and can refill from the
- * primary pool if needed.
- *
* Note: extract_entropy() assumes that .poolwords is a multiple of 16 words.
*/
static ssize_t extract_entropy(struct entropy_store *r, void * buf,
@@ -1317,7 +1312,7 @@ static ssize_t extract_entropy(struct en
if (r->entropy_count > r->poolinfo->POOLBITS)
r->entropy_count = r->poolinfo->POOLBITS;
- if (flags & EXTRACT_ENTROPY_SECONDARY)
+ if (r != input_pool)
xfer_secondary_pool(r, nbytes, tmp);
/* Hold lock while accounting */
@@ -1418,10 +1413,9 @@ static ssize_t extract_entropy(struct en
void get_random_bytes(void *buf, int nbytes)
{
if (blocking_pool)
- extract_entropy(blocking_pool, (char *) buf, nbytes,
- EXTRACT_ENTROPY_SECONDARY);
+ extract_entropy(blocking_pool, buf, nbytes, 0);
else if (input_pool)
- extract_entropy(input_pool, (char *) buf, nbytes, 0);
+ extract_entropy(input_pool, buf, nbytes, 0);
else
printk(KERN_NOTICE "get_random_bytes called before "
"random driver initialization\n");
@@ -1541,8 +1535,7 @@ random_read(struct file * file, char * b
n = extract_entropy(blocking_pool, buf, n,
EXTRACT_ENTROPY_USER |
- EXTRACT_ENTROPY_LIMIT |
- EXTRACT_ENTROPY_SECONDARY);
+ EXTRACT_ENTROPY_LIMIT);
DEBUG_ENT("read got %d bits (%d still needed)\n",
n*8, (nbytes-n)*8);
@@ -1594,8 +1587,7 @@ urandom_read(struct file * file, char *
size_t nbytes, loff_t *ppos)
{
return extract_entropy(blocking_pool, buf, nbytes,
- EXTRACT_ENTROPY_USER |
- EXTRACT_ENTROPY_SECONDARY);
+ EXTRACT_ENTROPY_USER);
}
static unsigned int
_
next prev parent reply other threads:[~2004-03-26 1:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-25 23:57 [PATCH 0/22] /dev/random: Assorted fixes and cleanups Matt Mackall
2004-03-25 23:57 ` [PATCH 1/22] /dev/random: Simplify entropy debugging Matt Mackall
2004-03-25 23:57 ` [PATCH 2/22] /dev/random: Cleanup sleep logic Matt Mackall
2004-03-25 23:57 ` [PATCH 3/22] /dev/random: remove broken resizing sysctl Matt Mackall
2004-03-25 23:57 ` [PATCH 4/22] /dev/random: remove outdated RNDGETPOOL ioctl Matt Mackall
2004-03-25 23:57 ` [PATCH 5/22] /dev/random: pool struct cleanup and rename Matt Mackall
2004-03-25 23:57 ` [PATCH 6/22] /dev/random: simplify pool initialization Matt Mackall
2004-03-25 23:57 ` Matt Mackall [this message]
2004-03-25 23:57 ` [PATCH 8/22] /dev/random: BUG on premature random users Matt Mackall
2004-03-25 23:57 ` [PATCH 9/22] /dev/random: more robust catastrophic reseed logic Matt Mackall
2004-03-25 23:57 ` [PATCH 10/22] /dev/random: entropy reserve logic for starvation preve Matt Mackall
2004-03-25 23:57 ` [PATCH 11/22] /dev/random: flag pools that need entropy reserve Matt Mackall
2004-03-25 23:57 ` [PATCH 12/22] /dev/random: add pool for /dev/urandom to prevent starv Matt Mackall
2004-03-25 23:57 ` [PATCH 13/22] /dev/random: kill extract_timer_state Matt Mackall
2004-03-25 23:57 ` [PATCH 14/22] /dev/random: kill unused md5 copy Matt Mackall
2004-03-25 23:57 ` [PATCH 15/22] /dev/random: kill unrolled SHA code Matt Mackall
2004-03-25 23:57 ` [PATCH 16/22] /dev/random: kill 2.2 cruft Matt Mackall
2004-03-25 23:57 ` [PATCH 17/22] /dev/random: minor shrinkage Matt Mackall
2004-03-25 23:57 ` [PATCH 18/22] /dev/random: bitop cleanup Matt Mackall
2004-03-25 23:57 ` [PATCH 19/22] /dev/random: use sched_clock for timing data Matt Mackall
2004-03-25 23:57 ` [PATCH 20/22] /dev/random: cleanup rol bitop Matt Mackall
2004-03-25 23:57 ` [PATCH 21/22] /dev/random: kill batching of entropy mixing Matt Mackall
2004-03-25 23:57 ` [PATCH 22/22] /dev/random: update credits Matt Mackall
2004-03-27 13:52 ` [PATCH 21/22] /dev/random: kill batching of entropy mixing Jamie Lokier
2004-03-27 15:17 ` Matt Mackall
2004-03-26 1:43 ` [PATCH 15/22] /dev/random: kill unrolled SHA code Jeff Garzik
2004-03-26 3:59 ` Matt Mackall
2004-03-27 13:49 ` Jamie Lokier
2004-03-26 0:15 ` [PATCH 4/22] /dev/random: remove outdated RNDGETPOOL ioctl Andrew Morton
2004-03-26 0:15 ` [PATCH 3/22] /dev/random: remove broken resizing sysctl Andrew Morton
2004-03-26 3:53 ` Matt Mackall
2004-03-26 0:14 ` [PATCH 2/22] /dev/random: Cleanup sleep logic Andrew Morton
2004-03-26 3:49 ` Matt Mackall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8.524465763@selenic.com \
--to=mpm@selenic.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox