Skip to content

Commit 20c7167

Browse files
authored
Merge pull request #1118 from fdoving/fdov-lockedpool-madvise
lockedpool: avoid sensitive data in core files (Linux and FreeBSD)
2 parents 2a71eb7 + 0fbc719 commit 20c7167

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/support/lockedpool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ void *PosixLockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess)
231231
addr = mmap(nullptr, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
232232
if (addr) {
233233
*lockingSuccess = mlock(addr, len) == 0;
234+
#if defined(MADV_DONTDUMP) // Linux
235+
madvise(addr, len, MADV_DONTDUMP);
236+
#elif defined(MADV_NOCORE) // FreeBSD
237+
madvise(addr, len, MADV_NOCORE);
238+
#endif
234239
}
235240
return addr;
236241
}

0 commit comments

Comments
 (0)