Skip to content

Commit 3fee4bb

Browse files
fdovingHyperPeek
authored andcommitted
lockedpool: avoid sensitive data in core files (Linux and FreeBSD)
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
1 parent 1956113 commit 3fee4bb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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)