]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
random(4): Make entropy source deregistration safe
authorcem <cem@FreeBSD.org>
Mon, 30 Dec 2019 01:38:19 +0000 (01:38 +0000)
committercem <cem@FreeBSD.org>
Mon, 30 Dec 2019 01:38:19 +0000 (01:38 +0000)
commit5533a2632ceb7f84f11cd2e68639251f4ad2bb96
tree1128f255a3f2eacca8b9fb7763578fe771b8bfaa
parent8929ab40f556911f4e18cebe11c66c863630a961
random(4): Make entropy source deregistration safe

Allow loadable modules that provide random entropy source(s) to safely
unload.  Prior to this change, no driver could ensure that their
random_source structure was not being used by random_harvestq.c for any
period of time after invoking random_source_deregister().

This change converts the source_list LIST to a ConcurrencyKit CK_LIST and
uses an epoch(9) to protect typical read accesses of the list.  The existing
HARVEST_LOCK spin mutex is used to safely add and remove list entries.
random_source_deregister() uses epoch_wait() to ensure no concurrent
source_list readers are accessing a random_source before freeing the list
item and returning to the caller.

Callers can safely unload immediately after random_source_deregister()
returns.

Reviewed by: markj
Approved by: csprng(markm)
Discussed with: jhb
Differential Revision: https://reviews.freebsd.org/D22489
sys/dev/random/random_harvestq.c