@@ -1382,12 +1382,20 @@ static void try_to_generate_entropy(void)
unsigned long entropy;
struct timer_list timer;
} stack;
+ int i;
stack.entropy = random_get_entropy();
- /* Slow counter - or none. Don't even bother */
- if (stack.entropy == random_get_entropy())
- return;
+ /*
+ * We must not proceed if we don't actually have a cycle counter. To
+ * detect a cycle counter, check whether random_get_entropy() returns a
+ * different value each time. Check it multiple times to avoid false
+ * positives where a slow counter could be just on the cusp of a change.
+ */
+ for (i = 0; i < 3; i++) {
+ if (stack.entropy == random_get_entropy())
+ return;
+ }
timer_setup_on_stack(&stack.timer, entropy_timer, 0);
while (!crng_ready() && !signal_pending(current)) {