Skip to content

Commit

Permalink
Merge bitcoin#18443: lockedpool: avoid sensitive data in core files (…
Browse files Browse the repository at this point in the history
…FreeBSD)

f852030 lockedpool: avoid sensitive data in core files (FreeBSD) (Vasil Dimov)

Pull request description:

  This is a followup to
  23991ee / 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.

ACKs for top commit:
  sipa:
    ACK f852030 if someone verifies this works as intended on *BSD.
  laanwj:
    ACK f852030
  practicalswift:
    Code-review ACK f852030 assuming a reviewer with FreeBSD access verifies that the PR goal is achieved :)

Tree-SHA512: 2e6d4ab6a9fbe18732c8ba530eacc17f58128c97140758b80c905b5b838922a2bcaa5f9abc45ab69d5a1a2baa0cba322f006048b60a877228e089c7e64dadd2a
  • Loading branch information
laanwj committed May 4, 2020
2 parents 23c926d + f852030 commit b549cb1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/support/lockedpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b549cb1

Please sign in to comment.