Skip to content

Fix GH-13230: phpdbg use-after-free at shutdown#22111

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/gh-13230-phpdbg-watch-uaf
Open

Fix GH-13230: phpdbg use-after-free at shutdown#22111
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/gh-13230-phpdbg-watch-uaf

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented May 21, 2026

phpdbg_watch_element back-pointers to phpdbg_watchpoint_t went stale when the watchpoint was freed, and phpdbg_destroy_watchpoints iterated its hashes in MSHUTDOWN after zend_mm_shutdown freed their backings. Non-ASAN tolerated the read, ZTS ASAN aborted.

Late notices that watch_.phpt and gh15210_.phpt previously expected were artifacts of reading freed memory; they're dropped from the expected outputs.

Fixes #13230

phpdbg_watch_element back-pointers to phpdbg_watchpoint_t went stale
when the watchpoint was freed, defeating the phpGH-13681 NULL guards.
phpdbg_destroy_watchpoints also iterated its hashes in MSHUTDOWN, after
zend_mm_shutdown freed their emalloc backings: non-ASAN tolerated the
read, ZTS ASAN aborted. NULL the back-pointer in
phpdbg_clean_watch_element, tolerate NULL in phpdbg_backup_watch_element,
unregister the freed element from watch_recreation in
phpdbg_free_watch_element, and move the recreation drain and the
btree plus hash reset into RSHUTDOWN so the work runs while emalloc
memory is alive. Drop the late notices from the existing watch_*,
gh15210_*, and bug73927 expected outputs since they were artifacts of
reading freed memory.

Fixes phpGH-13230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use-after-free at phpdbg shutdown

1 participant