Skip to content

Commit

Permalink
lockedpool: avoid sensitive data in core files (FreeBSD)
Browse files Browse the repository at this point in the history
This is a followup to
23991ee / #15600
to also use madvise(2) on FreeBSD to avoid sensitive data allocated
with secure_allocator ending up in core files in addition to preventing
it from going to the swap.
  • Loading branch information
vasild committed Mar 26, 2020
1 parent 7f9dedb commit f852030
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/support/lockedpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ void *PosixLockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess)
}
if (addr) {
*lockingSuccess = mlock(addr, len) == 0;
#ifdef MADV_DONTDUMP
#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 f852030

Please sign in to comment.