Skip to content

[Session] destroy session file without an open descriptor - #273

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/session-destroy-closed-fd-84
Closed

[Session] destroy session file without an open descriptor#273
iliaal wants to merge 1 commit into
PHP-8.4from
fix/session-destroy-closed-fd-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

PS_DESTROY_FUNC(files) unlinked the session file only inside the data->fd != -1 branch, so destroying a session whose file was never opened this request or whose descriptor was closed after a failed reopen returned SUCCESS while leaving the file on disk. It now unlinks after ps_files_close() so the key path is always removed; the access() check tolerates a missing file. PS(mm) has no descriptor gate and mod_user delegates to userland. A new test destroys a session from an error handler during session_start() when its mode-0444 file fails to open, failing on unpatched PHP-8.4.

@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
PS_DESTROY_FUNC(files) skipped the unlink when data->fd was -1, so a
destroy of a never-opened or already-closed session file returned
SUCCESS while the file stayed on disk. The unlink now always runs after
the optional ps_files_close(), tolerating ENOENT via the existing
access() check. Sibling audit: PS_DESTROY_FUNC(mm) and mod_user have no
descriptor gate, and the files close/read/write paths keep their
existing descriptor handling.
@iliaal
iliaal force-pushed the fix/session-destroy-closed-fd-84 branch from 143d796 to 4bfab31 Compare September 10, 2026 22:09
@iliaal

iliaal commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Upstream: php#23656

@iliaal iliaal closed this Sep 10, 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.

1 participant