aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorGreg Price <price@MIT.EDU>2013-11-29 15:50:06 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-03-19 22:18:50 -0400
commit19fa5be1d92be3112521145bf99f77007abf6b16 (patch)
tree62683ecd9f194b7da5dcaa4147f2c3542b2e37db /drivers/char/random.c
parent12ff3a517ab92b5496c731a3c354caa1f16c569f (diff)
random: fix comment on "account"
This comment didn't quite keep up as extract_entropy() was split into four functions. Put each bit by the function it describes. Signed-off-by: Greg Price <price@mit.edu> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index fcc2bff8f887..2c532a6b0a21 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -958,17 +958,9 @@ static void push_to_pool(struct work_struct *work)
958} 958}
959 959
960/* 960/*
961 * These functions extracts randomness from the "entropy pool", and 961 * This function decides how many bytes to actually take from the
962 * returns it in a buffer. 962 * given pool, and also debits the entropy count accordingly.
963 *
964 * The min parameter specifies the minimum amount we can pull before
965 * failing to avoid races that defeat catastrophic reseeding while the
966 * reserved parameter indicates how much entropy we must leave in the
967 * pool after each pull to avoid starving other readers.
968 *
969 * Note: extract_entropy() assumes that .poolwords is a multiple of 16 words.
970 */ 963 */
971
972static size_t account(struct entropy_store *r, size_t nbytes, int min, 964static size_t account(struct entropy_store *r, size_t nbytes, int min,
973 int reserved) 965 int reserved)
974{ 966{
@@ -1018,6 +1010,12 @@ retry:
1018 return ibytes; 1010 return ibytes;
1019} 1011}
1020 1012
1013/*
1014 * This function does the actual extraction for extract_entropy and
1015 * extract_entropy_user.
1016 *
1017 * Note: we assume that .poolwords is a multiple of 16 words.
1018 */
1021static void extract_buf(struct entropy_store *r, __u8 *out) 1019static void extract_buf(struct entropy_store *r, __u8 *out)
1022{ 1020{
1023 int i; 1021 int i;
@@ -1079,6 +1077,15 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
1079 memset(&hash, 0, sizeof(hash)); 1077 memset(&hash, 0, sizeof(hash));
1080} 1078}
1081 1079
1080/*
1081 * This function extracts randomness from the "entropy pool", and
1082 * returns it in a buffer.
1083 *
1084 * The min parameter specifies the minimum amount we can pull before
1085 * failing to avoid races that defeat catastrophic reseeding while the
1086 * reserved parameter indicates how much entropy we must leave in the
1087 * pool after each pull to avoid starving other readers.
1088 */
1082static ssize_t extract_entropy(struct entropy_store *r, void *buf, 1089static ssize_t extract_entropy(struct entropy_store *r, void *buf,
1083 size_t nbytes, int min, int reserved) 1090 size_t nbytes, int min, int reserved)
1084{ 1091{
@@ -1129,6 +1136,10 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
1129 return ret; 1136 return ret;
1130} 1137}
1131 1138
1139/*
1140 * This function extracts randomness from the "entropy pool", and
1141 * returns it in a userspace buffer.
1142 */
1132static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf, 1143static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
1133 size_t nbytes) 1144 size_t nbytes)
1134{ 1145{