diff options
Diffstat (limited to 'drivers/char/random.c')
| -rw-r--r-- | drivers/char/random.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index e0d0e371909c..7ce1ac4baa6d 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -407,7 +407,7 @@ struct entropy_store { | |||
| 407 | /* read-write data: */ | 407 | /* read-write data: */ |
| 408 | spinlock_t lock; | 408 | spinlock_t lock; |
| 409 | unsigned add_ptr; | 409 | unsigned add_ptr; |
| 410 | int entropy_count; | 410 | int entropy_count; /* Must at no time exceed ->POOLBITS! */ |
| 411 | int input_rotate; | 411 | int input_rotate; |
| 412 | }; | 412 | }; |
| 413 | 413 | ||
| @@ -520,6 +520,7 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes) | |||
| 520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) | 520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) |
| 521 | { | 521 | { |
| 522 | unsigned long flags; | 522 | unsigned long flags; |
| 523 | int entropy_count; | ||
| 523 | 524 | ||
| 524 | if (!nbits) | 525 | if (!nbits) |
| 525 | return; | 526 | return; |
| @@ -527,20 +528,20 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) | |||
| 527 | spin_lock_irqsave(&r->lock, flags); | 528 | spin_lock_irqsave(&r->lock, flags); |
| 528 | 529 | ||
| 529 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); | 530 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); |
| 530 | r->entropy_count += nbits; | 531 | entropy_count = r->entropy_count; |
| 531 | if (r->entropy_count < 0) { | 532 | entropy_count += nbits; |
| 533 | if (entropy_count < 0) { | ||
| 532 | DEBUG_ENT("negative entropy/overflow\n"); | 534 | DEBUG_ENT("negative entropy/overflow\n"); |
| 533 | r->entropy_count = 0; | 535 | entropy_count = 0; |
| 534 | } else if (r->entropy_count > r->poolinfo->POOLBITS) | 536 | } else if (entropy_count > r->poolinfo->POOLBITS) |
| 535 | r->entropy_count = r->poolinfo->POOLBITS; | 537 | entropy_count = r->poolinfo->POOLBITS; |
| 538 | r->entropy_count = entropy_count; | ||
| 536 | 539 | ||
| 537 | /* should we wake readers? */ | 540 | /* should we wake readers? */ |
| 538 | if (r == &input_pool && | 541 | if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) { |
| 539 | r->entropy_count >= random_read_wakeup_thresh) { | ||
| 540 | wake_up_interruptible(&random_read_wait); | 542 | wake_up_interruptible(&random_read_wait); |
| 541 | kill_fasync(&fasync, SIGIO, POLL_IN); | 543 | kill_fasync(&fasync, SIGIO, POLL_IN); |
| 542 | } | 544 | } |
| 543 | |||
| 544 | spin_unlock_irqrestore(&r->lock, flags); | 545 | spin_unlock_irqrestore(&r->lock, flags); |
| 545 | } | 546 | } |
| 546 | 547 | ||
| @@ -1571,6 +1572,7 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) | |||
| 1571 | 1572 | ||
| 1572 | return half_md4_transform(hash, keyptr->secret); | 1573 | return half_md4_transform(hash, keyptr->secret); |
| 1573 | } | 1574 | } |
| 1575 | EXPORT_SYMBOL_GPL(secure_ipv4_port_ephemeral); | ||
| 1574 | 1576 | ||
| 1575 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 1577 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 1576 | u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, | 1578 | u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, |
