diff options
author | Jack Lloyd <[email protected]> | 2019-07-27 15:09:46 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-07-27 15:09:46 -0400 |
commit | 94ffe5e4df60a397cc7e95fed9b5c2836afd1b87 (patch) | |
tree | f17d18b14003dcff0572c85383ddfa03c8c6ea21 | |
parent | c44e822fdef57bdd01193c8ceb5ec52f4b1c1a07 (diff) | |
parent | efccea267d3989069d06d022d4679717356af026 (diff) |
Merge GH #2050 Allow monitoring of locked pages on iOS/macOS
-rw-r--r-- | src/lib/utils/os_utils.cpp | 10 |
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) { |