Repository navigation
Conversation
|
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.
What does this PR do?
Protects native WAF context creation against concurrent handle closure and rejects handles that have already closed.
Motivation
The handle-lifetime race investigated in APPSEC-70090 allows context initialization to access a freed native handle. The exact customer crash remains unreproduced.
Description of the Change
Context initialization takes the handle's existing read lock and checks its state before calling JNI. Handle closure uses the same lock's write side. Existing contexts retain their rules and continue evaluating after handle closure.
Adds four regression tests covering null and closed handles, creation waiting behind closure, and closure waiting for creation.
Additional Notes
Keep the tracer workaround until a release containing this fix is adopted. Removing that workaround also requires retrying with the current handle when a captured handle has closed.
Validated on macOS ARM64 with libddwaf 2.0.1: 201 standard tests passed, one skipped, on JDK 8 and 25; six GC tests passed on JDK 25/ZGC. Java 8 validation used a scratch compiler configuration with
--release 8. Formatting checks pass. Performance benchmarking remains pending.