1 /* Copyright (c) 2020, Google Inc. 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef OPENSSL_HEADER_CRYPTO_FORK_DETECT_H 16 #define OPENSSL_HEADER_CRYPTO_FORK_DETECT_H 17 18 #include <openssl/base.h> 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 25 // crypto_get_fork_generation returns the fork generation number for the current 26 // process, or zero if not supported on the platform. The fork generation number 27 // is a non-zero, strictly-monotonic counter with the property that, if queried 28 // in an address space and then again in a subsequently forked copy, the forked 29 // address space will observe a greater value. 30 // 31 // This function may be used to clear cached values across a fork. When 32 // initializing a cache, record the fork generation. Before using the cache, 33 // check if the fork generation has changed. If so, drop the cache and update 34 // the save fork generation. Note this logic transparently handles platforms 35 // which always return zero. 36 // 37 // This is not reliably supported on all platforms which implement |fork|, so it 38 // should only be used as a hardening measure. 39 OPENSSL_EXPORT uint64_t CRYPTO_get_fork_generation(void); 40 41 // CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing is an internal detail 42 // used for testing purposes. 43 OPENSSL_EXPORT void CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing(void); 44 45 #if defined(__cplusplus) 46 } // extern C 47 #endif 48 49 #endif // OPENSSL_HEADER_CRYPTO_FORK_DETECT_H 50