aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-11-03 06:54:51 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-11-03 18:18:48 -0500
commit301f0595c0e788edacc3521c4caa90b4e56ffee1 (patch)
treedf43a0a76d8cfa5783154154a60653a7d51c2d8e /drivers/char/random.c
parent40db23e5337d99fda05ee6cd18034b516f8f123d (diff)
random: printk notifications for urandom pool initialization
Print a notification to the console when the nonblocking pool is initialized. Also printk a warning when a process tries reading from /dev/urandom before it is fully initialized. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 62923138e77a..a19a7a63ec35 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -655,6 +655,9 @@ retry:
655 r->entropy_total += nbits; 655 r->entropy_total += nbits;
656 if (!r->initialized && nbits > 0) { 656 if (!r->initialized && nbits > 0) {
657 if (r->entropy_total > 128) { 657 if (r->entropy_total > 128) {
658 if (r == &nonblocking_pool)
659 pr_notice("random: %s pool is initialized\n",
660 r->name);
658 r->initialized = 1; 661 r->initialized = 1;
659 r->entropy_total = 0; 662 r->entropy_total = 0;
660 } 663 }
@@ -1327,7 +1330,14 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
1327static ssize_t 1330static ssize_t
1328urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 1331urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
1329{ 1332{
1330 int ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); 1333 int ret;
1334
1335 if (unlikely(nonblocking_pool.initialized == 0))
1336 printk_once(KERN_NOTICE "random: %s urandom read "
1337 "with %d bits of entropy available\n",
1338 current->comm, nonblocking_pool.entropy_total);
1339
1340 ret = extract_entropy_user(&nonblocking_pool, buf, nbytes);
1331 1341
1332 trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool), 1342 trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool),
1333 ENTROPY_BITS(&input_pool)); 1343 ENTROPY_BITS(&input_pool));