[packages/php/PHP_8_3] Rel 2. Backport the debug_backtrace() fix, link with libz

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


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

    Rel 2. Backport the debug_backtrace() fix, link with libz
    
    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-129474.

 GHSA-8mjj-2r7p-4hg2.patch       | 129 ++++++++++++++++++++++++++++++++++++++++
 php-zlib-for-getimagesize.patch |   9 +++
 php.spec                        |   4 +-
 3 files changed, 141 insertions(+), 1 deletion(-)
---
diff --git a/php.spec b/php.spec
index e47c0a7..47b07b3 100644
--- a/php.spec
+++ b/php.spec
@@ -142,7 +142,7 @@
 %define		ver_suffix	83
 %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
@@ -203,6 +203,7 @@ Patch66:	php-db.patch
 Patch67:	mysql-lib-ver-mismatch.patch
 Patch71:	libdb-info.patch
 Patch72:	opcache-revalidate-path-once.patch
+Patch73:	GHSA-8mjj-2r7p-4hg2.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}
@@ -1901,6 +1902,7 @@ cp -p php.ini-production php.ini
 %patch -P67 -p1 -b .mysql-lib-ver-mismatch
 %patch -P71 -p1 -b .libdb-info
 %patch -P72 -p1
+%patch -P73 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env php,%{_bindir}/php,' \
 	ext/ext_skel.php \
diff --git a/GHSA-8mjj-2r7p-4hg2.patch b/GHSA-8mjj-2r7p-4hg2.patch
new file mode 100644
index 0000000..a0c88fb
--- /dev/null
+++ b/GHSA-8mjj-2r7p-4hg2.patch
@@ -0,0 +1,129 @@
+GHSA-8mjj-2r7p-4hg2 (CVE-2026-129474): backtraces read __call/__callStatic trampoline args from
+the wrong stack slots (stale, possibly freed zvals); 8.5-only Zend test dropped.
+https://github.com/php/php-src/commit/03c403286d9440c2b3a840812652be4e221d1be7
+
+diff -urNp a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
+--- a/sapi/phpdbg/phpdbg.c
++++ b/sapi/phpdbg/phpdbg.c
+@@ -120,6 +120,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 a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
+--- a/sapi/phpdbg/phpdbg_frame.c
++++ b/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 a/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt b/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt
+--- a/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-001.phpt
++++ b/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 a/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt b/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt
+--- a/sapi/phpdbg/tests/GHSA-8mjj-2r7p-4hg2-002.phpt
++++ b/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 a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
+--- a/Zend/zend_builtin_functions.c
++++ b/Zend/zend_builtin_functions.c
+@@ -1561,7 +1561,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/php-zlib-for-getimagesize.patch b/php-zlib-for-getimagesize.patch
index c09db17..ad219ff 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.3.37/ext/zlib/config0.m4
++++ php-8.3.37/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/fb0f40ef46b7b0210539bc66ebf72f33f17a3414



More information about the pld-cvs-commit mailing list