From 93ddc51cbd325ef3d5cf3a5b9948ff65c09fc5aa Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 29 May 2019 09:21:45 -0400 Subject: [PATCH 1/3] Give a more useful failure messgae when we fail to minherit(). Part of ticket 30686. --- src/lib/crypt_ops/crypto_rand_fast.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/crypt_ops/crypto_rand_fast.c b/src/lib/crypt_ops/crypto_rand_fast.c index b71ade81bd..d2ce1a542f 100644 --- a/src/lib/crypt_ops/crypto_rand_fast.c +++ b/src/lib/crypt_ops/crypto_rand_fast.c @@ -181,7 +181,11 @@ crypto_fast_rng_new_from_seed(const uint8_t *seed) #else /* We decided above that noinherit would always do _something_. Assert here * that we were correct. */ - tor_assert(inherit != INHERIT_RES_KEEP); + tor_assertf(inherit != INHERIT_RES_KEEP, + "We failed to create a non-inheritable memory region, even " + "though we believed such a failure to be impossible! This is " + "probably a bug in Tor support for your platform; please report " + "it."); #endif return result; } From cad0de35bd49064f5712f32a2b6e41ffe6e822e6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 29 May 2019 09:22:18 -0400 Subject: [PATCH 2/3] Give a compile warning when we don't have any flags for minherit(). Part of ticket 30686. --- src/lib/malloc/map_anon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/malloc/map_anon.c b/src/lib/malloc/map_anon.c index f4fda00bff..6afea713df 100644 --- a/src/lib/malloc/map_anon.c +++ b/src/lib/malloc/map_anon.c @@ -70,6 +70,11 @@ #endif +#if defined(HAVE_MINHERIT) && !defined(FLAG_ZERO) && !defined(FLAG_NOINHERIT) +#warn "minherit() is defined, but we couldn't find the right flag for it." +#warn "This is probably a bug in Tor's support for this platform." +#endif + /** * Helper: try to prevent the sz bytes at mem from being swapped * to disk. Return 0 on success or if the facility is not available on this From 5068ccab0b1849e836729c43a2ca891139cf107b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 29 May 2019 09:23:13 -0400 Subject: [PATCH 3/3] Add a changes file for ticket 30686. --- changes/ticket30686 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changes/ticket30686 diff --git a/changes/ticket30686 b/changes/ticket30686 new file mode 100644 index 0000000000..36473c1a02 --- /dev/null +++ b/changes/ticket30686 @@ -0,0 +1,5 @@ + o Minor features (logging): + - Give a more useful assertion failure message if we think we have + minherit() but we fail to make a region non-inheritable. Give a + compile-time warning if our support for minherit() is + incomplete. Closes ticket 30686.