aboutsummaryrefslogtreecommitdiff
path: root/src/support
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2020-03-26 20:43:17 +0100
committerVasil Dimov <vd@FreeBSD.org>2020-03-26 20:43:17 +0100
commitf85203097f78d9daa1d35c4097a80beab31da2a4 (patch)
tree5324eb0cb2b36bdabf3b46f849e7cdae487bac61 /src/support
parent7f9dedb22dcd9550ca525c0e35fec38b2d59e029 (diff)
downloadbitcoin-f85203097f78d9daa1d35c4097a80beab31da2a4.tar.xz
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.
Diffstat (limited to 'src/support')
-rw-r--r--src/support/lockedpool.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp
index f3cc12201c..ea4d80aba8 100644
--- a/src/support/lockedpool.cpp
+++ b/src/support/lockedpool.cpp
@@ -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;