[php-src] PR #25941: ext/pcntl: Fix UAF in pcntl_signal_dispatch() when handler is replaced
| From: | hohphu8 | Date: | Mon, 30 Nov 2026 11:42:34 +0000 |
| Subject: | [php-src] PR #25941: ext/pcntl: Fix UAF in pcntl_signal_dispatch() when handler is replaced | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41243@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25941
Author: hohphu8
When dispatching a queued signal in
pcntl_signal_dispatch()
(ext/pcntl/pcntl.c), handle points directly into
PCNTL_G(php_signal_table) without holding an extra reference. If an error handler
triggered while invoking the callable (for example, a #[Deprecated] closure handler)
replaces or resets that signal via pcntl_signal(), php_signal_table
destroys the original handler zval while call_user_function() is still using it,
causing a use-after-free / SIGSEGV.
This copies handle into a local handle_copy with ZVAL_COPY(),
passes &handle_copy to call_user_function(), and releases it
afterwards with zval_ptr_dtor().
Adds ext/pcntl/tests/pcntl_signal_dispatch_closure_uaf.phpt. Verified crash (SIGSEGV)
-> PASS on PHP-8.4 (Debug + ZTS), with ext/pcntl/tests/*signal*.phpt
passing 15/15.
Note: AI-assisted code audit; manually verified and reproduced locally.