aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-07-27 15:09:46 -0400
committerJack Lloyd <[email protected]>2019-07-27 15:09:46 -0400
commit94ffe5e4df60a397cc7e95fed9b5c2836afd1b87 (patch)
treef17d18b14003dcff0572c85383ddfa03c8c6ea21 /src
parentc44e822fdef57bdd01193c8ceb5ec52f4b1c1a07 (diff)
parentefccea267d3989069d06d022d4679717356af026 (diff)
Merge GH #2050 Allow monitoring of locked pages on iOS/macOS
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils/os_utils.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 50ebbb072..daa5bb73f 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -430,11 +430,19 @@ std::vector<void*> OS::allocate_locked_pages(size_t count)
#define PROT_MAX(p) 0
#endif
const int pflags = PROT_READ | PROT_WRITE;
+#if defined(BOTAN_TARGET_OS_IS_IOS) || defined(BOTAN_TARGET_OS_IS_MACOS)
+// On Darwin, tagging anonymous pages allows vmmap to track these.
+// Allowed from 240 to 255 for userland applications, taken an hardcoded
+// value for now even though it can possibly intersect.
+ const int locked_fd = (255<<24);
+#else
+ const int locked_fd = -1;
+#endif
ptr = ::mmap(nullptr, 2*page_size,
pflags | PROT_MAX(pflags),
MAP_ANONYMOUS | MAP_PRIVATE | MAP_NOCORE,
- /*fd=*/-1, /*offset=*/0);
+ /*fd=*/locked_fd, /*offset=*/0);
if(ptr == MAP_FAILED)
{