diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-11-04 03:24:08 +0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-11-04 03:24:08 +0400 |
commit | 392a546dc8368d1745f9891ef3f8f7c380de8650 (patch) | |
tree | c579d07d0c4bbece97f98181fea741afbd268244 /drivers/char/random.c | |
parent | 644008df899ec252e78db28c1b6d6b86779aada8 (diff) | |
download | linux-392a546dc8368d1745f9891ef3f8f7c380de8650.tar.xz |
random: add debugging code to detect early use of get_random_bytes()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 0894d86253fd..cdf4cfb2da4d 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -280,6 +280,8 @@ #define SEC_XFER_SIZE 512 #define EXTRACT_SIZE 10 +#define DEBUG_RANDOM_BOOT 0 + #define LONGS(x) (((x) + sizeof(unsigned long) - 1)/sizeof(unsigned long)) /* @@ -1177,6 +1179,13 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf, */ void get_random_bytes(void *buf, int nbytes) { +#if DEBUG_RANDOM_BOOT > 0 + if (unlikely(nonblocking_pool.initialized == 0)) + printk(KERN_NOTICE "random: %pF get_random_bytes called " + "with %d bits of entropy available\n", + (void *) _RET_IP_, + nonblocking_pool.entropy_total); +#endif trace_get_random_bytes(nbytes, _RET_IP_); extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); } |