Tidy handling of privileged operation fds#666
Draft
smcv wants to merge 3 commits intocontainers:mainfrom
Draft
Conversation
…kets Both sockets in this socket pair are technically bidirectional, but we're using them in a way that is close enough to unidirectional that using these symbolic constants is clearer than magic numbers. We send multi-byte requests into the write end, and read those requests from the read end (even though we also send a 1-byte reply to each request into the "read" end, and read it from the "write" end). Signed-off-by: Simon McVittie <smcv@collabora.com>
This is inspired by g_steal_fd() in GLib, and lets us make it explicit that ownership of a fd is being moved, similar to steal_pointer(). Signed-off-by: Simon McVittie <smcv@collabora.com>
Setting the members of privsep_sockets[] to -1 when they have been closed or had their ownership transferred is clearer than leaving behind dangling references. Signed-off-by: Simon McVittie <smcv@collabora.com>
smcv
added a commit
to smcv/bubblewrap
that referenced
this pull request
Oct 30, 2024
This avoids leaving dangling references to fds that no longer exist, clarifying ownership. This commit does not cover the socket pairs used to transfer the pid of a descendant process (see containers#665 for that) and privilege-separated operations (see containers#666). Signed-off-by: Simon McVittie <smcv@collabora.com>
This was referenced Oct 30, 2024
Collaborator
Author
... is not (currently) something that |
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.
Similar to #665, but for the socket pair that communicates privileged operations between the temporary unprivileged child and the privileged parent when we are setuid root.
Use PIPE_READ_END, PIPE_WRITE_END to clarify use of privileged op sockets
Both sockets in this socket pair are technically bidirectional, but
we're using them in a way that is close enough to unidirectional that
using these symbolic constants is clearer than magic numbers.
We send multi-byte requests into the write end, and read those requests
from the read end (even though we also send a 1-byte reply to each request
into the "read" end, and read it from the "write" end).
utils: Add steal_fd()
This is inspired by g_steal_fd() in GLib, and lets us make it explicit
that ownership of a fd is being moved, similar to steal_pointer().
Clarify ownership of privileged op sockets
Setting the members of privsep_sockets[] to -1 when they have been
closed or had their ownership transferred is clearer than leaving behind
dangling references.
cc @refi64