From cc8a3a240dcf9af853282c447676e96d3ac0d6a7 Mon Sep 17 00:00:00 2001 From: riastradh Date: Thu, 19 Mar 2015 05:46:25 +0000 Subject: [PATCH] Remove #ifdef MAP_INHERIT_ZERO. This is essential for fork-safety, so don't merely #warn about it. Attaining fork-safety without it requires restructuring things -- in particular, there's no clear way to make it per-thread and fork-safe without some global list of states to zero on fork. --- lib/libc/gen/arc4random.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 7e4dffc28cfa..695aaf9dea6a 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -1,4 +1,4 @@ -/* $NetBSD: arc4random.c,v 1.28 2015/01/21 02:47:39 riastradh Exp $ */ +/* $NetBSD: arc4random.c,v 1.29 2015/03/19 05:46:25 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -52,7 +52,7 @@ */ #include -__RCSID("$NetBSD: arc4random.c,v 1.28 2015/01/21 02:47:39 riastradh Exp $"); +__RCSID("$NetBSD: arc4random.c,v 1.29 2015/03/19 05:46:25 riastradh Exp $"); #include "namespace.h" #include "reentrant.h" @@ -447,18 +447,12 @@ arc4random_prng_create(void) prng = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); if (prng == MAP_FAILED) goto fail0; -#ifdef MAP_INHERIT_ZERO if (minherit(prng, size, MAP_INHERIT_ZERO) == -1) goto fail1; -#else -#warning This arc4random is not fork-safe! -#endif return prng; -#ifdef MAP_INHERIT_ZERO fail1: (void)munmap(prng, size); -#endif fail0: return NULL; } #endif