summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-03-01 22:03:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-30 10:29:10 +0300
commit6da877d2d46ba59a65352061cafbdac790cb8d68 (patch)
tree2069860480106e193e5c8501060bbbd86470aa61 /include
parent39c9e5566ac590ad2c9e488baaf6058c251b8fb5 (diff)
downloadlinux-6da877d2d46ba59a65352061cafbdac790cb8d68.tar.xz
random: replace custom notifier chain with standard one
commit 5acd35487dc911541672b3ffc322851769c32a56 upstream. We previously rolled our own randomness readiness notifier, which only has two users in the whole kernel. Replace this with a more standard atomic notifier block that serves the same purpose with less code. Also unexport the symbols, because no modules use it, only unconditional builtins. The only drawback is that it's possible for a notification handler returning the "stop" code to prevent further processing, but given that there are only two users, and that we're unexporting this anyway, that doesn't seem like a significant drawback for the simplification we receive here. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net> [Jason: for stable, also backported to crypto/drbg.c, not unexporting.] Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/crypto/drbg.h2
-rw-r--r--include/linux/random.h10
2 files changed, 4 insertions, 8 deletions
diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h
index c4165126937e..88e4d145f7cd 100644
--- a/include/crypto/drbg.h
+++ b/include/crypto/drbg.h
@@ -136,7 +136,7 @@ struct drbg_state {
const struct drbg_state_ops *d_ops;
const struct drbg_core *core;
struct drbg_string test_data;
- struct random_ready_callback random_ready;
+ struct notifier_block random_ready;
};
static inline __u8 drbg_statelen(struct drbg_state *drbg)
diff --git a/include/linux/random.h b/include/linux/random.h
index 6148b8d1ccf3..d4abda9e2348 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -10,11 +10,7 @@
#include <uapi/linux/random.h>
-struct random_ready_callback {
- struct list_head list;
- void (*func)(struct random_ready_callback *rdy);
- struct module *owner;
-};
+struct notifier_block;
extern void add_device_randomness(const void *, size_t);
extern void add_bootloader_randomness(const void *, size_t);
@@ -39,8 +35,8 @@ extern void get_random_bytes(void *buf, size_t nbytes);
extern int wait_for_random_bytes(void);
extern int __init rand_initialize(void);
extern bool rng_is_initialized(void);
-extern int add_random_ready_callback(struct random_ready_callback *rdy);
-extern void del_random_ready_callback(struct random_ready_callback *rdy);
+extern int register_random_ready_notifier(struct notifier_block *nb);
+extern int unregister_random_ready_notifier(struct notifier_block *nb);
extern size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes);
#ifndef MODULE