Add Linux-specific pidfd process extensions (take 2)#81825
Add Linux-specific pidfd process extensions (take 2)#81825bors merged 7 commits intorust-lang:masterfrom
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Just checking for ENOSYS is sadly not enough here.
The syscall can also be blocked by seccomp (EPERM).
We have also found cases where new syscalls where randomly broken on some configurations (see the EOPNOTSUPP comment here. Though, I think we can ignore this case for now.
There was a problem hiding this comment.
EPERM and EOPNOTSUPP might depend on the arguments of the clone3 call. It would be wrong to set HAS_CLONE3 to false if one of these errors occurred.
There was a problem hiding this comment.
In that case the usual approach is to perform the probe separately with arguments that are known to fail with a specific error code, e.g. an invalid combination of flags leading to EINVAL. If that returns EPERM then we know the syscall is filtered. CLONE_SIGHAND | CLONE_CLEAR_SIGHAND could work.
There was a problem hiding this comment.
Maybe we could just fallback to fork on EPERM without setting HAS_CLONE3.
There was a problem hiding this comment.
That could be considered slightly suboptimal since it'll try again every time in that case, but we already have a preferred path through posix_spawn so this shouldn't be hit too frequently.
There was a problem hiding this comment.
My concern was whether it would be possible for clone3 to succeed after having returned EPERM once. In case of ENOSYS we can be certain that any future calls will fail as well. For EPERM, this conclusion does potentially not hold since a seccomp filter could be defined in terms of arbitrary rules.
There was a problem hiding this comment.
I don't think we need to account for arbitrary seccomp filters here. seccomp filters should produce ENOSYS, not EPERM.
This comment has been minimized.
This comment has been minimized.
|
r? @m-ou-se or perhaps @joshtriplett |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #82045) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
|
@joshtriplett I think you were interested in the original PR. Would you mind taking a look at this? |
|
☔ The latest upstream changes (presumably #82877) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
|
📌 Commit f48caef6fc47df6acfb9d72f1a254e503e98b557 has been approved by |
|
⌛ Testing commit f48caef6fc47df6acfb9d72f1a254e503e98b557 with merge d1b9a4c984315ffa8365dbdfbdc5a331f5adcd8e... |
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed - checks-actions |
|
@Aaron1011 Thanks for tending to this issue! Unfortunately, I think the workaround in your commit is not enough to circumvent the LLVM bug. To my knowledge, the combination of List of failing tests |
|
I went ahead and added List of tests |
|
#87610 may address this. Let's give it another try (with the workarounds removed) once that has gone in. |
|
@joshtriplett I removed the workarounds. |
|
📌 Commit 741176a38771b233bdd6f972929a3930682da169 has been approved by |
|
⌛ Testing commit 741176a38771b233bdd6f972929a3930682da169 with merge a2522c6c85a7388a80cb33edc2ce2631b0695f99... |
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed - checks-actions |
|
All of the non-Apple builders passes, so the LLVM issue is fixed 🎉 The failing tests need to be made Linux-only (or be adjusted to avoid |
The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent. However, libc::getpid() returns the wrong value. Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls. The cached value is only updated when the wrapper functions for fork or clone are called. In PR rust-lang#81825 we switch to directly using the clone3 syscall. Thus, the cache is not updated and getpid returns the PID of the parent. source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES
|
@Aaron1011 Okay, I fixed it! And thanks for seeing to the LLVM fix getting merged so fast! 😃 |
|
@bors r=joshtriplett |
|
📌 Commit 4a832d3 has been approved by |
|
☀️ Test successful - checks-actions |
|
@voidc: Thanks for all of your work getting this over the finish line! |
|
🎉 🎉 Finally! Thanks for your patience @Aaron1011 and @joshtriplett during all of these 200+ comments and 15+ bors runs 😂 |
|
Thank you all for your work. Very happy to see upstream work make it into this project. :) |
Continuation of #77168.
I addressed the following concerns from the original PR:
CommandExtandChildExtsealed traitsPidFdstruct representing ownership over the fdtake_pidfdto take the fd out ofChildTracking Issue: #82971