[packages/php/PHP_7_0] Rel 34. Fix FPM use-after-free of reaped children

arekm arekm at pld-linux.org
Thu Nov 19 21:44:43 CET 2026


commit 0ef955fc63588e1e4bca58d5b336083cbeb2af7c
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Nov 19 21:35:54 2026 +0100

    Rel 34. Fix FPM use-after-free of reaped children
    
    Reaping children from the SIGCHLD event mid epoll batch freed records
    that later events of the same batch still used (upstream bug #77185).

 php-bug77185.patch | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 php.spec           |  4 +++-
 2 files changed, 69 insertions(+), 1 deletion(-)
---
diff --git a/php.spec b/php.spec
index fb47f4c..4374905 100644
--- a/php.spec
+++ b/php.spec
@@ -150,7 +150,7 @@ Summary(ru.UTF-8):	PHP Версии 7 - язык препроцессирова
 Summary(uk.UTF-8):	PHP Версії 7 - мова препроцесування HTML-файлів, виконувана на сервері
 Name:		%{orgname}%{php_suffix}
 Version:	7.0.33
-Release:	33
+Release:	34
 Epoch:		4
 # All files licensed under PHP version 3.01, except
 # Zend is licensed under Zend
@@ -398,6 +398,7 @@ Patch358:	php-cve-2026-127960.patch
 Patch359:	php-cve-2026-129291.patch
 Patch360:	php-cve-2026-129481.patch
 Patch361:	php-cve-2026-129474.patch
+Patch362:	php-bug77185.patch
 URL:		https://www.php.net/
 %{?with_interbase:%{!?with_interbase_inst:BuildRequires:	Firebird-devel >= 1.0.2.908-2}}
 %{?with_pspell:BuildRequires:	aspell-devel >= 2:0.50.0}
@@ -2380,6 +2381,7 @@ cp -p php.ini-production php.ini
 %patch -P359 -p1
 %patch -P360 -p1
 %patch -P361 -p1
+%patch -P362 -p1
 
 sed -E -i -e '1s,#!\s*/usr/bin/env\s+(.*),#!%{__bindir}\1,' \
       run-tests.php
diff --git a/php-bug77185.patch b/php-bug77185.patch
new file mode 100644
index 0000000..0897540
--- /dev/null
+++ b/php-bug77185.patch
@@ -0,0 +1,66 @@
+From bdf24f8d6d9d495ece354d6fd2dd6ed169198a2e Mon Sep 17 00:00:00 2001
+From: Maksim Nikulin <mnikulin at plesk.com>
+Date: Wed, 23 Jan 2019 12:19:29 +0700
+Subject: [PATCH] Prevent use after free in fpm_event_epoll_wait
+
+The master reaps children from the SIGCHLD event in the middle of an
+epoll batch, so later events of that batch still point at the reaped
+children's stdio events and read their closed descriptors (EBADF).
+Reap from a timer once the batch is done, as PHP 7.3.9+ does.
+
+The upstream test was removed later as unreliable (b59a9381b989) and
+is not included.
+
+Origin: upstream, https://github.com/php/php-src/commit/bdf24f8d6d9d495ece354d6fd2dd6ed169198a2e
+Bug: https://bugs.php.net/77185
+---
+ sapi/fpm/fpm/fpm_events.c | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/sapi/fpm/fpm/fpm_events.c b/sapi/fpm/fpm/fpm_events.c
+index cdb976ea..43dbe6b8 100644
+--- a/sapi/fpm/fpm/fpm_events.c
++++ b/sapi/fpm/fpm/fpm_events.c
+@@ -36,6 +36,7 @@
+ #define fpm_event_set_timeout(ev, now) timeradd(&(now), &(ev)->frequency, &(ev)->timeout);
+ 
+ static void fpm_event_cleanup(int which, void *arg);
++static void fpm_postponed_children_bury(struct fpm_event_s *ev, short which, void *arg);
+ static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg);
+ static struct fpm_event_s *fpm_event_queue_isset(struct fpm_event_queue_s *queue, struct fpm_event_s *ev);
+ static int fpm_event_queue_add(struct fpm_event_queue_s **queue, struct fpm_event_s *ev);
+@@ -45,6 +46,7 @@ static void fpm_event_queue_destroy(struct fpm_event_queue_s **queue);
+ static struct fpm_event_module_s *module;
+ static struct fpm_event_queue_s *fpm_event_queue_timer = NULL;
+ static struct fpm_event_queue_s *fpm_event_queue_fd = NULL;
++static struct fpm_event_s children_bury_timer;
+ 
+ static void fpm_event_cleanup(int which, void *arg) /* {{{ */
+ {
+@@ -53,6 +55,12 @@ static void fpm_event_cleanup(int which, void *arg) /* {{{ */
+ }
+ /* }}} */
+ 
++static void fpm_postponed_children_bury(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
++{
++	fpm_children_bury();
++}
++/* }}} */
++
+ static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
+ {
+ 	char c;
+@@ -74,7 +82,12 @@ static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{
+ 		switch (c) {
+ 			case 'C' :                  /* SIGCHLD */
+ 				zlog(ZLOG_DEBUG, "received SIGCHLD");
+-				fpm_children_bury();
++				/* epoll_wait() may report signal fd before read events for a finished child
++				 * in the same bunch of events. Prevent immediate free of the child structure
++				 * and so the fpm_event_s instance. Otherwise use after free happens during
++				 * attemp to process following read event. */
++				fpm_event_set_timer(&children_bury_timer, 0, &fpm_postponed_children_bury, NULL);
++				fpm_event_add(&children_bury_timer, 0);
+ 				break;
+ 			case 'I' :                  /* SIGINT  */
+ 				zlog(ZLOG_DEBUG, "received SIGINT");
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/0ef955fc63588e1e4bca58d5b336083cbeb2af7c



More information about the pld-cvs-commit mailing list