/*
- * Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2004-2014, Akamai Technologies. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
# include <sys/stat.h>
# include <fcntl.h>
#endif
+#ifndef HAVE_MADVISE
+# if defined(MADV_DONTDUMP)
+# define HAVE_MADVISE 1
+# else
+# define HAVE_MADVISE 0
+# endif
+#endif
+#if HAVE_MADVISE
+# undef NO_MADVISE
+#else
+# define NO_MADVISE
+#endif
#define CLEAR(p, s) OPENSSL_cleanse(p, s)
#ifndef PAGE_SIZE
size_t CRYPTO_secure_used(void)
{
+ size_t ret = 0;
+
#ifndef OPENSSL_NO_SECURE_MEMORY
- return secure_mem_used;
-#else
- return 0;
+ if (!CRYPTO_THREAD_read_lock(sec_malloc_lock))
+ return 0;
+
+ ret = secure_mem_used;
+
+ CRYPTO_THREAD_unlock(sec_malloc_lock);
#endif /* OPENSSL_NO_SECURE_MEMORY */
+ return ret;
}
size_t CRYPTO_secure_actual_size(void *ptr)
if (mlock(sh.arena, sh.arena_size) < 0)
ret = 2;
#endif
-#ifdef MADV_DONTDUMP
+#ifndef NO_MADVISE
if (madvise(sh.arena, sh.arena_size, MADV_DONTDUMP) < 0)
ret = 2;
#endif