Jason A. Donenfeld fed7ef0616 random: avoid initializing twice in credit race
Since all changes of crng_init now go through credit_init_bits(), we can
fix a long standing race in which two concurrent callers of
credit_init_bits() have the new bit count >= some threshold, but are
doing so with crng_init as a lower threshold, checked outside of a lock,
resulting in crng_reseed() or similar being called twice.

In order to fix this, we can use the original cmpxchg value of the bit
count, and only change crng_init when the bit count transitions from
below a threshold to meeting the threshold.

Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-05-18 15:53:53 +02:00
..
2022-03-29 08:50:14 -07:00
2022-03-23 18:23:13 -07:00
2022-03-28 14:32:39 -07:00
2021-06-04 15:35:03 +02:00
2022-03-22 09:17:20 -07:00
2021-07-27 12:17:21 +02:00