Skip to content

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

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

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

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@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 php#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
@iliaal iliaal force-pushed the fix/gh-13230-phpdbg-watch-uaf branch from ce59a1f to fd289bc Compare May 21, 2026 12:13
@iliaal
Copy link
Copy Markdown
Owner Author

iliaal commented May 21, 2026

Superseded by php#22111.

@iliaal iliaal closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use-after-free at phpdbg shutdown

1 participant