Skip to content

[pull] master from php:master - #1222

Merged
pull[bot] merged 8 commits into
turkdevops:masterfrom
php:master
Aug 26, 2026
Merged

[pull] master from php:master#1222
pull[bot] merged 8 commits into
turkdevops:masterfrom
php:master

Conversation

@pull

@pull pull Bot commented Aug 26, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

prateekbhujel and others added 8 commits August 26, 2026 16:45
* PHP-8.4:
  [ci skip] NEWS
  Fix GH-19320: Prevent FPM UID and GID overflow (#22986)
* PHP-8.5:
  [ci skip] NEWS
  Fix GH-19320: Prevent FPM UID and GID overflow (#22986)
Here we passes a properly null-terminated copy of the shortened path
to `phar_mount_entry()` instead and keep `test` alive until error
formatting and manifest lookup have completed.
* origin/PHP-8.4:
  Fix GH-23418: UAF when accessing mounted Phar subdirectories (#23442)
* PHP-8.5:
  Fix GH-23418: UAF when accessing mounted Phar subdirectories (#23442)
Three places dispatch on the page map entry of a pointer, and reach the
large-run case by elimination, with the assumption written down as a
comment rather than checked:

    if (EXPECTED(info & ZEND_MM_IS_SRUN)) {
        ...
    } else /* if (info & ZEND_MM_IS_LRUN) */ {

The assumption does not always hold: when ZEND_MM_IS_FRUN is 0 and
zend_mm_free_pages_ex() zeroes chunk->map[page_num], a pointer to a
large run that has already been freed has info == 0, so it fails the SRUN test,
and falls into the large-run branch. There, ZEND_MM_LRUN_PAGES(0) is 0,
and the three callers quietly degrade:

 - zend_mm_free_heap() frees a run of zero pages, i.e. a double free of a
   large block is accepted and does nothing at all.
 - zend_mm_size() reports a block size of 0.
 - zend_mm_realloc_heap() takes old_size 0 and reallocates from there.

A large-block double free or a use of a freed pointer is silently absorbed by
the allocator instead of being a hard failure. This commit promotes the comment
to a real ZEND_MM_CHECK() in all three. The value is already in a register at
that point, so it costs a test and a branch.

This was checked under GDB by allocating a large block, freeing it, and then
reusing the pointer. Before, _efree() returned normally,
_zend_mem_block_size() returned 0 and _erealloc() returned a new pointer.
After this commit, each of the three aborts with "zend_mm_heap corrupted".

Amusingly, the two comments naming ZEND_MM_IS_LARGE_RUN referred to a
macro that does not exist: the real name is ZEND_MM_IS_LRUN.
@pull pull Bot locked and limited conversation to collaborators Aug 26, 2026
@pull pull Bot added the ⤵️ pull label Aug 26, 2026
@pull
pull Bot merged commit 0c87849 into turkdevops:master Aug 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants