diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-01-19 12:45:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-01-19 12:45:37 +0000 |
commit | 28cc8c738305152ba1636b91a1fc01ed7bcc4d40 (patch) | |
tree | 667da0156500e5484c9dc2c21d8068352afa40fd /sys/arch | |
parent | a69dcedd6829f0cd8f3dd427ebba96d41ed91e35 (diff) |
Initialize ci_randseed better using arc4random() + a trick. Remove the
libkern srandom() API since it is not suitable for this use.
ok kettenis miod
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/cpu.c | 5 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/cpu.c | 6 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/machdep.c | 5 | ||||
-rw-r--r-- | sys/arch/hppa/dev/cpu.c | 5 | ||||
-rw-r--r-- | sys/arch/i386/i386/cpu.c | 6 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/machdep.c | 5 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/cpu.c | 6 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/cpu.c | 5 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/machdep.c | 5 | ||||
-rw-r--r-- | sys/arch/socppc/socppc/cpu.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/cpu.c | 5 |
11 files changed, 32 insertions, 25 deletions
diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index 47ca2118cd5..83e18399061 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.30 2013/12/22 18:53:14 miod Exp $ */ +/* $OpenBSD: cpu.c,v 1.31 2014/01/19 12:45:35 deraadt Exp $ */ /* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */ /*- @@ -64,6 +64,7 @@ #include <sys/device.h> #include <sys/proc.h> #include <sys/user.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -399,7 +400,7 @@ cpu_boot_secondary_processors() continue; if (ci->ci_flags & CPUF_PRIMARY) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; /* This processor is all set up; boot it! */ cpu_boot_secondary(ci); diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index ee1a97f2cd9..2039f0c12f6 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.58 2013/12/19 21:30:02 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.59 2014/01/19 12:45:35 deraadt Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -73,6 +73,7 @@ #include <sys/device.h> #include <sys/malloc.h> #include <sys/memrange.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -101,7 +102,6 @@ #include <dev/ic/mc146818reg.h> #include <amd64/isa/nvram.h> #include <dev/isa/isareg.h> -#include <dev/rndvar.h> int cpu_match(struct device *, void *, void *); void cpu_attach(struct device *, struct device *, void *); @@ -591,7 +591,7 @@ cpu_boot_secondary_processors(void) continue; if (ci->ci_flags & (CPUF_BSP|CPUF_SP|CPUF_PRIMARY)) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; cpu_boot_secondary(ci); } } diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c index 68e8bb15093..21c3585eb72 100644 --- a/sys/arch/aviion/aviion/machdep.c +++ b/sys/arch/aviion/aviion/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.59 2013/11/02 23:10:29 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.60 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. * @@ -79,6 +79,7 @@ #include <sys/core.h> #include <sys/kcore.h> #include <sys/device.h> +#include <dev/rndvar.h> #include <machine/asm.h> #include <machine/asm_macro.h> @@ -577,7 +578,7 @@ secondary_main() sched_init_cpu(ci); nanouptime(&ci->ci_schedstate.spc_runtime); ci->ci_curproc = NULL; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; /* * Release cpu_hatch_mutex to let other secondary processors diff --git a/sys/arch/hppa/dev/cpu.c b/sys/arch/hppa/dev/cpu.c index 32b40cfa07f..1c5aebfefb4 100644 --- a/sys/arch/hppa/dev/cpu.c +++ b/sys/arch/hppa/dev/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.40 2013/11/26 20:33:12 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.41 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -31,6 +31,7 @@ #include <sys/device.h> #include <sys/proc.h> #include <sys/reboot.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -200,7 +201,7 @@ cpu_boot_secondary_processors(void) if (ci->ci_cpuid == 0) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; sched_init_cpu(ci); diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c index 41e54c12faf..57e0b479765 100644 --- a/sys/arch/i386/i386/cpu.c +++ b/sys/arch/i386/i386/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.53 2013/12/19 23:44:55 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.54 2014/01/19 12:45:35 deraadt Exp $ */ /* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */ /*- @@ -88,6 +88,7 @@ #include <machine/segments.h> #include <machine/gdt.h> #include <machine/pio.h> +#include <dev/rndvar.h> #if NLAPIC > 0 #include <machine/apicvar.h> @@ -103,7 +104,6 @@ #include <dev/ic/mc146818reg.h> #include <i386/isa/nvram.h> #include <dev/isa/isareg.h> -#include <dev/rndvar.h> int cpu_match(struct device *, void *, void *); void cpu_attach(struct device *, struct device *, void *); @@ -519,7 +519,7 @@ cpu_boot_secondary_processors() continue; if (ci->ci_flags & (CPUF_BSP|CPUF_SP|CPUF_PRIMARY)) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; cpu_boot_secondary(ci); } } diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 2705ac4779d..2946e5af93b 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.93 2013/11/02 23:10:29 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.94 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -76,6 +76,7 @@ #include <sys/extent.h> #include <sys/core.h> #include <sys/kcore.h> +#include <dev/rndvar.h> #include <machine/asm.h> #include <machine/asm_macro.h> @@ -779,7 +780,7 @@ secondary_main() sched_init_cpu(ci); nanouptime(&ci->ci_schedstate.spc_runtime); ci->ci_curproc = NULL; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; /* * Release cpu_hatch_mutex to let other secondary processors diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c index f835f743292..217d58f73a7 100644 --- a/sys/arch/macppc/macppc/cpu.c +++ b/sys/arch/macppc/macppc/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.74 2013/10/31 08:26:12 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.75 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -38,6 +38,7 @@ #include <sys/proc.h> #include <sys/sysctl.h> #include <sys/device.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -240,7 +241,6 @@ cpuattach(struct device *parent, struct device *dev, void *aux) ci = &cpu_info[reg[0]]; ci->ci_cpuid = reg[0]; ci->ci_intrdepth = -1; - ci->ci_randseed = 1; ci->ci_dev = dev; pvr = ppc_mfpvr(); @@ -692,7 +692,7 @@ cpu_boot_secondary_processors(void) ci = &cpu_info[i]; if (ci->ci_cpuid == 0) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; sched_init_cpu(ci); diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c index ea848576067..5e7781503d5 100644 --- a/sys/arch/mips64/mips64/cpu.c +++ b/sys/arch/mips64/mips64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.51 2013/12/19 09:37:14 jasper Exp $ */ +/* $OpenBSD: cpu.c,v 1.52 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se) @@ -31,6 +31,7 @@ #include <sys/proc.h> #include <sys/device.h> #include <sys/malloc.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -404,7 +405,7 @@ cpu_boot_secondary_processors(void) if (ci->ci_flags & CPUF_PRIMARY) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; sched_init_cpu(ci); cpu_boot_secondary(ci); } diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c index badda86e05b..81aeae3376e 100644 --- a/sys/arch/mvme88k/mvme88k/machdep.c +++ b/sys/arch/mvme88k/mvme88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.258 2013/11/02 23:10:29 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.259 2014/01/19 12:45:35 deraadt Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -63,6 +63,7 @@ #include <sys/extent.h> #include <sys/core.h> #include <sys/kcore.h> +#include <dev/rndvar.h> #include <uvm/uvm.h> @@ -623,7 +624,7 @@ secondary_main() sched_init_cpu(ci); nanouptime(&ci->ci_schedstate.spc_runtime); ci->ci_curproc = NULL; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; __cpu_simple_unlock(&cpu_hatch_mutex); diff --git a/sys/arch/socppc/socppc/cpu.c b/sys/arch/socppc/socppc/cpu.c index b9ad04bcca7..6c39c34cc32 100644 --- a/sys/arch/socppc/socppc/cpu.c +++ b/sys/arch/socppc/socppc/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.5 2013/10/31 08:26:12 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.6 2014/01/19 12:45:36 deraadt Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -19,6 +19,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> +#include <dev/rndvar.h> #include <machine/autoconf.h> #include <powerpc/hid.h> @@ -68,7 +69,6 @@ cpu_attach(struct device *parent, struct device *self, void *aux) ci = &cpu_info[0]; ci->ci_cpuid = 0; ci->ci_intrdepth = -1; - ci->ci_randseed = 1; ci->ci_dev = self; printf(": %s\n", cpu_model); diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c index 59501915ffa..421d7173e90 100644 --- a/sys/arch/sparc64/sparc64/cpu.c +++ b/sys/arch/sparc64/sparc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.60 2013/06/03 16:55:22 guenther Exp $ */ +/* $OpenBSD: cpu.c,v 1.61 2014/01/19 12:45:36 deraadt Exp $ */ /* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */ /* @@ -57,6 +57,7 @@ #include <sys/proc.h> #include <sys/sysctl.h> #include <sys/systm.h> +#include <dev/rndvar.h> #include <uvm/uvm_extern.h> @@ -700,7 +701,7 @@ cpu_boot_secondary_processors(void) for (ci = cpus; ci != NULL; ci = ci->ci_next) { if (ci->ci_upaid == cpu_myid()) continue; - ci->ci_randseed = random(); + ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; if (CPU_ISSUN4V) cpuid = ci->ci_upaid; |