[packages/php/PHP_8_2] Rel 2. Backport two use-after-free fixes, link with libz

arekm arekm at pld-linux.org
Thu Nov 19 18:51:30 CET 2026


commit 68b6c24ec891733d61a2821bff86fb84f61b7413
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Nov 19 18:35:41 2026 +0100

    Rel 2. Backport two use-after-free fixes, link with libz
    
    GHSA-g3vh-838c-65v7 lists 8.2 as not affected, but the bug reproduces
    here and the Zend part of the fix applies.
    
    Upstream fixed GHSA-8mjj-2r7p-4hg2 in 8.5.13 only; this branch has the
    same trampoline argument bug.
    
    getimagesize() in core calls uncompress(), but since libxml2-devel
    2.15.4-2 keeps -lz private it no longer reaches the link line and
    libphp_common lost its libz dependency.
    
    Fixes CVE-2026-129481, CVE-2026-129474.

 CVE-2026-129474.patch           | 129 ++++++++++++++++++++++++++++++++++++++++
 CVE-2026-129481.patch           |  26 ++++++++
 php-zlib-for-getimagesize.patch |   9 +++
 php.spec                        |   6 +-
 4 files changed, 169 insertions(+), 1 deletion(-)
---
diff --git a/php.spec b/php.spec
index 198df9f..fb56373 100644
--- a/php.spec
+++ b/php.spec
@@ -142,7 +142,7 @@
 %define		ver_suffix	82
 %define		php_suffix	%{!?with_default_php:%{ver_suffix}}
 %define		subver		%{nil}
-%define		rel		1
+%define		rel		2
 Summary:	PHP: Hypertext Preprocessor
 Summary(fr.UTF-8):	Le langage de script embarque-HTML PHP
 Summary(pl.UTF-8):	Język skryptowy PHP
@@ -209,6 +209,8 @@ Patch67:	mysql-lib-ver-mismatch.patch
 Patch68:	php-mysql-ssl-context.patch
 Patch71:	libdb-info.patch
 Patch72:	opcache-revalidate-path-once.patch
+Patch73:	CVE-2026-129481.patch
+Patch74:	CVE-2026-129474.patch
 URL:		https://www.php.net/
 %{?with_pdo_firebird:%{!?with_interbase_inst:BuildRequires:	Firebird-devel >= 1.0.2.908-2}}
 %{?with_pspell:BuildRequires:	aspell-devel >= 2:0.50.0}
@@ -1910,6 +1912,8 @@ cp -p php.ini-production php.ini
 #%%patch68 -p1 DROP or update to 7.0 APIs
 %patch -P71 -p1 -b .libdb-info
 %patch -P72 -p1
+%patch -P73 -p1
+%patch -P74 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env php,%{_bindir}/php,' \
 	ext/ext_skel.php \
diff --git a/CVE-2026-129474.patch b/CVE-2026-129474.patch
new file mode 100644
index 0000000..9c394bf
--- /dev/null
+++ b/CVE-2026-129474.patch
@@ -0,0 +1,129 @@
+GHSA-8mjj-2r7p-4hg2 (CVE-2026-129474): debug_backtrace()/phpdbg read __call/__callStatic trampoline
+args from the wrong slots (UAF); on 8.2 reachable from a pcntl signal handler. Zend/tests/ test dropped
+(needs 8.5 fatal_error_backtraces). https://github.com/php/php-src/commit/03c403286d9440c2b3a840812652be4e221d1be7
+
+diff -urNp php-8.2.36.orig/sapi/phpdbg/phpdbg.c php-8.2.36/sapi/phpdbg/phpdbg.c
+--- php-8.2.36.orig/sapi/phpdbg/phpdbg.c
++++ php-8.2.36/sapi/phpdbg/phpdbg.c
+@@ -125,6 +125,7 @@ static inline void php_phpdbg_globals_ct
+ 	pg->flags = PHPDBG_DEFAULT_FLAGS;
+ 	memset(pg->io, 0, sizeof(pg->io));
+ 	pg->frame.num = 0;
++	pg->frame.generator = 0;
+ 	pg->sapi_name_ptr = NULL;
+ 	pg->unclean_eval = 0;
+ 
+diff -urNp php-8.2.36.orig/sapi/phpdbg/phpdbg_frame.c php-8.2.36/sapi/phpdbg/phpdbg_frame.c
+--- php-8.2.36.orig/sapi/phpdbg/phpdbg_frame.c
++++ php-8.2.36/sapi/phpdbg/phpdbg_frame.c
+@@ -56,6 +56,12 @@ zend_string *phpdbg_compile_stackframe(z
+ 	uint32_t i = 0, first_extra_arg = op_array->num_args, num_args = ZEND_CALL_NUM_ARGS(ex);
+ 	zval *p = ZEND_CALL_ARG(ex, 1);
+ 
++	if (ex->func->op_array.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
++		/* A __call/__callStatic trampoline doesn't move extra args
++		 * behind the CVs and TMPs (see i_init_func_execute_data()). */
++		first_extra_arg = num_args;
++	}
++
+ 	if (op_array->scope) {
+ 		smart_str_append(&s, op_array->scope->name);
+ 		smart_str_appends(&s, "::");
+@@ -86,6 +92,8 @@ zend_string *phpdbg_compile_stackframe(z
+ 		smart_str_appends(&s, " [internal function]");
+ 	}
+ 
++	smart_str_0(&s);
++
+ 	return s.s;
+ }
+ 
+diff -urNp php-8.2.36.orig/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt php-8.2.36/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt
+--- php-8.2.36.orig/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt
++++ php-8.2.36/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt
+@@ -0,0 +1,34 @@
++--TEST--
++GHSA-8mjj-2r7p-4hg2: phpdbg frame display for __call trampoline
++--INI--
++fatal_error_backtraces=0
++zend.exception_ignore_args=1
++--PHPDBG--
++b ZEND_CALL_TRAMPOLINE
++r
++f 1
++f 0
++q
++--EXPECTF--
++[Successful compilation of %s]
++prompt> [Breakpoint #0 added at ZEND_CALL_TRAMPOLINE]
++prompt> [Breakpoint #0 in ZEND_CALL_TRAMPOLINE at %s:0, hits: 1]
++ 00001: <?php
++ 00002: class C { static function __callStatic($name, $args) {} }
++prompt> [Switched to frame #1: caller() at %s:5]
++>00005:     C::test(1, 2, 3, 4);
++ 00006: }
++ 00007:%w
++prompt> [Switched to frame #0: C::test(1, 2, 3, 4) at %s:0]
++ 00001: <?php
++ 00002: class C { static function __callStatic($name, $args) {} }
++prompt>
++--FILE--
++<?php
++class C { static function __callStatic($name, $args) {} }
++
++function caller() {
++    C::test(1, 2, 3, 4);
++}
++
++caller();
+diff -urNp php-8.2.36.orig/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt php-8.2.36/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt
+--- php-8.2.36.orig/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt
++++ php-8.2.36/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt
+@@ -0,0 +1,31 @@
++--TEST--
++GHSA-8mjj-2r7p-4hg2: phpdbg backtrace for __call trampoline with attached symbol table
++--INI--
++fatal_error_backtraces=0
++zend.exception_ignore_args=0
++--PHPDBG--
++b ZEND_CALL_TRAMPOLINE
++r
++i v
++back
++q
++--EXPECTF--
++[Successful compilation of %s]
++prompt> [Breakpoint #0 added at ZEND_CALL_TRAMPOLINE]
++prompt> [Breakpoint #0 in ZEND_CALL_TRAMPOLINE at %s:0, hits: 1]
++ 00001: <?php
++ 00002: class C { static function __callStatic($name, $args) {} }
++prompt> [Variables in C::test() (0)]
++prompt> frame #0: C::test(1, 2, 3, 4) at %s:0
++frame #1: caller() at %s:5
++frame #2: {main} at %s:8
++prompt>
++--FILE--
++<?php
++class C { static function __callStatic($name, $args) {} }
++
++function caller() {
++    C::test(1, 2, 3, 4);
++}
++
++caller();
+diff -urNp php-8.2.36.orig/Zend/zend_builtin_functions.c php-8.2.36/Zend/zend_builtin_functions.c
+--- php-8.2.36.orig/Zend/zend_builtin_functions.c
++++ php-8.2.36/Zend/zend_builtin_functions.c
+@@ -1546,7 +1546,11 @@ static bool debug_backtrace_get_args(zen
+ 			return false;
+ 		}
+ 		ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(arg_array)) {
+-			if (call->func->type == ZEND_USER_FUNCTION) {
++			/* Extra args are moved after CVs and TMPs in user functions, except
++			 * for trampoline frames (see i_init_func_execute_data()).
++			 */
++			if (call->func->type == ZEND_USER_FUNCTION
++			 && !(call->func->op_array.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
+ 				uint32_t first_extra_arg = MIN(num_args, call->func->op_array.num_args);
+ 
+ 				if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
diff --git a/CVE-2026-129481.patch b/CVE-2026-129481.patch
new file mode 100644
index 0000000..14092de
--- /dev/null
+++ b/CVE-2026-129481.patch
@@ -0,0 +1,26 @@
+GHSA-g3vh-838c-65v7 (CVE-2026-129481): exit when a module RSHUTDOWN bails out; on 8.2 the
+stale PS(mod_user_class_name)/PS(mod_user_names) are otherwise released by the next request.
+Zend part of https://github.com/php/php-src/commit/ad9b44ae611962c8b770ffc962ddff0c30d7d77c
+
+--- php-8.2.36/Zend/zend_API.c.orig
++++ php-8.2.36/Zend/zend_API.c
+@@ -3147,6 +3147,9 @@ ZEND_API void zend_deactivate_modules(vo
+ 			if (module->request_shutdown_func) {
+ 				zend_try {
+ 					module->request_shutdown_func(module->type, module->module_number);
++				} zend_catch {
++					/* module shutdown is incomplete */
++					_exit(1);
+ 				} zend_end_try();
+ 			}
+ 		} ZEND_HASH_FOREACH_END();
+@@ -3157,6 +3160,9 @@ ZEND_API void zend_deactivate_modules(vo
+ 			zend_module_entry *module = *p;
+ 			zend_try {
+ 				module->request_shutdown_func(module->type, module->module_number);
++			} zend_catch {
++				/* module shutdown is incomplete */
++				_exit(1);
+ 			} zend_end_try();
+ 			p++;
+ 		}
diff --git a/php-zlib-for-getimagesize.patch b/php-zlib-for-getimagesize.patch
index c09db17..778d49e 100644
--- a/php-zlib-for-getimagesize.patch
+++ b/php-zlib-for-getimagesize.patch
@@ -33,3 +33,12 @@ upstream: https://github.com/php/php-src/pull/4681
  			result = php_handle_swc(stream);
  #else
  			php_error_docref(NULL, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled");
+--- php-8.2.36/ext/zlib/config0.m4
++++ php-8.2.36/ext/zlib/config0.m4
+@@ -13,4 +13,6 @@
+ 
+   PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+   PHP_SUBST(ZLIB_SHARED_LIBADD)
++  dnl getimagesize() in core uses uncompress() even with shared zlib
++  PHP_EVAL_LIBLINE($ZLIB_LIBS)
+ fi
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/68b6c24ec891733d61a2821bff86fb84f61b7413



More information about the pld-cvs-commit mailing list