From 71b79b85d1b347f3c38cb0c056403cc80933250c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 26 Mar 2020 20:43:17 +0100 Subject: [PATCH] lockedpool: avoid sensitive data in core files (FreeBSD) This is a followup to 23991ee53 / https://github.com/bitcoin/bitcoin/pull/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. --- src/support/lockedpool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index ba5e418d9..7a5a655c4 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -257,8 +257,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;