Skip to content

[PHP] fix: preserve unix socket path ownership in stat#753

Merged
brandonpayton merged 2 commits into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-unix-socket-path-ownership
Jul 10, 2026
Merged

[PHP] fix: preserve unix socket path ownership in stat#753
brandonpayton merged 2 commits into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-unix-socket-path-ownership

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Why

A filesystem-backed AF_UNIX socket is a pathname node with ordinary owner, group, mode, timestamps, and link metadata. chown(2), chmod(2), and the stat family must round-trip that VFS state; only the reported file type is S_IFSOCK.

Kandelo instead returned a fully synthetic record for every registered Unix-socket path: fixed inode/mode, the caller's current credentials, and zero timestamps. That discarded changes made through the VFS and made PHP and other programs observe false metadata.

What

  • Adds one unix_socket_path_stat helper used by stat, lstat, and fstatat for currently registered AF_UNIX paths.
  • Reads uid, gid, permission bits, timestamps, link count, inode, device, and size from the backing VFS node, then overlays only S_IFSOCK.
  • Preserves parent-directory search checks instead of bypassing them for registered socket paths.
  • Creates a pathname socket's backing node with Linux-observable mode 0777 & ~umask, then records the creating process's uid/gid.
  • Covers initial umask-derived mode and later chmod/chown round-trips through stat, lstat, and fstatat.
  • Documents the registered-path behavior and its current rename/hard-link/process-cleanup boundary in docs/posix-status.md.

Review changes

The original commit exposed the backing placeholder's hard-coded 0600, which would have regressed the previous default visible mode (0755 with the default 022 umask). Review added commit cf73d23d4 to derive the creation mode from the process umask, expand coverage, remove an unexplained st_nlink == 0 rewrite, and document the remaining registry boundary. The original commit was not rewritten.

View

Accept after the review fix. The VFS is now authoritative for pathname-socket metadata, and the kernel registry supplies only the socket type classification. This is shared kernel behavior with no structural ABI change and no Node/browser-specific branch.

Current limitation: the socket classification applies while the pathname is registered. Registry state does not yet follow hard links or renames, and process cleanup can leave the backing placeholder as an ordinary VFS file.

Focused validation

On both the PR branch and a clean replay onto the live batch-1 tip:

cargo test -p kandelo --target aarch64-apple-darwin --lib unix_socket -- --nocapture

Result each time: 9 passed, 0 failed. The full kernel/host/libc/POSIX/ABI gate remains deferred to the final batch tree.

Provenance

Supersedes fork-headed PR #733. Original head commit 3a46eb51619f242fea44dd5978fca33aee31d714 was preserved; the review fix was appended without force-pushing.

(cherry picked from commit 80396cd)
(cherry picked from commit c40c493)
@brandonpayton
brandonpayton changed the base branch from integration/kd-6nz-php-phpt-harness-only-base to integration/kd-6nz-php-phpt-batch-1-kernel-fixes July 10, 2026 17:57
@brandonpayton
brandonpayton merged commit 91d1395 into integration/kd-6nz-php-phpt-batch-1-kernel-fixes Jul 10, 2026
1 check passed
@brandonpayton
brandonpayton deleted the gascity/kd-6nz/split-pr717-unix-socket-path-ownership branch July 10, 2026 17:57
brandonpayton pushed a commit that referenced this pull request Jul 13, 2026
(cherry picked from commit 80396cd)
(cherry picked from commit c40c493)

Curated-Reconstruction: combines authoritative path ownership with umask-derived mode handling from #753.
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