aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-26 17:50:04 -0400
committerJack Lloyd <[email protected]>2018-03-26 17:50:04 -0400
commitf1c44e92bcc00d814a48876405fcb87bac9f11c0 (patch)
tree5a71384fcd4d66cc9cb69b713fc08653df2f31d4 /src
parent6747faa63553d80276fd6eb54523ddbc38153eaa (diff)
Add back posix_mlock flag
We need a distinct flag for this because Haiku is mostly POSIX but does not support mlock.
Diffstat (limited to 'src')
-rw-r--r--src/build-data/os/aix.txt1
-rw-r--r--src/build-data/os/android.txt3
-rw-r--r--src/build-data/os/darwin.txt1
-rw-r--r--src/build-data/os/dragonfly.txt1
-rw-r--r--src/build-data/os/freebsd.txt1
-rw-r--r--src/build-data/os/hpux.txt1
-rw-r--r--src/build-data/os/hurd.txt1
-rw-r--r--src/build-data/os/ios.txt1
-rw-r--r--src/build-data/os/linux.txt1
-rw-r--r--src/build-data/os/netbsd.txt1
-rw-r--r--src/build-data/os/openbsd.txt1
-rw-r--r--src/build-data/os/qnx.txt1
-rw-r--r--src/build-data/os/solaris.txt1
-rw-r--r--src/lib/utils/os_utils.cpp6
14 files changed, 20 insertions, 1 deletions
diff --git a/src/build-data/os/aix.txt b/src/build-data/os/aix.txt
index caf94fdd4..be5a8717e 100644
--- a/src/build-data/os/aix.txt
+++ b/src/build-data/os/aix.txt
@@ -5,6 +5,7 @@ use_stack_protector no
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
proc_fs
diff --git a/src/build-data/os/android.txt b/src/build-data/os/android.txt
index b45287b54..3b0b0c09a 100644
--- a/src/build-data/os/android.txt
+++ b/src/build-data/os/android.txt
@@ -3,9 +3,10 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
+clock_gettime
dev_random
-clock_gettime
# getauxval is available in Android NDK for min API 18 and in Crystax NDK
# for all min API levels. Use --without-os-feature=getauxval to disable
diff --git a/src/build-data/os/darwin.txt b/src/build-data/os/darwin.txt
index e32a5c4c6..056d535e7 100644
--- a/src/build-data/os/darwin.txt
+++ b/src/build-data/os/darwin.txt
@@ -11,6 +11,7 @@ doc_dir doc
<target_features>
posix1
+posix_mlock
arc4random
dev_random
security_framework
diff --git a/src/build-data/os/dragonfly.txt b/src/build-data/os/dragonfly.txt
index 257b2ef6b..6cf794948 100644
--- a/src/build-data/os/dragonfly.txt
+++ b/src/build-data/os/dragonfly.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
proc_fs
dev_random
diff --git a/src/build-data/os/freebsd.txt b/src/build-data/os/freebsd.txt
index 4de44a318..2ff60844a 100644
--- a/src/build-data/os/freebsd.txt
+++ b/src/build-data/os/freebsd.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
arc4random
diff --git a/src/build-data/os/hpux.txt b/src/build-data/os/hpux.txt
index 112ad1ea3..f9a74f639 100644
--- a/src/build-data/os/hpux.txt
+++ b/src/build-data/os/hpux.txt
@@ -4,6 +4,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
diff --git a/src/build-data/os/hurd.txt b/src/build-data/os/hurd.txt
index 29ca47490..6d12c9a48 100644
--- a/src/build-data/os/hurd.txt
+++ b/src/build-data/os/hurd.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
dev_random
clock_gettime
diff --git a/src/build-data/os/ios.txt b/src/build-data/os/ios.txt
index a5ffab696..0e3eb7c4b 100644
--- a/src/build-data/os/ios.txt
+++ b/src/build-data/os/ios.txt
@@ -7,6 +7,7 @@ doc_dir doc
<target_features>
posix1
+posix_mlock
arc4random
sockets
diff --git a/src/build-data/os/linux.txt b/src/build-data/os/linux.txt
index 7029adbef..6f4f3d644 100644
--- a/src/build-data/os/linux.txt
+++ b/src/build-data/os/linux.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
dev_random
proc_fs
diff --git a/src/build-data/os/netbsd.txt b/src/build-data/os/netbsd.txt
index 4de44a318..2ff60844a 100644
--- a/src/build-data/os/netbsd.txt
+++ b/src/build-data/os/netbsd.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
arc4random
diff --git a/src/build-data/os/openbsd.txt b/src/build-data/os/openbsd.txt
index 9c6c8b707..5ba148e66 100644
--- a/src/build-data/os/openbsd.txt
+++ b/src/build-data/os/openbsd.txt
@@ -5,6 +5,7 @@ soname_pattern_patch "lib{libname}.so.{abi_rev}.{version_minor}"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
arc4random
diff --git a/src/build-data/os/qnx.txt b/src/build-data/os/qnx.txt
index 70810d2d9..1cf671ce7 100644
--- a/src/build-data/os/qnx.txt
+++ b/src/build-data/os/qnx.txt
@@ -2,6 +2,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
diff --git a/src/build-data/os/solaris.txt b/src/build-data/os/solaris.txt
index f2bfca616..c729f6aa1 100644
--- a/src/build-data/os/solaris.txt
+++ b/src/build-data/os/solaris.txt
@@ -3,6 +3,7 @@ soname_suffix "so"
<target_features>
posix1
+posix_mlock
clock_gettime
dev_random
proc_fs
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index f2813b323..c7f04a855 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -325,11 +325,13 @@ void* OS::allocate_locked_pages(size_t length)
::madvise(ptr, length, MADV_DONTDUMP);
#endif
+#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
if(::mlock(ptr, length) != 0)
{
::munmap(ptr, length);
return nullptr; // failed to lock
}
+#endif
::memset(ptr, 0, length);
@@ -361,7 +363,11 @@ void OS::free_locked_pages(void* ptr, size_t length)
#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
secure_scrub_memory(ptr, length);
+
+#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
::munlock(ptr, length);
+#endif
+
::munmap(ptr, length);
#elif defined(BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK)
secure_scrub_memory(ptr, length);