Skip to content

Commit

Permalink
Merge pull request #1118 from fdoving/fdov-lockedpool-madvise
Browse files Browse the repository at this point in the history
lockedpool: avoid sensitive data in core files (Linux and FreeBSD)
  • Loading branch information
TronBlack authored Nov 5, 2021
2 parents 2a71eb7 + 0fbc719 commit 20c7167
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/support/lockedpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ 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;
#if defined(MADV_DONTDUMP) // Linux
madvise(addr, len, MADV_DONTDUMP);
#elif defined(MADV_NOCORE) // FreeBSD
madvise(addr, len, MADV_NOCORE);
#endif
}
return addr;
}
Expand Down

0 comments on commit 20c7167

Please sign in to comment.