OpenSSL 1.1.1-pre2

This commit is contained in:
Hakase
2018-04-07 17:29:40 +09:00
parent 82a44d2483
commit bbac8ca55d
17755 changed files with 221242 additions and 98415 deletions
+23 -14
View File
@@ -1,5 +1,6 @@
/*
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2004-2014, Akamai Technologies. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -7,11 +8,6 @@
* https://www.openssl.org/source/license.html
*/
/*
* Copyright 2004-2014, Akamai Technologies. All Rights Reserved.
* This file is distributed under the terms of the OpenSSL license.
*/
/*
* This file is in two halves. The first half implements the public API
* to be used by external consumers, and to be used by OpenSSL to store
@@ -19,8 +15,8 @@
* For details on that implementation, see below (look for uppercase
* "SECURE HEAP IMPLEMENTATION").
*/
#include "e_os.h"
#include <openssl/crypto.h>
#include <e_os.h>
#include <string.h>
@@ -35,6 +31,11 @@
# include <unistd.h>
# include <sys/types.h>
# include <sys/mman.h>
# if defined(OPENSSL_SYS_LINUX)
# include <sys/syscall.h>
# include <linux/mman.h>
# include <errno.h>
# endif
# include <sys/param.h>
# include <sys/stat.h>
# include <fcntl.h>
@@ -44,9 +45,6 @@
#ifndef PAGE_SIZE
# define PAGE_SIZE 4096
#endif
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
# define MAP_ANON MAP_ANONYMOUS
#endif
#ifdef IMPLEMENTED
static size_t secure_mem_used;
@@ -59,8 +57,8 @@ static CRYPTO_RWLOCK *sec_malloc_lock = NULL;
* These are the functions that must be implemented by a secure heap (sh).
*/
static int sh_init(size_t size, int minsize);
static char *sh_malloc(size_t size);
static void sh_free(char *ptr);
static void *sh_malloc(size_t size);
static void sh_free(void *ptr);
static void sh_done(void);
static size_t sh_actual_size(char *ptr);
static int sh_allocated(const char *ptr);
@@ -472,8 +470,19 @@ static int sh_init(size_t size, int minsize)
if (mprotect(sh.map_result + aligned, pgsize, PROT_NONE) < 0)
ret = 2;
#if defined(OPENSSL_SYS_LINUX) && defined(MLOCK_ONFAULT) && defined(SYS_mlock2)
if (syscall(SYS_mlock2, sh.arena, sh.arena_size, MLOCK_ONFAULT) < 0) {
if (errno == ENOSYS) {
if (mlock(sh.arena, sh.arena_size) < 0)
ret = 2;
} else {
ret = 2;
}
}
#else
if (mlock(sh.arena, sh.arena_size) < 0)
ret = 2;
#endif
#ifdef MADV_DONTDUMP
if (madvise(sh.arena, sh.arena_size, MADV_DONTDUMP) < 0)
ret = 2;
@@ -515,7 +524,7 @@ static char *sh_find_my_buddy(char *ptr, int list)
return chunk;
}
static char *sh_malloc(size_t size)
static void *sh_malloc(size_t size)
{
ossl_ssize_t list, slist;
size_t i;
@@ -577,10 +586,10 @@ static char *sh_malloc(size_t size)
return chunk;
}
static void sh_free(char *ptr)
static void sh_free(void *ptr)
{
size_t list;
char *buddy;
void *buddy;
if (ptr == NULL)
return;