diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-06-01 22:45:33 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-25 11:55:02 +0100 |
commit | 119e75d8fe4ddc758a04568fdf28f3c3cda130e9 (patch) | |
tree | 2b4d726990c8ce9523ec74bf6f076175d9be62f1 | |
parent | 2da1f95085791ad8912dc4d9584e2ae003616662 (diff) | |
download | linux-stable-119e75d8fe4ddc758a04568fdf28f3c3cda130e9.tar.gz linux-stable-119e75d8fe4ddc758a04568fdf28f3c3cda130e9.tar.bz2 linux-stable-119e75d8fe4ddc758a04568fdf28f3c3cda130e9.zip |
random: always mix cycle counter in add_latent_entropy()
[ Upstream commit d7bf7f3b813e3755226bcb5114ad2ac477514ebf ]
add_latent_entropy() is called every time a process forks, in
kernel_clone(). This in turn calls add_device_randomness() using the
latent entropy global state. add_device_randomness() does two things:
2) Mixes into the input pool the latent entropy argument passed; and
1) Mixes in a cycle counter, a sort of measurement of when the event
took place, the high precision bits of which are presumably
difficult to predict.
(2) is impossible without CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y. But (1) is
always possible. However, currently CONFIG_GCC_PLUGIN_LATENT_ENTROPY=n
disables both (1) and (2), instead of just (2).
This commit causes the CONFIG_GCC_PLUGIN_LATENT_ENTROPY=n case to still
do (1) by passing NULL (len 0) to add_device_randomness() when add_latent_
entropy() is called.
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Emese Revfy <re.emese@gmail.com>
Fixes: 38addce8b600 ("gcc-plugins: Add latent_entropy plugin")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | include/linux/random.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/random.h b/include/linux/random.h index 917470c4490a..ed2bac6c7a8a 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -19,14 +19,14 @@ void add_input_randomness(unsigned int type, unsigned int code, void add_interrupt_randomness(int irq) __latent_entropy; void add_hwgenerator_randomness(const void *buf, size_t len, size_t entropy); -#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) static inline void add_latent_entropy(void) { +#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy)); -} #else -static inline void add_latent_entropy(void) { } + add_device_randomness(NULL, 0); #endif +} void get_random_bytes(void *buf, size_t len); size_t __must_check get_random_bytes_arch(void *buf, size_t len); |