diff options
| -rw-r--r-- | drivers/char/random.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index a19a7a63ec35..a38d97a21455 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -1228,14 +1228,11 @@ static void init_std_data(struct entropy_store *r) | |||
| 1228 | ktime_t now = ktime_get_real(); | 1228 | ktime_t now = ktime_get_real(); |
| 1229 | unsigned long rv; | 1229 | unsigned long rv; |
| 1230 | 1230 | ||
| 1231 | r->entropy_count = 0; | ||
| 1232 | r->entropy_total = 0; | ||
| 1233 | r->last_data_init = 0; | ||
| 1234 | r->last_pulled = jiffies; | 1231 | r->last_pulled = jiffies; |
| 1235 | mix_pool_bytes(r, &now, sizeof(now), NULL); | 1232 | mix_pool_bytes(r, &now, sizeof(now), NULL); |
| 1236 | for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) { | 1233 | for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) { |
| 1237 | if (!arch_get_random_long(&rv)) | 1234 | if (!arch_get_random_long(&rv)) |
| 1238 | break; | 1235 | rv = random_get_entropy(); |
| 1239 | mix_pool_bytes(r, &rv, sizeof(rv), NULL); | 1236 | mix_pool_bytes(r, &rv, sizeof(rv), NULL); |
| 1240 | } | 1237 | } |
| 1241 | mix_pool_bytes(r, utsname(), sizeof(*(utsname())), NULL); | 1238 | mix_pool_bytes(r, utsname(), sizeof(*(utsname())), NULL); |
| @@ -1258,7 +1255,7 @@ static int rand_initialize(void) | |||
| 1258 | init_std_data(&nonblocking_pool); | 1255 | init_std_data(&nonblocking_pool); |
| 1259 | return 0; | 1256 | return 0; |
| 1260 | } | 1257 | } |
| 1261 | module_init(rand_initialize); | 1258 | early_initcall(rand_initialize); |
| 1262 | 1259 | ||
| 1263 | #ifdef CONFIG_BLOCK | 1260 | #ifdef CONFIG_BLOCK |
| 1264 | void rand_initialize_disk(struct gendisk *disk) | 1261 | void rand_initialize_disk(struct gendisk *disk) |
| @@ -1433,10 +1430,15 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | |||
| 1433 | return 0; | 1430 | return 0; |
| 1434 | case RNDZAPENTCNT: | 1431 | case RNDZAPENTCNT: |
| 1435 | case RNDCLEARPOOL: | 1432 | case RNDCLEARPOOL: |
| 1436 | /* Clear the entropy pool counters. */ | 1433 | /* |
| 1434 | * Clear the entropy pool counters. We no longer clear | ||
| 1435 | * the entropy pool, as that's silly. | ||
| 1436 | */ | ||
| 1437 | if (!capable(CAP_SYS_ADMIN)) | 1437 | if (!capable(CAP_SYS_ADMIN)) |
| 1438 | return -EPERM; | 1438 | return -EPERM; |
| 1439 | rand_initialize(); | 1439 | input_pool.entropy_count = 0; |
| 1440 | nonblocking_pool.entropy_count = 0; | ||
| 1441 | blocking_pool.entropy_count = 0; | ||
| 1440 | return 0; | 1442 | return 0; |
| 1441 | default: | 1443 | default: |
| 1442 | return -EINVAL; | 1444 | return -EINVAL; |
