Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen Remove #ifdef MAP_INHERIT_ZERO.



details:   https://anonhg.NetBSD.org/src/rev/0aa4bbd447d5
branches:  trunk
changeset: 336778:0aa4bbd447d5
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 19 05:46:25 2015 +0000

description:
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.

diffstat:

 lib/libc/gen/arc4random.c |  10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diffs (37 lines):

diff -r 1d94e3d86fc6 -r 0aa4bbd447d5 lib/libc/gen/arc4random.c
--- a/lib/libc/gen/arc4random.c Wed Mar 18 23:03:06 2015 +0000
+++ b/lib/libc/gen/arc4random.c Thu Mar 19 05:46:25 2015 +0000
@@ -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 @@
        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



Home | Main Index | Thread Index | Old Index