Skip to content

Commit 95b709b

Browse files
committed
random: drop trickle mode
The add_timer_randomness() used to drop into trickle mode when entropy pool was estimated to be 87.5% full. This was important when add_timer_randomness() was used to sample interrupts. It's not used for this any more --- add_interrupt_randomness() now uses fast_mix() instead. By elimitating trickle mode, it allows us to fully utilize entropy provided by add_input_randomness() and add_disk_randomness() even when the input pool is above the old trickle threshold of 87.5%. This helps to answer the criticism in [1] in their hypothetical scenario where our entropy estimator was inaccurate, even though the measurements in [2] seem to indicate that our entropy estimator given real-life entropy collection is actually pretty good, albeit on the conservative side (which was as it was designed). [1] http://eprint.iacr.org/2013/338.pdf [2] http://eprint.iacr.org/2012/251.pdf Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 6e9fa2c commit 95b709b

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

drivers/char/random.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,8 @@
282282
#define LONGS(x) (((x) + sizeof(unsigned long) - 1)/sizeof(unsigned long))
283283

284284
/*
285-
* To allow fractional bits to be tracked, the following fields contain
286-
* this many fractional bits:
287-
*
288-
* entropy_count, trickle_thresh
285+
* To allow fractional bits to be tracked, the entropy_count field is
286+
* denominated in units of 1/8th bits.
289287
*
290288
* 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
291289
* credit_entropy_bits() needs to be 64 bits wide.
@@ -313,14 +311,6 @@ static int random_write_wakeup_thresh = 128;
313311
*/
314312
static int random_min_urandom_seed = 60;
315313

316-
/*
317-
* When the input pool goes over trickle_thresh, start dropping most
318-
* samples to avoid wasting CPU time and reduce lock contention.
319-
*/
320-
static const int trickle_thresh = (INPUT_POOL_WORDS * 28) << ENTROPY_SHIFT;
321-
322-
static DEFINE_PER_CPU(int, trickle_count);
323-
324314
/*
325315
* Originally, we used a primitive polynomial of degree .poolwords
326316
* over GF(2). The taps for various sizes are defined below. They
@@ -755,10 +745,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
755745
long delta, delta2, delta3;
756746

757747
preempt_disable();
758-
/* if over the trickle threshold, use only 1 in 4096 samples */
759-
if (ENTROPY_BITS(&input_pool) > trickle_thresh &&
760-
((__this_cpu_inc_return(trickle_count) - 1) & 0xfff))
761-
goto out;
762748

763749
sample.jiffies = jiffies;
764750
sample.cycles = random_get_entropy();
@@ -800,7 +786,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
800786
credit_entropy_bits(&input_pool,
801787
min_t(int, fls(delta>>1), 11));
802788
}
803-
out:
804789
preempt_enable();
805790
}
806791

0 commit comments

Comments
 (0)