mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
random: make 'add_interrupt_randomness()' do something sane
We've been moving away from add_interrupt_randomness() for various reasons: it's too expensive to do on every interrupt, and flooding the CPU with interrupts could theoretically cause bogus floods of entropy from a somewhat externally controllable source. This solves both problems by limiting the actual randomness addition to just once a second or after 64 interrupts, whicever comes first. During that time, the interrupt cycle data is buffered up in a per-cpu pool. Also, we make sure the the nonblocking pool used by urandom is initialized before we start feeding the normal input pool. This assures that /dev/urandom is returning unpredictable data as soon as possible. (Based on an original patch by Linus, but significantly modified by tytso.) Tested-by: Eric Wustrow <[email protected]> Reported-by: Eric Wustrow <[email protected]> Reported-by: Nadia Heninger <[email protected]> Reported-by: Zakir Durumeric <[email protected]> Reported-by: J. Alex Halderman <[email protected]>. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
This commit is contained in:
parent
74feec5dd8
commit
775f4b297b
4 changed files with 90 additions and 24 deletions
|
|
@ -133,7 +133,7 @@ irqreturn_t
|
|||
handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)
|
||||
{
|
||||
irqreturn_t retval = IRQ_NONE;
|
||||
unsigned int random = 0, irq = desc->irq_data.irq;
|
||||
unsigned int flags = 0, irq = desc->irq_data.irq;
|
||||
|
||||
do {
|
||||
irqreturn_t res;
|
||||
|
|
@ -161,7 +161,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)
|
|||
|
||||
/* Fall through to add to randomness */
|
||||
case IRQ_HANDLED:
|
||||
random |= action->flags;
|
||||
flags |= action->flags;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -172,8 +172,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)
|
|||
action = action->next;
|
||||
} while (action);
|
||||
|
||||
if (random & IRQF_SAMPLE_RANDOM)
|
||||
add_interrupt_randomness(irq);
|
||||
add_interrupt_randomness(irq, flags);
|
||||
|
||||
if (!noirqdebug)
|
||||
note_interrupt(irq, desc, retval);
|
||||
|
|
|
|||
Loading…
Reference in a new issue