diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -2001,16 +2001,15 @@ static int linprocfs_doboot_id(PFS_FILL_ARGS) { - static bool firstboot = 1; - static struct uuid uuid; - - if (firstboot) { - kern_uuidgen(&uuid, 1); - firstboot = 0; - } - sbuf_printf_uuid(sb, &uuid); - sbuf_printf(sb, "\n"); - return(0); + static char boot_id[37]; + int error = 0; + + if ((error = kernel_sysctlbyname(td, "kern.random.boot_id", boot_id, + &sz, 0, 0, 0, 0)) != 0) { + return (error); + } + sbuf_printf(sb, "%s\n", boot_id); + return (0); } /* diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,11 @@ /* For use with make_dev(9)/destroy_dev(9). */ static struct cdev *random_dev; +/* UUID which differs on every boot. */ +static char boot_id[37]; +SYSCTL_STRING(_kern_random, OID_AUTO, boot_id, CTLFLAG_RDTUN, boot_id, + sizeof(boot_id), "UUID which differs on every boot"); + #if defined(RANDOM_LOADABLE) static void random_alg_context_init(void *dummy __unused) @@ -396,6 +402,7 @@ static int randomdev_modevent(module_t mod __unused, int type, void *data __unused) { + struct uuid uuid; int error = 0; switch (type) { @@ -404,6 +411,9 @@ random_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &random_cdevsw, RANDOM_UNIT, NULL, UID_ROOT, GID_WHEEL, 0644, "random"); make_dev_alias(random_dev, "urandom"); /* compatibility */ + + kern_uuidgen(&uuid, 1); + snprintf_uuid(boot_id, sizeof(boot_id), &uuid); break; case MOD_UNLOAD: error = EBUSY;