Skip to content

Commit f852030

Browse files
committed
lockedpool: avoid sensitive data in core files (FreeBSD)
This is a followup to 23991ee / bitcoin/bitcoin#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.
1 parent 7f9dedb commit f852030

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/support/lockedpool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,10 @@ void *PosixLockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess)
253253
}
254254
if (addr) {
255255
*lockingSuccess = mlock(addr, len) == 0;
256-
#ifdef MADV_DONTDUMP
256+
#if defined(MADV_DONTDUMP) // Linux
257257
madvise(addr, len, MADV_DONTDUMP);
258+
#elif defined(MADV_NOCORE) // FreeBSD
259+
madvise(addr, len, MADV_NOCORE);
258260
#endif
259261
}
260262
return addr;

0 commit comments

Comments
 (0)