From 28cc8c738305152ba1636b91a1fc01ed7bcc4d40 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 19 Jan 2014 12:45:37 +0000 Subject: Initialize ci_randseed better using arc4random() + a trick. Remove the libkern srandom() API since it is not suitable for this use. ok kettenis miod --- sys/lib/libkern/libkern.h | 3 +-- sys/lib/libkern/random.c | 18 +++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'sys/lib') diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index 9de6fbf84b4..43f38bab50c 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libkern.h,v 1.31 2013/07/11 01:20:32 jsg Exp $ */ +/* $OpenBSD: libkern.h,v 1.32 2014/01/19 12:45:36 deraadt Exp $ */ /* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */ /*- @@ -153,7 +153,6 @@ int flsl(long); void *memchr(const void *, int, size_t); int memcmp(const void *, const void *, size_t); u_int32_t random(void); -void srandom(u_int32_t); int scanc(u_int, const u_char *, const u_char [], int); int skpc(int, size_t, u_char *); size_t strlen(const char *); diff --git a/sys/lib/libkern/random.c b/sys/lib/libkern/random.c index d78e1b0607a..26a9173702d 100644 --- a/sys/lib/libkern/random.c +++ b/sys/lib/libkern/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.8 2008/10/15 23:23:51 deraadt Exp $ */ +/* $OpenBSD: random.c,v 1.9 2014/01/19 12:45:36 deraadt Exp $ */ /* $NetBSD: random.c,v 1.2 1994/10/26 06:42:42 cgd Exp $ */ /*- @@ -38,22 +38,10 @@ #include /* - * Pseudo-random number generator for randomizing the profiling clock, - * and whatever else we might use it for. The result is uniform on - * [0, 2^31 - 1]. + * Pseudo-random number generator for randomizing the profiling clock. + * The result is uniform on [0, 2^31 - 1]. */ -void -srandom(u_int32_t seed) -{ - struct cpu_info *ci = curcpu(); - - seed &= 0x7fffffff; - if (seed == 0) - seed = 1; - ci->ci_randseed = seed; -} - u_int32_t random(void) { -- cgit v1.2.3