diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-06 10:35:02 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-04-04 12:56:52 -0400 |
commit | 12205c3cbee4e71ded2b5710a57342b510e9d6df (patch) | |
tree | a0f1800c2e4c95ce37409fdecf28830188fb161a /src/lib/malloc/map_anon.h | |
parent | ab6ad3c040de68b1f06b8f910407bff570b24b43 (diff) | |
download | tor-12205c3cbee4e71ded2b5710a57342b510e9d6df.tar.gz tor-12205c3cbee4e71ded2b5710a57342b510e9d6df.zip |
Make map_anon expose the result of a noinherit attempt
Previously we did this for tests only, but it's valuable for getting
proper fork behavior in rand_fast.
Diffstat (limited to 'src/lib/malloc/map_anon.h')
-rw-r--r-- | src/lib/malloc/map_anon.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/malloc/map_anon.h b/src/lib/malloc/map_anon.h index 395145bd71..edd7500821 100644 --- a/src/lib/malloc/map_anon.h +++ b/src/lib/malloc/map_anon.h @@ -31,11 +31,18 @@ */ #define ANONMAP_NOINHERIT (1u<<1) -void *tor_mmap_anonymous(size_t sz, unsigned flags); -void tor_munmap_anonymous(void *mapping, size_t sz); +/** Possible value for inherit_result_out: the memory will be kept + * by any child process. */ +#define INHERIT_KEEP 0 +/** Possible value for inherit_result_out: the memory will be dropped in + * the child process. Attempting to access it will likely cause a segfault. */ +#define INHERIT_DROP 1 +/** Possible value for inherit_result_out: the memory will be cleared in + * the child process. */ +#define INHERIT_ZERO 2 -#ifdef TOR_UNIT_TESTS -unsigned get_last_anon_map_noinherit(void); -#endif +void *tor_mmap_anonymous(size_t sz, unsigned flags, + unsigned *inherit_result_out); +void tor_munmap_anonymous(void *mapping, size_t sz); #endif /* !defined(TOR_MAP_ANON_H) */ |