kernel: keep passed pipe and socket descriptors alive#949
Open
brandonpayton wants to merge 1 commit into
Open
Conversation
Track endpoint references owned by queued descriptors separately from externally owned readers. Successful recvmsg transfers each reference to its new OFD, while unusable control buffers and receiver allocation failures release it exactly once. Install the descriptor prefix that fits a short control buffer, close the excess, and report MSG_CTRUNC. Mark ancillary queues reachable from live receive endpoints and follow queued socket rights as graph edges, then sweep unrooted self and mutual cycles. Add kernel slot-reuse coverage and a real Wasm regression for read/write endpoint transfer, live and abandoned socket-rights cycles, absent and truncated control buffers, and partial EMFILE installation. This changes no ABI structure or version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
SCM_RIGHTS is the Unix socket mechanism for sending open file descriptors from one process to another. recvmsg is the receiving system call, and a queued descriptor must keep its pipe or socket endpoint alive until that transfer finishes or is discarded.
SCM_RIGHTS queued serialized pipe and socket descriptors without owning their underlying endpoint references while they were in transit. Closing the sender descriptor could therefore free a resource before recvmsg installed it. The opposite failure also existed: socket descriptors queued inside self or mutual cycles kept global pipe slots alive forever.
This is a kernel ownership bug, not a package workaround. It is also a prerequisite for named-pipe descriptor passing in #864.
What changed
This changes no ABI structure or version.
Validation
Run through scripts/dev-shell.sh on exact commit 792e8b8:
A second independent devil review found no blocking ownership, collection, rollback, or ABI defect. Browser and external POSIX conformance suites were not run.
Follow-up boundary
The pre-existing pseudo-terminal (PTY) and ordinary-file EMFILE (file descriptor table full) rollback gap remains separate. When #864 is stacked on this change, FIFO descriptors must add explicit ownership for O_PATH, O_RDWR, and the FIFO read-only cohort rather than infer ownership only from O_ACCMODE.
Current CI dependency
The first staging run on this PR stopped before the test suites while materializing the unchanged ABI 39 package baseline. This branch and current main compute Bash cache key 9fe79ff8d7200b5b5ea10651d55dc2ed2332439d1ad1c71ec86e36c9c6cfc6f0, while the canonical ABI 39 index still points to f62b8fb529fd8ef2294e68e2a5067988c0edeb3ae88883bfcc8ac19cfe737019; 56 packages report the same stale-baseline condition.
#936 has already staged the package set for its post-merge tree (for example Bash 2844dd3e31af14bfc2af68ead82a41cca6b54297012b5d7231c719f834d35ab2) and owns promotion of that verified baseline. This PR must be rebased and rerun after #936 merges. No fetch bypass or package artifact change belongs in this kernel PR.