History

Merge tag 'random-5.19-rc4-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random

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

Linus Torvalds committed 4 years ago

Commit ba461af2 parents fa1796a 63b8ea52 files · +11 −7Browse files

Unified · Split

2 files
  1. drivers/char/random.c +3 −3
  2. include/linux/ratelimit_types.h +8 −4
drivers/char/random.c+3−3
@@ -87,7 +87,7 @@ static struct fasync_struct *fasync; · 86 unmodified lines
8787
8888 /* Control how we warn userspace. */
8989 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);
9191 static int ratelimit_disable __read_mostly =
9292 IS_ENABLED(CONFIG_WARN_ALL_UNSEEDED_RANDOM);
9393 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
408408
409409 /*
410410 * 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
412412 * forever, so that we still retain forward secrecy in that case.
413413 */
414414 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
10091009 if (new_count & MIX_INFLIGHT)
10101010 return;
10111011
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))
10131013 return;
10141014
10151015 if (unlikely(!fast_pool->mix.func))
include/linux/ratelimit_types.h+8−4
@@ -23,12 +23,16 @@ struct ratelimit_state { · 22 unmodified lines
2323 unsigned long flags;
2424 };
2525
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, \
3031 }
3132
33+#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) \
34+ RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, 0)
35+
3236 #define RATELIMIT_STATE_INIT_DISABLED \
3337 RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST)
3438