reset global pointers to prevent use-after-free in zend_jit_status()
#19212
+8
−0
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.
We have seen crashes in calls to
zend_jit_status()
purely in Apache mod_php environments. The only place where I could possibly see something could crash is the dereference ofdasm_ptr
in:php-src/ext/opcache/jit/zend_jit.c
Line 825 in 37bc8f9
I traced it further down and it looks to be the following (rare) situation:
apache2ctl graceful
will trigger a MSHUTDOWN -> MINIT in the same processaccel_post_startup()
again and for "reasons" does not callzend_jit_startup()
.This leaves
dasm_ptr
,dasm_buf
,dasm_end
anddasm_size
with dangling values.Those reasons could be:
opcache.jit
fromtracing
todisable
/off
)accel_post_startup()
was runHow to reproduce:
php:apache
apache2-foreground
index.php
file servingvar_dump(opcache_get_status())
['jit']['buffer_size']
is a non-0 integer and JIT enabledapache2ctl graceful
Now JIT is disabled, but still has a size and
buffer_free
is "huge" suggesting uninitialised memory.