Null-guard EVP_AEAD_CTX_cleanup for fork safety with shared memory#3280
Closed
WillChilds-Klein wants to merge 7 commits into
Closed
Null-guard EVP_AEAD_CTX_cleanup for fork safety with shared memory#3280WillChilds-Klein wants to merge 7 commits into
WillChilds-Klein wants to merge 7 commits into
Conversation
Applications that use fork() with MAP_SHARED memory for TLS connection state can trigger a SIGSEGV in EVP_AEAD_CTX_cleanup. This occurs because DEFINE_METHOD_FUNCTION lazily initializes AEAD vtables via CRYPTO_once into .bss storage. After fork(), each process has an independent .bss copy. If a child process initializes the vtable (by performing TLS) and stores an EVP_AEAD_CTX in shared memory, the parent process's vtable remains zeroed. When the parent calls EVP_AEAD_CTX_cleanup, it dereferences ctx->aead->cleanup which is NULL, crashing the process. This commit adds a null-check on ctx->aead->cleanup before calling it. This is safe because: - All AES-GCM cleanup functions are no-ops (empty function body) - aead_chacha20_poly1305_cleanup is also a no-op - In the cross-process cleanup scenario, skipping cleanup prevents a crash with no resource leak (the shared memory pool manages lifetime) Also adds aead_fork_test, an isolated test binary that verifies EVP_AEAD_CTX_cleanup tolerates an uninitialized vtable after fork().
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 1, 2026 17:09 — with
GitHub Actions
Inactive
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3280 +/- ##
==========================================
- Coverage 78.16% 78.15% -0.02%
==========================================
Files 693 694 +1
Lines 123955 124033 +78
Branches 17213 17217 +4
==========================================
+ Hits 96887 96934 +47
- Misses 26149 26175 +26
- Partials 919 924 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 2, 2026 21:35 — with
GitHub Actions
Inactive
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
WillChilds-Klein
had a problem deploying
to
auto-approve
June 3, 2026 17:09 — with
GitHub Actions
Failure
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 3, 2026 17:10 — with
GitHub Actions
Inactive
WillChilds-Klein
marked this pull request as ready for review
June 18, 2026 19:19
WillChilds-Klein
had a problem deploying
to
auto-approve
June 18, 2026 19:19 — with
GitHub Actions
Failure
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
June 18, 2026 19:20 — with
GitHub Actions
Inactive
WillChilds-Klein
had a problem deploying
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Failure
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
WillChilds-Klein
temporarily deployed
to
auto-approve
July 8, 2026 17:59 — with
GitHub Actions
Inactive
Contributor
Author
|
Closing in favor of PR #3336 |
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.
Issues:
Resolves #P425555771
Description of changes:
Summary
Applications that use
fork()withMAP_SHAREDmemory for TLS connection state can trigger a SIGSEGV inEVP_AEAD_CTX_cleanup. This occurs becauseDEFINE_METHOD_FUNCTIONlazily initializes AEAD vtables viaCRYPTO_onceinto.bssstorage. Afterfork(), each process has an independent.bsscopy. If a child process initializes the vtable (by performing TLS) and stores anEVP_AEAD_CTXin shared memory, the parent process's vtable remains zeroed. When the parent callsEVP_AEAD_CTX_cleanup, it dereferencesctx->aead->cleanupwhich is NULL, crashing the process.
Call-outs:
n/a
Testing:
Adds
aead_fork_test, an isolated test binary that verifiesEVP_AEAD_CTX_cleanuptolerates an uninitialized vtable afterfork(). The test is a separate executable (likerand_isolated_test) because it requires that AEAD vtables are NOT initialized before the test runs. The FIPS power-on self-test and other tests incrypto_testtrigger vtable initialization as a side effect.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.