summaryrefslogtreecommitdiff
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-03-01 17:14:04 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2022-03-13 04:00:56 +0300
commita4107d34f960df99ca07fa8eb022425a804f59f3 (patch)
tree2e13e4c5cf1ef5cb52b27a992ac3fb35acf33fd5 /drivers/char/random.c
parentaf6b54e2b5baa54c844573b6d49cc91157bcdd7e (diff)
downloadlinux-a4107d34f960df99ca07fa8eb022425a804f59f3.tar.xz
random: do not export add_vmfork_randomness() unless needed
Since add_vmfork_randomness() is only called from vmgenid.o, we can guard it in CONFIG_VMGENID, similarly to how we do with add_disk_randomness() and CONFIG_BLOCK. If we ever have multiple things calling into add_vmfork_randomness(), we can add another shared Kconfig symbol for that, but for now, this is good enough. Even though add_vmfork_randomess() is a pretty small function, removing it means that there are only calls to crng_reseed(false) and none to crng_reseed(true), which means the compiler can constant propagate the false, removing branches from crng_reseed() and its descendants. Additionally, we don't even need the symbol to be exported if CONFIG_VMGENID is not a module, so conditionalize that too. Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 2b323f6bd96c..bc2a4f7e3655 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1168,6 +1168,7 @@ void add_bootloader_randomness(const void *buf, size_t size)
}
EXPORT_SYMBOL_GPL(add_bootloader_randomness);
+#if IS_ENABLED(CONFIG_VMGENID)
/*
* Handle a new unique VM ID, which is unique, not secret, so we
* don't credit it, but we do immediately force a reseed after so
@@ -1181,7 +1182,10 @@ void add_vmfork_randomness(const void *unique_vm_id, size_t size)
pr_notice("crng reseeded due to virtual machine fork\n");
}
}
+#if IS_MODULE(CONFIG_VMGENID)
EXPORT_SYMBOL_GPL(add_vmfork_randomness);
+#endif
+#endif
struct fast_pool {
union {