Skip to content

Commit

Permalink
lockedpool: avoid sensitive data in core files (Linux and FreeBSD)
Browse files Browse the repository at this point in the history
Manual backport of bitcoin PR#18443 and bitcoin PR#15633.

Use madvise on Linux and FreeBSD to avoid sensitive data from secure_allocator to be written to swap and core-files.

bitcoin/bitcoin@d831831
bitcoin/bitcoin@f852030
  • Loading branch information
fdoving authored and HyperPeek committed Nov 15, 2021
1 parent 1956113 commit 3fee4bb
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 3fee4bb

Please sign in to comment.