From d831831822885717e9841f1ff67c19add566fa45 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 14 Mar 2019 13:36:24 +0000 Subject: [PATCH] lockedpool: When possible, use madvise to avoid including sensitive information in core dumps --- src/support/lockedpool.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 070b3ed80e7..fc1f660aece 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -250,6 +250,9 @@ void *PosixLockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess) addr = mmap(nullptr, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (addr) { *lockingSuccess = mlock(addr, len) == 0; +#ifdef MADV_DONTDUMP + madvise(addr, len, MADV_DONTDUMP); +#endif } return addr; }