Skip to content

Commit ba461af

Browse files
committed
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
2 parents fa1796a + 63b8ea5 commit ba461af

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/char/random.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static struct fasync_struct *fasync;
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)
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)
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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ struct ratelimit_state {
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

0 commit comments

Comments
 (0)