-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG #113939
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
ping @Mark-Simulacrum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me modulo comment fix and/or if removal
msg.msg_controllen = mem::size_of::<Cmsg>() as _; | ||
msg.msg_control = &mut cmsg as *mut _ as *mut _; | ||
|
||
match cvt_r(|| libc::recvmsg(sock.as_raw(), &mut msg, 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a timeout here (or something like it) at all? E.g., if we're unlucky and the child process is kill'd by something before we get the pidfd sent back? Or will that close the stream and end here?
My sense is that we should be ok, but wanted to raise in case I overlooked something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent closes its output
, so only the child holds the remote side of the socket open. If the child gets killed that gets closed, which disconnects the socket which in turn leads to a 0-length read in the parent and a return from this function.
78ea4c1
to
4673247
Compare
@bors r=Mark-Simulacrum |
📌 Commit 4673247bf49c260e952082d463fb74342aa81434 has been approved by It is now in the queue for this repository. |
⌛ Testing commit 4673247bf49c260e952082d463fb74342aa81434 with merge 829cf9a30cfb622ec07dbad9fddeffdae487b630... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
…+CMSG This is a 100% race-free way to obtain a child's pidfd while avoiding `clone3`.
4673247
to
8d349c1
Compare
fixed cfg on the test @bors r=Mark-Simulacrum |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#113939 (open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG) - rust-lang#114548 (Migrate a trait selection error to use diagnostic translation) - rust-lang#114606 (fix: not insert missing lifetime for `ConstParamTy`) - rust-lang#114634 (Mention riscv64-linux-android support in Android documentation) - rust-lang#114638 (Remove old RPITIT tests (revisions were removed)) - rust-lang#114641 (Rename copying `ascii::Char` methods from `as_` to `to_`) r? `@ghost` `@rustbot` modify labels: rollup
…ochenkov Clean up after clone3 removal from pidfd code (docs and tests) rust-lang#113939 removed clone3 from pidfd code. This patchset does necessary clean up: fixes docs and tests
…ochenkov Clean up after clone3 removal from pidfd code (docs and tests) rust-lang#113939 removed clone3 from pidfd code. This patchset does necessary clean up: fixes docs and tests
Rollup merge of rust-lang#120306 - safinaskar:clone3-clean-up, r=petrochenkov Clean up after clone3 removal from pidfd code (docs and tests) rust-lang#113939 removed clone3 from pidfd code. This patchset does necessary clean up: fixes docs and tests
This avoids using
clone3
when a pidfd is requested while still getting it in a 100% race-free manner by passing it up from the child process.This should solve most concerns in #82971