Module Name:    src
Committed By:   riastradh
Date:           Thu Mar 19 05:46:25 UTC 2015

Modified Files:
        src/lib/libc/gen: arc4random.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/gen/arc4random.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/arc4random.c
diff -u src/lib/libc/gen/arc4random.c:1.28 src/lib/libc/gen/arc4random.c:1.29
--- src/lib/libc/gen/arc4random.c:1.28	Wed Jan 21 02:47:39 2015
+++ src/lib/libc/gen/arc4random.c	Thu Mar 19 05:46:25 2015
@@ -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 <sys/cdefs.h>
-__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

Reply via email to