Pull random number generator fixes from Jason Donenfeld: - A change to schedule the interrupt randomness mixing less often, yet credit a little more each time, to reduce overhead during interrupt storms. - Squelch an undesired pr_warn() from __ratelimit(), which was causing problems in the reporters' CI. - A trivial comment fix. * tag 'random-5.19-rc4-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random: random: update comment from copy_to_user() -> copy_to_iter() random: quiet urandom warning ratelimit suppression message random: schedule mix_interrupt_randomness() less often
Unified · Split
| @@ -87,7 +87,7 @@ static struct fasync_struct *fasync; · 86 unmodified lines | ||
| 87 | 87 | |
| 88 | 88 | /* Control how we warn userspace. */ |
| 89 | 89 | static struct ratelimit_state urandom_warning = |
| 90 | − RATELIMIT_STATE_INIT("warn_urandom_randomness", HZ, 3); | |
| 90 | + RATELIMIT_STATE_INIT_FLAGS("urandom_warning", HZ, 3, RATELIMIT_MSG_ON_RELEASE); | |
| 91 | 91 | static int ratelimit_disable __read_mostly = |
| 92 | 92 | IS_ENABLED(CONFIG_WARN_ALL_UNSEEDED_RANDOM); |
| 93 | 93 | module_param_named(ratelimit_disable, ratelimit_disable, int, 0644); |
| @@ -408,7 +408,7 @@ static ssize_t get_random_bytes_user(struct iov_iter *iter) · 314 unmodified lines | ||
| 408 | 408 | |
| 409 | 409 | /* |
| 410 | 410 | * Immediately overwrite the ChaCha key at index 4 with random |
| 411 | − * bytes, in case userspace causes copy_to_user() below to sleep | |
| 411 | + * bytes, in case userspace causes copy_to_iter() below to sleep | |
| 412 | 412 | * forever, so that we still retain forward secrecy in that case. |
| 413 | 413 | */ |
| 414 | 414 | crng_make_state(chacha_state, (u8 *)&chacha_state[4], CHACHA_KEY_SIZE); |
| @@ -1009,7 +1009,7 @@ void add_interrupt_randomness(int irq) · 594 unmodified lines | ||
| 1009 | 1009 | if (new_count & MIX_INFLIGHT) |
| 1010 | 1010 | return; |
| 1011 | 1011 | |
| 1012 | − if (new_count < 64 && !time_is_before_jiffies(fast_pool->last + HZ)) | |
| 1012 | + if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ)) | |
| 1013 | 1013 | return; |
| 1014 | 1014 | |
| 1015 | 1015 | if (unlikely(!fast_pool->mix.func)) |
| @@ -23,12 +23,16 @@ struct ratelimit_state { · 22 unmodified lines | ||
| 23 | 23 | unsigned long flags; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | −#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \ | |
| 27 | − .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ | |
| 28 | − .interval = interval_init, \ | |
| 29 | − .burst = burst_init, \ | |
| 26 | +#define RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, flags_init) { \ | |
| 27 | + .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ | |
| 28 | + .interval = interval_init, \ | |
| 29 | + .burst = burst_init, \ | |
| 30 | + .flags = flags_init, \ | |
| 30 | 31 | } |
| 31 | 32 | |
| 33 | +#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) \ | |
| 34 | + RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, 0) | |
| 35 | + | |
| 32 | 36 | #define RATELIMIT_STATE_INIT_DISABLED \ |
| 33 | 37 | RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST) |
| 34 | 38 | |