Fix GH-22063: stream filter chain UAF on self-removal during callback#67
Closed
iliaal wants to merge 1 commit into
Closed
Fix GH-22063: stream filter chain UAF on self-removal during callback#67iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
A stream filter struct must stay live while a fops->filter() callback or chain iteration holds it. A php_user_filter that removes its own resource inside filter() frees the struct under userfilter_filter (&thisfilter->abstract deref) and under the three chain-walk sites (current->next read). Defer pefree via an in_callback counter until every C-level frame holding the filter releases it. Closes phpGH-22063
Owner
Author
|
Submitted upstream as php#22083 |
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
php_user_filterthat callsstream_filter_removeon its own resource from insidefilter()frees thephp_stream_filterstruct whileuserfilter_filterstill dereferences&thisfilter->abstractand while the chain walks in_php_stream_filter_flush,_php_stream_write_filtered, and_php_stream_fill_read_bufferstill needcurrent->next. Two new fields onphp_stream_filter,in_callbackanddeferred_dtor, carry the deferral:php_stream_filter_remove(filter, true)unlinks and runszend_list_deleteimmediately but defers thepefree.