Page MenuHomeFreeBSD

D22512.id64751.diff
No OneTemporary

D22512.id64751.diff

Index: UPDATING
===================================================================
--- UPDATING
+++ UPDATING
@@ -26,6 +26,9 @@
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+2019xxxx:
+ Kernel-loadable random(4) modules are no longer unloadable.
+
20191120:
The amd(8) automount daemon has been disabled by default, and will be
removed in the future. As of FreeBSD 10.1 the autofs(5) is available
Index: sys/dev/random/random_harvestq.c
===================================================================
--- sys/dev/random/random_harvestq.c
+++ sys/dev/random/random_harvestq.c
@@ -49,11 +49,6 @@
#include <sys/sysctl.h>
#include <sys/unistd.h>
-#if defined(RANDOM_LOADABLE)
-#include <sys/lock.h>
-#include <sys/sx.h>
-#endif
-
#include <machine/atomic.h>
#include <machine/cpu.h>
@@ -164,13 +159,9 @@
random_harvestq_fast_process_event(struct harvest_event *event)
{
#if defined(RANDOM_LOADABLE)
- RANDOM_CONFIG_S_LOCK();
- if (p_random_alg_context)
+ if (p_random_alg_context != NULL)
#endif
p_random_alg_context->ra_event_processor(event);
-#if defined(RANDOM_LOADABLE)
- RANDOM_CONFIG_S_UNLOCK();
-#endif
explicit_bzero(event, sizeof(*event));
}
@@ -231,9 +222,8 @@
* to the system-wide RNG.
*/
#if defined(RANDOM_LOADABLE)
- RANDOM_CONFIG_S_LOCK();
- if (p_random_alg_context) {
- /* It's an indenting error. Yeah, Yeah. */
+ if (p_random_alg_context == NULL)
+ return;
#endif
local_read_rate = atomic_readandclear_32(&read_rate);
/* Perform at least one read per round */
@@ -261,10 +251,6 @@
}
}
explicit_bzero(entropy, sizeof(entropy));
-#if defined(RANDOM_LOADABLE)
- }
- RANDOM_CONFIG_S_UNLOCK();
-#endif
}
void
Index: sys/dev/random/random_infra.c
===================================================================
--- sys/dev/random/random_infra.c
+++ sys/dev/random/random_infra.c
@@ -35,11 +35,6 @@
#include <sys/random.h>
#include <sys/sysctl.h>
-#if defined(RANDOM_LOADABLE)
-#include <sys/lock.h>
-#include <sys/sx.h>
-#endif
-
#include <dev/random/randomdev.h>
/* Set up the sysctl root node for the entropy device */
@@ -121,87 +116,50 @@
return (false);
}
-struct random_readers {
+static struct random_readers {
int (*read_random_uio)(struct uio *, bool);
void (*read_random)(void *, u_int);
bool (*is_random_seeded)(void);
} random_reader_context = {
- (int (*)(struct uio *, bool))nullop,
+ (int (*)(struct uio *, bool))null_read_random,
null_read_random,
null_is_random_seeded,
};
-struct sx randomdev_config_lock;
-
-static void
-random_infra_sysinit(void *dummy __unused)
-{
-
- RANDOM_CONFIG_INIT_LOCK();
-}
-SYSINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_FIRST, random_infra_sysinit, NULL);
-
void
random_infra_init(int (*p_random_read_uio)(struct uio *, bool),
void (*p_random_read)(void *, u_int),
bool (*p_is_random_seeded)(void))
{
+#ifdef INVARIANTS
+ static bool loaded_once = false;
+
+ KASSERT(!loaded_once, ("%s: attempt to load a second randomdev module",
+ __func__));
+ loaded_once = true;
+#endif
- RANDOM_CONFIG_X_LOCK();
random_reader_context.read_random_uio = p_random_read_uio;
random_reader_context.read_random = p_random_read;
random_reader_context.is_random_seeded = p_is_random_seeded;
- RANDOM_CONFIG_X_UNLOCK();
-}
-
-void
-random_infra_uninit(void)
-{
-
- RANDOM_CONFIG_X_LOCK();
- random_reader_context.read_random_uio = (int (*)(struct uio *, bool))nullop;
- random_reader_context.read_random = null_read_random;
- random_reader_context.is_random_seeded = null_is_random_seeded;
- RANDOM_CONFIG_X_UNLOCK();
-}
-
-static void
-random_infra_sysuninit(void *dummy __unused)
-{
-
- RANDOM_CONFIG_DEINIT_LOCK();
}
-SYSUNINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_FIRST, random_infra_sysuninit, NULL);
int
read_random_uio(struct uio *uio, bool nonblock)
{
- int retval;
-
- RANDOM_CONFIG_S_LOCK();
- retval = random_reader_context.read_random_uio(uio, nonblock);
- RANDOM_CONFIG_S_UNLOCK();
- return (retval);
+ return (random_reader_context.read_random_uio(uio, nonblock));
}
void
read_random(void *buf, u_int len)
{
-
- RANDOM_CONFIG_S_LOCK();
random_reader_context.read_random(buf, len);
- RANDOM_CONFIG_S_UNLOCK();
}
bool
is_random_seeded(void)
{
- bool result;
-
- RANDOM_CONFIG_S_LOCK();
- result = random_reader_context.is_random_seeded();
- RANDOM_CONFIG_S_UNLOCK();
- return (result);
+ return (random_reader_context.is_random_seeded());
}
Index: sys/dev/random/randomdev.h
===================================================================
--- sys/dev/random/randomdev.h
+++ sys/dev/random/randomdev.h
@@ -106,16 +106,8 @@
void random_source_deregister(struct random_source *);
#if defined(RANDOM_LOADABLE)
-extern struct sx randomdev_config_lock;
-#define RANDOM_CONFIG_INIT_LOCK(x) sx_init(&randomdev_config_lock, "configuration change lock")
-#define RANDOM_CONFIG_X_LOCK(x) sx_xlock(&randomdev_config_lock)
-#define RANDOM_CONFIG_X_UNLOCK(x) sx_xunlock(&randomdev_config_lock)
-#define RANDOM_CONFIG_S_LOCK(x) sx_slock(&randomdev_config_lock)
-#define RANDOM_CONFIG_S_UNLOCK(x) sx_sunlock(&randomdev_config_lock)
-#define RANDOM_CONFIG_DEINIT_LOCK(x) sx_destroy(&randomdev_config_lock)
void random_infra_init(int (*)(struct uio *, bool), void (*)(void *, u_int),
bool (*)(void));
-void random_infra_uninit(void);
#endif
#endif /* _KERNEL */
Index: sys/dev/random/randomdev.c
===================================================================
--- sys/dev/random/randomdev.c
+++ sys/dev/random/randomdev.c
@@ -104,9 +104,6 @@
random_alg_context_ra_deinit_alg(void *data)
{
-#if defined(RANDOM_LOADABLE)
- random_infra_uninit();
-#endif
p_random_alg_context->ra_deinit_alg(data);
p_random_alg_context = NULL;
}
@@ -424,7 +421,7 @@
make_dev_alias(random_dev, "urandom"); /* compatibility */
break;
case MOD_UNLOAD:
- destroy_dev(random_dev);
+ error = EBUSY;
break;
case MOD_SHUTDOWN:
break;

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 24, 10:12 PM (8 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34277917
Default Alt Text
D22512.id64751.diff (5 KB)

Event Timeline