-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix GH-20318, GH-20316: Handle concurrent mutations during reference assignment #20254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arnaud-lb
wants to merge
2
commits into
php:master
Choose a base branch
from
arnaud-lb:gh15938-refs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+654
−54
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
AWS x86_64 (c7i.24xl)
Laravel 12.2.0 demo app - 100 consecutive runs, 50 warmups, 100 requests (sec)
Symfony 2.7.0 demo app - 100 consecutive runs, 50 warmups, 100 requests (sec)
Wordpress 6.2 main page - 100 consecutive runs, 20 warmups, 20 requests (sec)
bench.php - 100 consecutive runs, 10 warmups, 2 requests (sec)
|
73824f2 to
df25942
Compare
Typed references may be modified while assigning to them, during coercion: * The reference may be freed, resulting in UAF * The type source list maybe freed or reallocated, resulting in UAF * Some newly added types may skipped, resulting in incorrect typing Here we fix these issues. Freeing is avoided by increasing the refcount during assignment. Source list issues are fixed by updating the iteration code, and modifying the list in append-only mode during assignment.
…e=IS_TMP_VAR zend_assign_to_typed_ref_ex() receives a zval slot and tries to dtor it when value_type=IS_TMP_VAR. This slot may be modified before dtor if it was in fact a CV slot. In particular it may be turned into a ref, replaced by anyother ref, or unset; leading to UAFs or leaks. Fix by passing a stack slot instead. This is consistent with zend_assign_to_typed_prop().
df25942 to
4d447e1
Compare
dstogov
reviewed
Nov 5, 2025
Member
dstogov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These attempts to fix "destructive" magic methods became too complicated for me.
Take the decision yourself. I won't object.
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.
Typed references may be modified while assigning to them, during coercion (#20318):
The rvalue may also be changed, leading to UAFs or leaks when freeing it (#20316).
Here we fix these issues (see commits).
Freeing is avoided by increasing the refcount during assignment.
Source list issues are fixed by updating the iteration code, and modifying the list in append-only mode during assignment.
zend_verify_ref_assignable_zval()repeats coercion for every type source, to ensure consistency. Since each execution of a__toString()may append new types, this could easily turn into an infinite loop. To avoid this, we execute__toString()only once, assuming that converting the same object to string twice will have the same result.The rvalue issue is fixed by copying the zval to a stack slot.
Fixes GH-20318, GH-20316.
Targeting master only, as the type list issue is difficult to fix in release branches.