summaryrefslogtreecommitdiff
path: root/include/linux/random.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-03-01 20:22:39 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2022-03-12 18:00:56 -0700
commitf3c2682bad7bc6033c837e9c66e5af881fe8d465 (patch)
treef0101c73dee541fd4cd6e599e26f5e5b1195190e /include/linux/random.h
parent5acd35487dc911541672b3ffc322851769c32a56 (diff)
random: provide notifier for VM fork
Drivers such as WireGuard need to learn when VMs fork in order to clear sessions. This commit provides a simple notifier_block for that, with a register and unregister function. When no VM fork detection is compiled in, this turns into a no-op, similar to how the power notifier works. Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'include/linux/random.h')
-rw-r--r--include/linux/random.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/random.h b/include/linux/random.h
index fab1ab0563b4..c0baffe7afb1 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -32,6 +32,11 @@ extern void add_hwgenerator_randomness(const void *buffer, size_t count,
size_t entropy);
#if IS_ENABLED(CONFIG_VMGENID)
extern void add_vmfork_randomness(const void *unique_vm_id, size_t size);
+extern int register_random_vmfork_notifier(struct notifier_block *nb);
+extern int unregister_random_vmfork_notifier(struct notifier_block *nb);
+#else
+static inline int register_random_vmfork_notifier(struct notifier_block *nb) { return 0; }
+static inline int unregister_random_vmfork_notifier(struct notifier_block *nb) { return 0; }
#endif
extern void get_random_bytes(void *buf, size_t nbytes);