diff options
| author | kenjiro <> | 2026-08-30 12:19:37 +0000 |
|---|---|---|
| committer | kenjiro <> | 2026-08-30 12:19:37 +0000 |
| commit | 5931045c664b500427fb54c31fab4de3e92bb159 (patch) | |
| tree | 6bcb237ddd3233dde465de629eee51c4c1a0ed2c /src/lib/libcrypto/man | |
| parent | 6b13eef79d2dc54c1b0203f967b3fc8b8971df78 (diff) | |
| download | openbsd-5931045c664b500427fb54c31fab4de3e92bb159.tar.gz openbsd-5931045c664b500427fb54c31fab4de3e92bb159.tar.bz2 openbsd-5931045c664b500427fb54c31fab4de3e92bb159.zip | |
Make CRYPTO_cleanup_all_ex_data() a compatibility no-op
The ex_data callback registry is process-wide, but this API could free
it while other threads were still using libcrypto, resulting in a
use-after-free.
Retain the public symbol as a compatibility no-op and mark it
deprecated. Move the actual cleanup to an internal function called by
OPENSSL_cleanup(). Replace the in-tree callers with OPENSSL_cleanup()
at final shutdown to preserve cleanup behavior and coverage.
Document both APIs and the requirement that OPENSSL_cleanup() only be
called after all threads and components have stopped using libcrypto.
ok tb
Diffstat (limited to 'src/lib/libcrypto/man')
| -rw-r--r-- | src/lib/libcrypto/man/CRYPTO_set_ex_data.3 | 27 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/OPENSSL_init_crypto.3 | 35 |
2 files changed, 54 insertions, 8 deletions
diff --git a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 index ae2b04b528..00b5785533 100644 --- a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 +++ b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.17 2026/08/23 04:46:31 jsg Exp $ | 1 | .\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.18 2026/08/30 12:19:37 kenjiro Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> |
| 4 | .\" | 4 | .\" |
| @@ -14,7 +14,7 @@ | |||
| 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | .\" | 16 | .\" |
| 17 | .Dd $Mdocdate: August 23 2026 $ | 17 | .Dd $Mdocdate: August 30 2026 $ |
| 18 | .Dt CRYPTO_SET_EX_DATA 3 | 18 | .Dt CRYPTO_SET_EX_DATA 3 |
| 19 | .Os | 19 | .Os |
| 20 | .Sh NAME | 20 | .Sh NAME |
| @@ -25,7 +25,8 @@ | |||
| 25 | .Nm CRYPTO_new_ex_data , | 25 | .Nm CRYPTO_new_ex_data , |
| 26 | .Nm CRYPTO_set_ex_data , | 26 | .Nm CRYPTO_set_ex_data , |
| 27 | .Nm CRYPTO_get_ex_data , | 27 | .Nm CRYPTO_get_ex_data , |
| 28 | .Nm CRYPTO_free_ex_data | 28 | .Nm CRYPTO_free_ex_data , |
| 29 | .Nm CRYPTO_cleanup_all_ex_data | ||
| 29 | .Nd low-level functions for application specific data | 30 | .Nd low-level functions for application specific data |
| 30 | .Sh SYNOPSIS | 31 | .Sh SYNOPSIS |
| 31 | .Lb libcrypto | 32 | .Lb libcrypto |
| @@ -89,6 +90,8 @@ | |||
| 89 | .Fa "void *parent" | 90 | .Fa "void *parent" |
| 90 | .Fa "CRYPTO_EX_DATA *ad" | 91 | .Fa "CRYPTO_EX_DATA *ad" |
| 91 | .Fc | 92 | .Fc |
| 93 | .Ft void | ||
| 94 | .Fn CRYPTO_cleanup_all_ex_data void | ||
| 92 | .Sh DESCRIPTION | 95 | .Sh DESCRIPTION |
| 93 | The library implements the functions documented in the | 96 | The library implements the functions documented in the |
| 94 | .Xr RSA_get_ex_new_index 3 | 97 | .Xr RSA_get_ex_new_index 3 |
| @@ -342,6 +345,20 @@ Despite its name, | |||
| 342 | does not free | 345 | does not free |
| 343 | .Fa ad | 346 | .Fa ad |
| 344 | itself. | 347 | itself. |
| 348 | .Pp | ||
| 349 | .Fn CRYPTO_cleanup_all_ex_data | ||
| 350 | is deprecated and has no effect. | ||
| 351 | It is retained for source and binary compatibility only. | ||
| 352 | Application programs should not call it after individual operations, | ||
| 353 | from individual library components, or during process shutdown. | ||
| 354 | No replacement call is needed. | ||
| 355 | .Pp | ||
| 356 | In particular, | ||
| 357 | .Xr OPENSSL_cleanup 3 | ||
| 358 | is not a replacement for | ||
| 359 | .Fn CRYPTO_cleanup_all_ex_data . | ||
| 360 | It tears down process-wide library state and is only intended for final | ||
| 361 | shutdown after all threads using libcrypto have stopped. | ||
| 345 | .Sh RETURN VALUES | 362 | .Sh RETURN VALUES |
| 346 | .Fn CRYPTO_get_ex_new_index | 363 | .Fn CRYPTO_get_ex_new_index |
| 347 | returns a new index equal to or greater than 1 | 364 | returns a new index equal to or greater than 1 |
| @@ -425,6 +442,10 @@ and | |||
| 425 | .Fn CRYPTO_EX_dup | 442 | .Fn CRYPTO_EX_dup |
| 426 | first appeared in OpenSSL 0.9.5 and have been available since | 443 | first appeared in OpenSSL 0.9.5 and have been available since |
| 427 | .Ox 2.7 . | 444 | .Ox 2.7 . |
| 445 | .Pp | ||
| 446 | .Fn CRYPTO_cleanup_all_ex_data | ||
| 447 | first appeared in OpenSSL 0.9.7 and has been available since | ||
| 448 | .Ox 3.2 . | ||
| 428 | .Sh CAVEATS | 449 | .Sh CAVEATS |
| 429 | If a program installs callback functions, the last call to | 450 | If a program installs callback functions, the last call to |
| 430 | .Fn CRYPTO_get_ex_new_index | 451 | .Fn CRYPTO_get_ex_new_index |
diff --git a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 b/src/lib/libcrypto/man/OPENSSL_init_crypto.3 index 5c29d55aa9..24756bc396 100644 --- a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 +++ b/src/lib/libcrypto/man/OPENSSL_init_crypto.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: OPENSSL_init_crypto.3,v 1.7 2025/06/09 12:43:53 schwarze Exp $ | 1 | .\" $OpenBSD: OPENSSL_init_crypto.3,v 1.8 2026/08/30 12:19:37 kenjiro Exp $ |
| 2 | .\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> | 2 | .\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> |
| 3 | .\" | 3 | .\" |
| 4 | .\" Permission to use, copy, modify, and distribute this software for any | 4 | .\" Permission to use, copy, modify, and distribute this software for any |
| @@ -13,13 +13,14 @@ | |||
| 13 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 13 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | .\" | 15 | .\" |
| 16 | .Dd $Mdocdate: June 9 2025 $ | 16 | .Dd $Mdocdate: August 30 2026 $ |
| 17 | .Dt OPENSSL_INIT_CRYPTO 3 | 17 | .Dt OPENSSL_INIT_CRYPTO 3 |
| 18 | .Os | 18 | .Os |
| 19 | .Sh NAME | 19 | .Sh NAME |
| 20 | .Nm OPENSSL_init_crypto , | 20 | .Nm OPENSSL_init_crypto , |
| 21 | .Nm OPENSSL_init | 21 | .Nm OPENSSL_init , |
| 22 | .Nd initialise the crypto library | 22 | .Nm OPENSSL_cleanup |
| 23 | .Nd initialise and shut down the crypto library | ||
| 23 | .Sh SYNOPSIS | 24 | .Sh SYNOPSIS |
| 24 | .Lb libcrypto | 25 | .Lb libcrypto |
| 25 | .In openssl/crypto.h | 26 | .In openssl/crypto.h |
| @@ -30,8 +31,13 @@ | |||
| 30 | .Fc | 31 | .Fc |
| 31 | .Ft void | 32 | .Ft void |
| 32 | .Fn OPENSSL_init void | 33 | .Fn OPENSSL_init void |
| 34 | .Ft void | ||
| 35 | .Fn OPENSSL_cleanup void | ||
| 33 | .Sh DESCRIPTION | 36 | .Sh DESCRIPTION |
| 34 | These functions are deprecated. | 37 | .Fn OPENSSL_init_crypto |
| 38 | and | ||
| 39 | .Fn OPENSSL_init | ||
| 40 | are deprecated. | ||
| 35 | It is never useful for an application program | 41 | It is never useful for an application program |
| 36 | to call either of them explicitly. | 42 | to call either of them explicitly. |
| 37 | .Pp | 43 | .Pp |
| @@ -84,6 +90,21 @@ the first one have any effect. | |||
| 84 | .Pp | 90 | .Pp |
| 85 | .Fn OPENSSL_init | 91 | .Fn OPENSSL_init |
| 86 | has no effect at all. | 92 | has no effect at all. |
| 93 | .Pp | ||
| 94 | .Fn OPENSSL_cleanup | ||
| 95 | frees process-wide resources allocated by libcrypto. | ||
| 96 | It is intended exclusively for the final shutdown of libcrypto in a process. | ||
| 97 | Before calling it, the application has to ensure that all other threads | ||
| 98 | that may use libcrypto have stopped and that no library component will use | ||
| 99 | libcrypto again. | ||
| 100 | After it returns, libcrypto cannot be reinitialized and no libcrypto or | ||
| 101 | libssl function may be called. | ||
| 102 | .Pp | ||
| 103 | .Fn OPENSSL_cleanup | ||
| 104 | is not a replacement for deprecated cleanup functions such as | ||
| 105 | .Xr CRYPTO_cleanup_all_ex_data 3 | ||
| 106 | and must not be called after individual cryptographic operations or when an | ||
| 107 | individual library component is finished with libcrypto. | ||
| 87 | .Sh RETURN VALUES | 108 | .Sh RETURN VALUES |
| 88 | .Fn OPENSSL_init_crypto | 109 | .Fn OPENSSL_init_crypto |
| 89 | is intended to return 1 on success or 0 on error. | 110 | is intended to return 1 on success or 0 on error. |
| @@ -101,6 +122,10 @@ It stopped having any effect in OpenSSL 1.1.1 and in | |||
| 101 | .Fn OPENSSL_init_crypto | 122 | .Fn OPENSSL_init_crypto |
| 102 | first appeared in OpenSSL 1.1.0 and has been available since | 123 | first appeared in OpenSSL 1.1.0 and has been available since |
| 103 | .Ox 6.3 . | 124 | .Ox 6.3 . |
| 125 | .Pp | ||
| 126 | .Fn OPENSSL_cleanup | ||
| 127 | first appeared in OpenSSL 1.1.0 and has been available since | ||
| 128 | .Ox 7.2 . | ||
| 104 | .Sh BUGS | 129 | .Sh BUGS |
| 105 | .Fn OPENSSL_init_crypto | 130 | .Fn OPENSSL_init_crypto |
| 106 | silently ignores almost all kinds of errors. | 131 | silently ignores almost all kinds of errors. |
