fuzz: fix stack-use-after-scope in LLVMFuzzerTestOneInput#881
Closed
oliverchang wants to merge 1 commit intoPCRE2Project:mainfrom
Closed
fuzz: fix stack-use-after-scope in LLVMFuzzerTestOneInput#881oliverchang wants to merge 1 commit intoPCRE2Project:mainfrom
oliverchang wants to merge 1 commit intoPCRE2Project:mainfrom
Conversation
A variable `callout_count` is declared within the scope of a `for` loop in the function `LLVMFuzzerTestOneInput`. The address of this variable is passed to the function `pcre2_set_callout()` and stored within the variable `match_context`. The variable `match_context` is defined outside the loop, initialized during the first loop iteration, and persists for the second iteration. The address of `callout_count` is a stale stack location in the second iteration. When `pcre2_match()` is called in the second iteration, a callback attempts to access this address, resulting in a stack-use-after-scope error. This patch moves the declaration of `callout_count` to the function scope, ensuring its lifetime covers the entire duration that `match_context` is active. Co-authored-by: CodeMender <codemender-patching@google.com> Fixes: https://issues.oss-fuzz.com/issues/478301105
Contributor
|
Please note that this should be considered an AI contribution. |
Contributor
|
@oliverchang, as requested in #882, can you please provide more context for this PR? Is there something in OSS-Fuzz we are not seeing, or was this a spurious patch? |
Author
This is a spurious patch caused by a bad bug in our infrastructure. Please ignore this one, and sorry again for the noise! |
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.
A variable
callout_countis declared within the scope of aforloop in the functionLLVMFuzzerTestOneInput. The address of this variable is passed to the functionpcre2_set_callout()and stored within the variablematch_context.The variable
match_contextis defined outside the loop, initialized during the first loop iteration, and persists for the second iteration. The address ofcallout_countis a stale stack location in the second iteration. Whenpcre2_match()is called in the second iteration, a callback attempts to access this address, resulting in a stack-use-after-scope error.This patch moves the declaration of
callout_countto the function scope, ensuring its lifetime covers the entire duration thatmatch_contextis active.Fixes: https://issues.oss-fuzz.com/issues/478301105