]> git.baikalelectronics.ru Git - kernel.git/commit
random: cap jitter samples per bit to factor of HZ
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 13 Jul 2022 15:11:15 +0000 (17:11 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jul 2022 17:42:12 +0000 (10:42 -0700)
commitd6ce4bf084c3e7ef70f782d6823a18a9097c930a
treeb346e911932ceeacb15919a66574a2a70c2ffc8e
parent90d21146c7273ac336c7cf753a709559d6146e0a
random: cap jitter samples per bit to factor of HZ

Currently the jitter mechanism will require two timer ticks per
iteration, and it requires N iterations per bit. This N is determined
with a small measurement, and if it's too big, it won't waste time with
jitter entropy because it'd take too long or not have sufficient entropy
anyway.

With the current max N of 32, there are large timeouts on systems with a
small CONFIG_HZ. Rather than set that maximum to 32, instead choose a
factor of CONFIG_HZ. In this case, 1/30 seems to yield sane values for
different configurations of CONFIG_HZ.

Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
Fixes: 2fc3e113e981 ("random: vary jitter iterations based on cycle counter speed")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/random.c