diff options
| -rw-r--r-- | drivers/char/random.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 482531d87fb8..92d6dd24c86e 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -466,7 +466,6 @@ struct entropy_store { | |||
| 466 | int entropy_count; | 466 | int entropy_count; |
| 467 | int entropy_total; | 467 | int entropy_total; |
| 468 | unsigned int initialized:1; | 468 | unsigned int initialized:1; |
| 469 | unsigned int limit:1; | ||
| 470 | unsigned int last_data_init:1; | 469 | unsigned int last_data_init:1; |
| 471 | __u8 last_data[EXTRACT_SIZE]; | 470 | __u8 last_data[EXTRACT_SIZE]; |
| 472 | }; | 471 | }; |
| @@ -484,7 +483,6 @@ static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy; | |||
| 484 | static struct entropy_store input_pool = { | 483 | static struct entropy_store input_pool = { |
| 485 | .poolinfo = &poolinfo_table[0], | 484 | .poolinfo = &poolinfo_table[0], |
| 486 | .name = "input", | 485 | .name = "input", |
| 487 | .limit = 1, | ||
| 488 | .lock = __SPIN_LOCK_UNLOCKED(input_pool.lock), | 486 | .lock = __SPIN_LOCK_UNLOCKED(input_pool.lock), |
| 489 | .pool = input_pool_data | 487 | .pool = input_pool_data |
| 490 | }; | 488 | }; |
| @@ -492,7 +490,6 @@ static struct entropy_store input_pool = { | |||
| 492 | static struct entropy_store blocking_pool = { | 490 | static struct entropy_store blocking_pool = { |
| 493 | .poolinfo = &poolinfo_table[1], | 491 | .poolinfo = &poolinfo_table[1], |
| 494 | .name = "blocking", | 492 | .name = "blocking", |
| 495 | .limit = 1, | ||
| 496 | .pull = &input_pool, | 493 | .pull = &input_pool, |
| 497 | .lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock), | 494 | .lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock), |
| 498 | .pool = blocking_pool_data, | 495 | .pool = blocking_pool_data, |
| @@ -1212,15 +1209,6 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) | |||
| 1212 | r->entropy_count > r->poolinfo->poolfracbits) | 1209 | r->entropy_count > r->poolinfo->poolfracbits) |
| 1213 | return; | 1210 | return; |
| 1214 | 1211 | ||
| 1215 | if (r->limit == 0 && random_min_urandom_seed) { | ||
| 1216 | unsigned long now = jiffies; | ||
| 1217 | |||
| 1218 | if (time_before(now, | ||
| 1219 | r->last_pulled + random_min_urandom_seed * HZ)) | ||
| 1220 | return; | ||
| 1221 | r->last_pulled = now; | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | _xfer_secondary_pool(r, nbytes); | 1212 | _xfer_secondary_pool(r, nbytes); |
| 1225 | } | 1213 | } |
| 1226 | 1214 | ||
| @@ -1228,8 +1216,6 @@ static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes) | |||
| 1228 | { | 1216 | { |
| 1229 | __u32 tmp[OUTPUT_POOL_WORDS]; | 1217 | __u32 tmp[OUTPUT_POOL_WORDS]; |
| 1230 | 1218 | ||
| 1231 | /* For /dev/random's pool, always leave two wakeups' worth */ | ||
| 1232 | int rsvd_bytes = r->limit ? 0 : random_read_wakeup_bits / 4; | ||
| 1233 | int bytes = nbytes; | 1219 | int bytes = nbytes; |
| 1234 | 1220 | ||
| 1235 | /* pull at least as much as a wakeup */ | 1221 | /* pull at least as much as a wakeup */ |
| @@ -1240,7 +1226,7 @@ static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes) | |||
| 1240 | trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8, | 1226 | trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8, |
| 1241 | ENTROPY_BITS(r), ENTROPY_BITS(r->pull)); | 1227 | ENTROPY_BITS(r), ENTROPY_BITS(r->pull)); |
| 1242 | bytes = extract_entropy(r->pull, tmp, bytes, | 1228 | bytes = extract_entropy(r->pull, tmp, bytes, |
| 1243 | random_read_wakeup_bits / 8, rsvd_bytes); | 1229 | random_read_wakeup_bits / 8, 0); |
| 1244 | mix_pool_bytes(r, tmp, bytes); | 1230 | mix_pool_bytes(r, tmp, bytes); |
| 1245 | credit_entropy_bits(r, bytes*8); | 1231 | credit_entropy_bits(r, bytes*8); |
| 1246 | } | 1232 | } |
| @@ -1268,7 +1254,7 @@ static void push_to_pool(struct work_struct *work) | |||
| 1268 | static size_t account(struct entropy_store *r, size_t nbytes, int min, | 1254 | static size_t account(struct entropy_store *r, size_t nbytes, int min, |
| 1269 | int reserved) | 1255 | int reserved) |
| 1270 | { | 1256 | { |
| 1271 | int entropy_count, orig; | 1257 | int entropy_count, orig, have_bytes; |
| 1272 | size_t ibytes, nfrac; | 1258 | size_t ibytes, nfrac; |
| 1273 | 1259 | ||
| 1274 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); | 1260 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); |
| @@ -1277,14 +1263,12 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
| 1277 | retry: | 1263 | retry: |
| 1278 | entropy_count = orig = ACCESS_ONCE(r->entropy_count); | 1264 | entropy_count = orig = ACCESS_ONCE(r->entropy_count); |
| 1279 | ibytes = nbytes; | 1265 | ibytes = nbytes; |
| 1280 | /* If limited, never pull more than available */ | 1266 | /* never pull more than available */ |
| 1281 | if (r->limit) { | 1267 | have_bytes = entropy_count >> (ENTROPY_SHIFT + 3); |
| 1282 | int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3); | ||
| 1283 | 1268 | ||
| 1284 | if ((have_bytes -= reserved) < 0) | 1269 | if ((have_bytes -= reserved) < 0) |
| 1285 | have_bytes = 0; | 1270 | have_bytes = 0; |
| 1286 | ibytes = min_t(size_t, ibytes, have_bytes); | 1271 | ibytes = min_t(size_t, ibytes, have_bytes); |
| 1287 | } | ||
| 1288 | if (ibytes < min) | 1272 | if (ibytes < min) |
| 1289 | ibytes = 0; | 1273 | ibytes = 0; |
| 1290 | 1274 | ||
