From 0c342db5f08551253ddd77c1f3d9bbedb9820ee0 Mon Sep 17 00:00:00 2001 From: Waley Chen Date: Tue, 9 Aug 2016 14:39:25 -0400 Subject: SERVER-21503 Update SecureAllocator to use MADV_DONTDUMP --- src/mongo/base/secure_allocator.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); -- cgit v1.2.1