handshake: free libctx after the SSL_CTXs to fix use-after-free#92
Closed
npajkovsky wants to merge 2 commits into
Closed
handshake: free libctx after the SSL_CTXs to fix use-after-free#92npajkovsky wants to merge 2 commits into
npajkovsky wants to merge 2 commits into
Conversation
The SSL_CTX objects (sctx and cctx) are created from the per-pool OSSL_LIB_CTX and hold references back into it. Freeing the library context first left SSL_CTX_free() operating on a freed libctx. Reorder free_ctx_pool() so the SSL_CTXs are torn down first and the OSSL_LIB_CTX is freed last, matching their creation dependency. Fixes: openssl#91 Assisted-by: Claude:claude-sonnet-4-8 Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
d09e03c to
3cb2915
Compare
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
4463422 to
58630be
Compare
Sashan
approved these changes
Jun 29, 2026
jogme
approved these changes
Jun 29, 2026
esyr
approved these changes
Jul 1, 2026
Member
|
The same issue is present in |
esyr
pushed a commit
that referenced
this pull request
Jul 1, 2026
The SSL_CTX objects (sctx and cctx) are created from the per-pool OSSL_LIB_CTX and hold references back into it. Freeing the library context first left SSL_CTX_free() operating on a freed libctx. Reorder free_ctx_pool() so the SSL_CTXs are torn down first and the OSSL_LIB_CTX is freed last, matching their creation dependency. Resolves: #91 Fixes: 5e1a24c "handshake: test SSL_CTX pool" Assisted-by: Claude:claude-sonnet-4-8 Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Norbert Pocs <norbertp@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> MergeDate: Wed Jul 1 15:32:40 2026 (Merged from #92)
esyr
pushed a commit
that referenced
this pull request
Jul 1, 2026
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Norbert Pocs <norbertp@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> MergeDate: Wed Jul 1 15:32:42 2026 (Merged from #92)
Member
|
Applied to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SSL_CTX objects (sctx and cctx) are created from the per-pool OSSL_LIB_CTX and hold references back into it. Freeing the library context first left SSL_CTX_free() operating on a freed libctx.
Reorder free_ctx_pool() so the SSL_CTXs are torn down first and the OSSL_LIB_CTX is freed last, matching their creation dependency.
Assisted-by: Claude:claude-sonnet-4-6