[packages/php/PHP_7_2] Rel 28. Fix FPM use-after-free of reaped children
arekm
arekm at pld-linux.org
Thu Nov 19 21:44:06 CET 2026
commit 97676df227506c71b7c5bdaff45292588ab5b519
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Nov 19 21:35:53 2026 +0100
Rel 28. 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 07c1c0f..73f483c 100644
--- a/php.spec
+++ b/php.spec
@@ -155,7 +155,7 @@ Summary(ru.UTF-8): PHP Версии 7 - язык препроцессирова
Summary(uk.UTF-8): PHP Версії 7 - мова препроцесування HTML-файлів, виконувана на сервері
Name: %{orgname}%{php_suffix}
Version: 7.2.34
-Release: 27
+Release: 28
Epoch: 4
# All files licensed under PHP version 3.01, except
# Zend is licensed under Zend
@@ -379,6 +379,7 @@ Patch330: php-cve-2026-127960.patch
Patch331: php-cve-2026-129496.patch
Patch332: php-cve-2026-129474.patch
Patch333: php-cve-2026-129481.patch
+Patch334: 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}
@@ -2351,6 +2352,7 @@ cp -p php.ini-production php.ini
%patch -P331 -p1
%patch -P332 -p1
%patch -P333 -p1
+%patch -P334 -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..1beebba
--- /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 f7aebce5..1ddcf776 100644
+--- a/sapi/fpm/fpm/fpm_events.c
++++ b/sapi/fpm/fpm/fpm_events.c
+@@ -35,6 +35,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);
+@@ -44,6 +45,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) /* {{{ */
+ {
+@@ -52,6 +54,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;
+@@ -73,7 +81,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/97676df227506c71b7c5bdaff45292588ab5b519
More information about the pld-cvs-commit
mailing list