Go to file
Nicolai Stange 960e64920c crypto: drbg - move dynamic ->reseed_threshold adjustments to __drbg_seed()
commit 262d83a4290c331cd4f617a457408bdb82fbb738 upstream.

Since commit 42ea507fae ("crypto: drbg - reseed often if seedsource is
degraded"), the maximum seed lifetime represented by ->reseed_threshold
gets temporarily lowered if the get_random_bytes() source cannot provide
sufficient entropy yet, as is common during boot, and restored back to
the original value again once that has changed.

More specifically, if the add_random_ready_callback() invoked from
drbg_prepare_hrng() in the course of DRBG instantiation does not return
-EALREADY, that is, if get_random_bytes() has not been fully initialized
at this point yet, drbg_prepare_hrng() will lower ->reseed_threshold
to a value of 50. The drbg_async_seed() scheduled from said
random_ready_callback will eventually restore the original value.

A future patch will replace the random_ready_callback based notification
mechanism and thus, there will be no add_random_ready_callback() return
value anymore which could get compared to -EALREADY.

However, there's __drbg_seed() which gets invoked in the course of both,
the DRBG instantiation as well as the eventual reseeding from
get_random_bytes() in aforementioned drbg_async_seed(), if any. Moreover,
it knows about the get_random_bytes() initialization state by the time the
seed data had been obtained from it: the new_seed_state argument introduced
with the previous patch would get set to DRBG_SEED_STATE_PARTIAL in case
get_random_bytes() had not been fully initialized yet and to
DRBG_SEED_STATE_FULL otherwise. Thus, __drbg_seed() provides a convenient
alternative for managing that ->reseed_threshold lowering and restoring at
a central place.

Move all ->reseed_threshold adjustment code from drbg_prepare_hrng() and
drbg_async_seed() respectively to __drbg_seed(). Make __drbg_seed()
lower the ->reseed_threshold to 50 in case its new_seed_state argument
equals DRBG_SEED_STATE_PARTIAL and let it restore the original value
otherwise.

There is no change in behaviour.

Signed-off-by: Nicolai Stange <nstange@suse.de>
Reviewed-by: Stephan Müller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-25 11:49:13 +02:00
arch xtensa: use fallback for random_get_entropy() instead of zero 2022-06-25 11:49:10 +02:00
block blk-iolatency: Fix inflight count imbalances and IO hangs on offline 2022-06-14 16:59:30 +02:00
certs
crypto crypto: drbg - move dynamic ->reseed_threshold adjustments to __drbg_seed() 2022-06-25 11:49:13 +02:00
Documentation random: fix sysctl documentation nits 2022-06-25 11:49:09 +02:00
drivers Revert "random: use static branch for crng_ready()" 2022-06-25 11:49:12 +02:00
firmware
fs 9p: missing chunk of "fs/9p: Don't update file type when updating file attributes" 2022-06-25 11:48:57 +02:00
include crypto: drbg - track whether DRBG was seeded with !rng_is_initialized() 2022-06-25 11:49:13 +02:00
init random: handle latent entropy and command line from random_init() 2022-06-25 11:49:11 +02:00
ipc shm: extend forced shm destroy to support objects from several IPC nses 2021-12-08 08:50:11 +01:00
kernel timekeeping: Add raw clock fallback for random_get_entropy() 2022-06-25 11:49:10 +02:00
lib random: remove ratelimiting for in-kernel unseeded randomness 2022-06-25 11:49:11 +02:00
LICENSES
mm random: move randomize_page() into mm where it belongs 2022-06-25 11:49:12 +02:00
net tcp: fix tcp_mtup_probe_success vs wrong snd_cwnd 2022-06-14 16:59:40 +02:00
samples samples/kretprobes: Fix return value if register_kretprobe() failed 2021-11-26 11:36:11 +01:00
scripts modpost: fix undefined behavior of is_arm_mapping_symbol() 2022-06-14 16:59:38 +02:00
security Fix incorrect type in assignment of ipv6 port for audit 2022-04-15 14:14:54 +02:00
sound ALSA: hda/conexant - Fix loopback issue with CX20632 2022-06-14 16:59:38 +02:00
tools perf c2c: Fix sorting in percent_rmt_hitm_cmp() 2022-06-14 16:59:34 +02:00
usr
virt KVM: Prevent module exit until all VMs are freed 2022-04-15 14:14:57 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: co-maintain random.c 2022-06-25 11:49:01 +02:00
Makefile Linux 4.19.248 2022-06-16 13:18:53 +02:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.