Use MAP_INHERIT_NONE/ZERO if available instead of crashing on assertion failure
On NetBSD, the way to ask a page range be zero'd or unmapped on fork is minherit(addr, nbytes, MAP_INHERIT_ZERO)
or minherit(addr, nbytes, MAP_INHERIT_NONE)
. However,
- map_anon.c does not actually check for or use
MAP_INHERIT_ZERO
orMAP_INHERIT_NONE
, so -
FLAG_NOINHERIT
is undefined, so -
tor_mmap_anonymous
fails to disinherit the mapping, so -
crypto_fast_rng_new_from_seed
throws a fit.
slow/prob_distr/stochastic_log_logistic: [forking] May 25 03:56:58.091 [err] tor_assertion_failed_(): Bug: src/lib/crypt_ops/crypto_rand_fast.c:184: crypto_fast_rng_new_from_seed: Assertion inherit != INHERIT_RES_KEEP failed; aborting. (on Tor 0.4.1.1-alpha-dev 29955f13e5bc8e61)
May 25 03:56:58.091 [err] Bug: Assertion inherit != INHERIT_RES_KEEP failed in crypto_fast_rng_new_from_seed at src/lib/crypt_ops/crypto_rand_fast.c:184: . (Stack trace not available) (on Tor 0.4.1.1-alpha-dev 29955f13e5bc8e61)
[Lost connection!]
The attached patch checks for and uses MAP_INHERIT_ZERO
and MAP_INHERIT_NONE
. However, it does not adjust the code path that gets confused if tor_mmap_anonymous
fails to disinherit the mapping, which might be worth doing too, perhaps earlier on by detecting and noisily reporting a lack of support for cutting off the hereditary concentration of wealth, or at least secrets, in society before it's too late.