[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Mon Nov 16 12:15:37 UTC 2015


The branch master has been updated
       via  27186da71560e5ce09de36ffd039e5abdc7637a9 (commit)
      from  9d0e4dc6351df7d0c08400c4b4cf17c017022e50 (commit)


- Log -----------------------------------------------------------------
commit 27186da71560e5ce09de36ffd039e5abdc7637a9
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Nov 13 21:30:44 2015 +0100

    crypto/sec_mem.c: fix anonymous mmap on legacy systems.
    
    Reviewed-by: Kurt Roeckx <kurt at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/sec_mem.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/crypto/sec_mem.c b/crypto/sec_mem.c
index b7a9d3b..2e29219 100644
--- a/crypto/sec_mem.c
+++ b/crypto/sec_mem.c
@@ -19,8 +19,11 @@
 # include <string.h>
 # include <assert.h>
 # include <unistd.h>
+# include <sys/types.h>
 # include <sys/mman.h>
 # include <sys/param.h>
+# include <sys/stat.h>
+# include <fcntl.h>
 #endif
 
 #define LOCK()      CRYPTO_w_lock(CRYPTO_LOCK_MALLOC)
@@ -336,8 +339,21 @@ static int sh_init(size_t size, int minsize)
     pgsize = PAGE_SIZE;
 #endif
     sh.map_size = pgsize + sh.arena_size + pgsize;
-    sh.map_result = mmap(NULL, sh.map_size,
-                         PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
+    if (1) {
+#ifdef MAP_ANON
+        sh.map_result = mmap(NULL, sh.map_size,
+                             PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
+    } else {
+#endif
+        int fd;
+
+        sh.map_result = MAP_FAILED;
+        if ((fd = open("/dev/zero", O_RDWR)) >= 0) {
+            sh.map_result = mmap(NULL, sh.map_size,
+                                 PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+            close(fd);
+        }
+    }
     OPENSSL_assert(sh.map_result != MAP_FAILED);
     if (sh.map_result == MAP_FAILED)
         goto err;


More information about the openssl-commits mailing list