[php-src] PR #22085: Fix GH-22060: UAF in class-autoloader dispatch on self-unregister
| From: | iliaal | Date: | Tue, 19 May 2026 00:33:18 +0000 |
| Subject: | [php-src] PR #22085: Fix GH-22060: UAF in class-autoloader dispatch on self-unregister | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36173@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22085
Author: iliaal
A method-bound autoloader registered as
[$obj, 'load'] can call
spl_autoload_unregister([$this, 'load']) from inside its own callback. The
hash entry's destructor releases the last ref on the object, frees it, and the rest of the PHP
body (e.g. echo $this->data) reads freed memory. The dispatch loop in
zend_perform_class_autoload calls zend_call_known_fcc(func_info, ...), but
zend_call_function reads fci_cache->object into EX(This)
without bumping the refcount; the call convention is that the caller holds the ref, and here the
only ref was the hash entry's.
Fix pins object and closure across the call with
GC_ADDREF/OBJ_RELEASE. The pointers are saved locally before the call so
the releases work even when func_info itself is freed mid-call by self-unregister.