Commit 43d5d301 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] random driver preempt robustness

A certain codepath in the random driver relied on vt_ioctl() being under
the BKL and implicitly disabling preemption.  The code wasn't buggy
upstream but it's slighly unrobust so I think we want the fix upstream too,
independently of the remove-bkl patch.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 644f6741
......@@ -807,10 +807,11 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
long delta, delta2, delta3;
int entropy = 0;
preempt_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
if ( random_state->entropy_count > trickle_thresh &&
(__get_cpu_var(trickle_count)++ & 0xfff))
return;
goto out;
/*
* Use get_cycles() if implemented, otherwise fall back to
......@@ -861,6 +862,8 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
entropy = int_ln_12bits(delta);
}
batch_entropy_store(num, time, entropy);
out:
preempt_enable();
}
void add_keyboard_randomness(unsigned char scancode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment