Re: [PATCH] random: do not export add_vmfork_randomness() unless needed

From: Theodore Ts'o
Date: Tue Mar 01 2022 - 14:00:25 EST


On Tue, Mar 01, 2022 at 03:25:28PM +0100, Jason A. Donenfeld wrote:
> 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 it
> and simply crng_reseed().

How about only exporting add_vmfork_randomness if VMGENID is compiled
as a module? If it's built-in to the kernel, no need to export the
symbol.

- Ted