From d21f8b83a997c59075bf068d03283314fb27a093 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 28 Dec 2013 03:04:20 +0000 Subject: [PATCH] We can random_start() earlier (not that it does too much) and call arc4random() much earlier. Leading to random pids for anything besides 0 and 1. --- sys/kern/init_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 2e8cade491a..eb6415b145f 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.192 2013/12/01 16:40:56 krw Exp $ */ +/* $OpenBSD: init_main.c,v 1.193 2013/12/28 03:04:20 deraadt Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -340,6 +340,9 @@ main(void *framep) sleep_queue_init(); sched_init_cpu(curcpu()); + random_start(); + srandom(arc4random()); + /* Initialize work queues */ workq_init(); taskq_init(); @@ -447,6 +450,8 @@ main(void *framep) &initproc)) panic("fork init"); + randompid = 1; + /* * Create any kernel threads whose creation was deferred because * initproc had not yet been created. @@ -533,8 +538,6 @@ main(void *framep) microtime(&rtv); srandom((u_int32_t)(rtv.tv_sec ^ rtv.tv_usec) ^ arc4random()); - randompid = 1; - #if defined(MULTIPROCESSOR) /* Boot the secondary processors. */ cpu_boot_secondary_processors(); -- 2.20.1