diff options
author | Waley Chen <waleycz@gmail.com> | 2016-08-09 14:39:25 -0400 |
---|---|---|
committer | Waley Chen <waleycz@gmail.com> | 2016-08-10 12:39:02 -0400 |
commit | 0c342db5f08551253ddd77c1f3d9bbedb9820ee0 (patch) | |
tree | a342dc3196abda133c6264c4c54ce1ed1ab332f2 | |
parent | 82a188cc0a0b33badcc64f294908b1f629b0fb05 (diff) | |
download | mongo-0c342db5f08551253ddd77c1f3d9bbedb9820ee0.tar.gz |
SERVER-21503 Update SecureAllocator to use MADV_DONTDUMP
-rw-r--r-- | src/mongo/base/secure_allocator.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/base/secure_allocator.cpp b/src/mongo/base/secure_allocator.cpp index ecfc6b12f0d..b888c6e781a 100644 --- a/src/mongo/base/secure_allocator.cpp +++ b/src/mongo/base/secure_allocator.cpp @@ -154,10 +154,21 @@ void* systemAllocate(std::size_t bytes) { fassertFailed(28832); } +#if defined(MADV_DONTDUMP) + // We deliberately ignore the return value since if the Linux version is < 3.4, madvise + // will fail since MADV_DONTDUMP is not supported. + (void)madvise(ptr, bytes, MADV_DONTDUMP); +#endif + return ptr; } void systemDeallocate(void* ptr, std::size_t bytes) { +#if defined(MADV_DONTDUMP) && defined(MADV_DODUMP) + // See comment above madvise in systemAllocate(). + (void)madvise(ptr, bytes, MADV_DODUMP); +#endif + if (munlock(ptr, bytes) != 0) { severe() << errnoWithPrefix("Failed to munlock"); fassertFailed(28833); |