options: fix heap-use-after-free in ioengine_so_path#2070
Merged
Conversation
Owner
|
Looks good to me, running it through the CI now. You need to add a |
When parsing `ioengine=external:/path`, `td->o.ioengine_so_path` was
previously assigned as a pointer directly into the `td->o.ioengine`
string buffer. If `td->o.ioengine` was subsequently reallocated (e.g.,
due to multiple ioengine definitions or the use of include directives),
`ioengine_so_path` became a dangling pointer, resulting in a
heap-use-after-free during `dlopen_ioengine`.
Fix this by ensuring `ioengine_so_path` owns its own memory allocation
independent of the `ioengine` string. Since this field is not defined
as a standard option entry, manual lifecycle management is implemented:
1. **str_ioengine_external_cb**: Use `strdup` to store the path and
free any previously allocated string.
2. **fio_options_mem_dupe**: Explicitly duplicate the string when
copying thread options.
3. **fio_options_free**: Explicitly free the string when tearing down
thread options.
This approach resolves the UAF while adhering to the requirement of not
adding a new option entry to the parser. Verified with ASan and existing
test suites.
Signed-off-by: Matthew Suozzo <[email protected]>
b2d7e9e to
7aeef09
Compare
Contributor
Author
|
Thanks! Added the signed off trailer. |
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.
When parsing
ioengine=external:/path,td->o.ioengine_so_pathwaspreviously assigned as a pointer directly into the
td->o.ioenginestring buffer. If
td->o.ioenginewas subsequently reallocated (e.g.,due to multiple ioengine definitions or the use of include directives),
ioengine_so_pathbecame a dangling pointer, resulting in aheap-use-after-free during
dlopen_ioengine.Fix this by ensuring
ioengine_so_pathowns its own memory allocationindependent of the
ioenginestring. Since this field is not definedas a standard option entry, manual lifecycle management is implemented:
strdupto store the path andfree any previously allocated string.
copying thread options.
thread options.
This approach resolves the UAF while avoiding adding a new option entry.