Feed environment data into RNG initializers#17270
Conversation
0971ae9 to
0c6d5cb
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Errors on MacOSX (looks like it doesn't have |
c197258 to
4b12381
Compare
|
Concept ACK: good idea |
0b1d233 to
eed8cfe
Compare
|
I think I've addressed a compatibility/build issues. Can someone try this on OSX, and perhaps some BSD flavor? |
promag
left a comment
There was a problem hiding this comment.
Concept ACK, nice commit sequence.
I get the following error when building eed8cfec452a538d644844fb96606e6bc24f47c8 on OpenBSD 6.6: |
|
Log on FreeBSD 12.0-RELEASE-p10 (same complaint, about Details |
|
Building freeBSD here: https://cirrus-ci.com/task/5690364417015808 Edit: Same error: https://cirrus-ci.com/task/5690364417015808?command=make#L734 |
|
Does the comment in |
e604e52 to
8470cbb
Compare
|
New freeBSD build: https://cirrus-ci.com/task/4712584309112832 |
f93fc61 Put bounds on the number of CPUID leaves explored (Pieter Wuille) ba2c5fe Fix CPUID subleaf iteration (Pieter Wuille) Pull request description: This fixes bitcoin#17523. The code to determine which CPUID subleaves to explore was incorrect in bitcoin#17270. The new code here is based on Intel's reference documentation for CPUID (a document called "Intel® Processor Identification and the CPUID Instruction - Application Note 485", which I cannot actually find on their own website). ACKs for top commit: laanwj: ACK f93fc61 jonatack: ACK f93fc61 code review, tested rebased on current master bb862d7 with Debian 4.19 x86_64 mzumsande: ACK f93fc61, reviewed code and compared with the intel doc, tested on an AMD and an Intel processor. Tree-SHA512: 2790b326fa397b736c0f39f25807bea57de2752fdd58bf6693d044b8cb26df36c11cce165a334b471f8e33724f10e3b76edab5cc4e0e7776601aabda13277245
…rv64 toolchain issue eafd259 build: Add NX workaround for RV64 (Wladimir J. van der Laan) f6e4225 build: Allow export of environ symbols (Wladimir J. van der Laan) Pull request description: This export was introduced in #17270 which added ``` //! Necessary on some platforms extern char** environ; ``` This should (finally) make the gitian build pass again (fix issue #17525.). Built on top of #17538 which should be merged first. Top commit has no ACKs. Tree-SHA512: 5c2054d52d0957aec3dc945b76d8e219187d22dc03889e7a88fb76049bf8e4a3e9f4da00dd1e9dd0351211f8e70d1a1b8ad7244f0348dab698e9d14b9d0c0bd4
…around rv64 toolchain issue eafd259 build: Add NX workaround for RV64 (Wladimir J. van der Laan) f6e4225 build: Allow export of environ symbols (Wladimir J. van der Laan) Pull request description: This export was introduced in bitcoin#17270 which added ``` //! Necessary on some platforms extern char** environ; ``` This should (finally) make the gitian build pass again (fix issue bitcoin#17525.). Built on top of bitcoin#17538 which should be merged first. Top commit has no ACKs. Tree-SHA512: 5c2054d52d0957aec3dc945b76d8e219187d22dc03889e7a88fb76049bf8e4a3e9f4da00dd1e9dd0351211f8e70d1a1b8ad7244f0348dab698e9d14b9d0c0bd4
55b2cb1 random: mark RandAddPeriodic and SeedPeriodic as noexcept (fanquake) 461e547 doc: correct random.h docs after #17270 (fanquake) Pull request description: The usage of `MilliSleep()` in SeedPeriodic (previously SeedSleep) was [removed](d61f2bb) in #17270, meaning it, and its users can now be marked `noexcept`. This also corrects the docs in random.h for some of the changes in #17270. ACKs for top commit: practicalswift: ACK 55b2cb1 laanwj: ACK 55b2cb1 sipa: ACK 55b2cb1 Tree-SHA512: 672d369796e7c4f9b4d98dc545e5454999fa1bef373871994a26041d6163c58909e2255e4f820d3ef011679aa3392754eb57477306a89f5fd3d57e2bd7f0811a
… noexcept 55b2cb1 random: mark RandAddPeriodic and SeedPeriodic as noexcept (fanquake) 461e547 doc: correct random.h docs after bitcoin#17270 (fanquake) Pull request description: The usage of `MilliSleep()` in SeedPeriodic (previously SeedSleep) was [removed](bitcoin@d61f2bb) in bitcoin#17270, meaning it, and its users can now be marked `noexcept`. This also corrects the docs in random.h for some of the changes in bitcoin#17270. ACKs for top commit: practicalswift: ACK 55b2cb1 laanwj: ACK 55b2cb1 sipa: ACK 55b2cb1 Tree-SHA512: 672d369796e7c4f9b4d98dc545e5454999fa1bef373871994a26041d6163c58909e2255e4f820d3ef011679aa3392754eb57477306a89f5fd3d57e2bd7f0811a
This export was introduced in bitcoin#17270 which added ``` //! Necessary on some platforms extern char** environ; ``` Github-Pull: bitcoin#17569 Rebased-From: f6e4225
dc9305b random: don't special case clock usage on macOS (fanquake) Pull request description: `clock_gettime()`, `CLOCK_MONOTONIC` and `CLOCK_REALTIME` are all available for use on macOS (now that we require macOS >=10.12 and build against 10.14). Use them rather than the [deprecated](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html) `mach_timespec_t` time API. I mentioned the possibility for this change [in #17270](#17270 (comment)). [master](1dbf335): ```bash 2019-12-23T20:49:43Z Feeding 216 bytes of dynamic environment data into RNG 2019-12-23T20:50:43Z Feeding 216 bytes of dynamic environment data into RNG ``` This PR: ```bash 2019-12-23T20:32:41Z Feeding 232 bytes of dynamic environment data into RNG 2019-12-23T20:33:42Z Feeding 232 bytes of dynamic environment data into RNG ``` ~~Depends on #16392.~~ Merged. ACKs for top commit: laanwj: ACK dc9305b Tree-SHA512: 18c2f336ea628f9cf7339b817381d230a18893fd9c0351bf99a39ca6f45c5b0a20af9d599d48d6c09515627d5edafa91337c17f9f790264251d2cdcb3763bbd5
dc9305b random: don't special case clock usage on macOS (fanquake) Pull request description: `clock_gettime()`, `CLOCK_MONOTONIC` and `CLOCK_REALTIME` are all available for use on macOS (now that we require macOS >=10.12 and build against 10.14). Use them rather than the [deprecated](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html) `mach_timespec_t` time API. I mentioned the possibility for this change [in bitcoin#17270](bitcoin#17270 (comment)). [master](1dbf335): ```bash 2019-12-23T20:49:43Z Feeding 216 bytes of dynamic environment data into RNG 2019-12-23T20:50:43Z Feeding 216 bytes of dynamic environment data into RNG ``` This PR: ```bash 2019-12-23T20:32:41Z Feeding 232 bytes of dynamic environment data into RNG 2019-12-23T20:33:42Z Feeding 232 bytes of dynamic environment data into RNG ``` ~~Depends on bitcoin#16392.~~ Merged. ACKs for top commit: laanwj: ACK dc9305b Tree-SHA512: 18c2f336ea628f9cf7339b817381d230a18893fd9c0351bf99a39ca6f45c5b0a20af9d599d48d6c09515627d5edafa91337c17f9f790264251d2cdcb3763bbd5
This export was introduced in bitcoin#17270 which added ``` //! Necessary on some platforms extern char** environ; ```
The usage of MilliSleep() in SeedPeriodic (previously SeedSleep) was removed in bitcoin#17270, meaning it, and its users can now be marked noexcept.
Summary: ``` This should have been part of #17151. ``` Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@b51bae1 Depends on D6157. Test Plan: Read the comments. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6158
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@cea3902 Test Plan: ninja make Run the build-win64 CI build plan. Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D6159
Summary: ``` This sort of data is also used by OpenSSL. ``` Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@c2a262a Depends on D6159. Test Plan: ninja all check-all Run the build-win64 and build-osx CI build plans. Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D6160
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@723c796 Test Plan: ninja all check-all Run the Gitian builds. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6161
Summary: ``` This based on code by Gregory Maxwell. ``` Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@2554c1b Depends on D6161. Test Plan: ninja all check-all Run the Gitian builds (will run symbol-check). Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6162
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@a81c494 Test Plan: ninja all check-all Build for OSX (native and cross build), check the binary runs. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6201
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@11793ea Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6205
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@483b942 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6206
Summary: ``` * Instead of calling RandAddSeedSleep anytime the scheduler goes idle, call its replacement (RandAddSeedPeriodic) just once per minute. This has better guarantees of actually being run, and helps limit how frequently the dynamic env data is gathered. * Since this code runs once per minute regardless now, we no longer need to keep track of the last time strengthening was run; just do it always. * Make strengthening time context dependent (100 ms at startup, 10 ms once per minute afterwards). ``` Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@d61f2bb Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6207
Summary: ``` Also switch to chrono based types. ``` Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@64e1e02 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6208
Summary: Completes backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@d1c0277 Depends on D6207. Test Plan: ninja all check-all ./src/bitcoind Check in the log that the amount of environment data feeded into RNG is logged. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6209
Summary: Partial backport of core [[bitcoin/bitcoin#17270 | PR17270]]: bitcoin/bitcoin@723c796 Test Plan: ninja all check-all Run the Gitian builds. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6161
| //! Necessary on some platforms | ||
| extern char** environ; |
There was a problem hiding this comment.
@sipa
While compiling natively on Windows with MSVC, receiving C4273 warnings:
randomenv.cpp
C:\Users\hebasto\bitcoin\src\randomenv.cpp(60,22): warning C4273: '__p__environ': inconsistent dll linkage [C:\Users\hebasto\bitcoin\build\src\util\bitcoin_util.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdlib.h(1158,29): message : see previous definition of '__p__environ' [C:\Users\hebasto\bitcoin\build\src\util\bitcoin_util.
vcxproj]
randomenv.cpp
C:\Users\hebasto\bitcoin\src\randomenv.cpp(60,22): warning C4273: '__p__environ': inconsistent dll linkage [C:\Users\hebasto\bitcoin\build\src\kernel\bitcoinkernel.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdlib.h(1158,29): message : see previous definition of '__p__environ' [C:\Users\hebasto\bitcoin\build\src\kernel\bitcoinkern
el.vcxproj]
Considering https://docs.microsoft.com/en-us/cpp/c-runtime-library/environ-wenviron, is this code correct for MSVC?
This introduces a new
randomenvmodule that queries varies non-cryptographic (and non-RNG) sources of entropy available on the system; things like user IDs, system configuration, time, statistics, CPUID data.The idea is that these provide a fallback in scenarios where system entropy is somehow broken (note that if system entropy fails we will abort regardless; this is only meant to function as a last resort against undetected failure). It includes some data sources OpenSSL currently uses, and more.
The separation between random and randomenv is a bit arbitrary, but I felt that all this "non-essential" functionality deserved to be separated from the core random module.