mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Merge bitcoin/bitcoin#31548: fuzz: Abort when global PRNG is used before SeedRand::ZEROS
fa3c787b62fuzz: Abort when global PRNG is used before SeedRand::ZEROS (MarcoFalke) Pull request description: This adds one more check to abort when global PRNG is used before SeedRand::ZEROS in fuzz tests. This is achieved by carving out the two remaining uses. First, `g_rng_temp_path_init`, and second the random fallback for `RANDOM_CTX_SEED`, which isn't used in fuzz tests anyway. Requested in https://github.com/bitcoin/bitcoin/pull/31521#issuecomment-2554669015 Can be tested by revertingfadd568931and observing an abort when running the `utxo_total_supply` fuzz target. ACKs for top commit: marcofleon: ACKfa3c787b62hodlinator: re-ACKfa3c787b62ryanofsky: Code review ACKfa3c787b62. This adds a new check to make that sure that RNG is never seeded during fuzzing after the RNG has been used. Together with existing checks which ensure RNG can only be seeded with zeroes during fuzzing, and that RNG must was seeded at some point if used after fuzzing, this implies it must have been seeded by zeros before being used. Tree-SHA512: 2614928d31c310309bd9021b3e5637b35f64196020fbf9409e978628799691d0efd3f4cf606be9a2db0ef60b010f890c2e70c910eaa2934a7fbf64cd1598fe22
This commit is contained in:
@@ -78,7 +78,9 @@ constexpr inline auto TEST_DIR_PATH_ELEMENT{"test_common bitcoin"}; // Includes
|
||||
static FastRandomContext g_rng_temp_path;
|
||||
static const bool g_rng_temp_path_init{[] {
|
||||
// Must be initialized before any SeedRandomForTest
|
||||
Assert(!g_used_g_prng);
|
||||
(void)g_rng_temp_path.rand64();
|
||||
g_used_g_prng = false;
|
||||
return true;
|
||||
}()};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user