From 3aaa8d3526c53f3e3a9901853910401bd3eb3aa9 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 22 Jul 2025 10:39:56 +0200 Subject: [PATCH] Reset global pointers to prevent use-after-free Closes GH-19212. --- NEWS | 4 +++- ext/opcache/jit/zend_jit.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d52050e3a8e..a05b577d101 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.1.34 - +- Opcache: + . Reset global pointers to prevent use-after-free in zend_jit_status(). + (Florian Engelhardt) 03 Jul 2025, PHP 8.1.33 diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 4d2baddb900..f0225b0c7a8 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -5087,6 +5087,14 @@ ZEND_EXT_API void zend_jit_shutdown(void) #else zend_jit_trace_free_caches(&jit_globals); #endif + + /* Reset global pointers to prevent use-after-free in `zend_jit_status()` + * after gracefully restarting Apache with mod_php, see: + * https://github.com/php/php-src/pull/19212 */ + dasm_ptr = NULL; + dasm_buf = NULL; + dasm_end = NULL; + dasm_size = 0; } static void zend_jit_reset_counters(void)