Skip to content
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

Implement clone3 fallback to clone when ENOSYS returns #2081

Closed
wants to merge 1 commit into from

Conversation

yihuaf
Copy link
Collaborator

@yihuaf yihuaf commented Jun 23, 2023

Fix #2030

Potentially controversial:

  • Removed the use of clone3 crate. Our usecase for the clone3 syscall is very specific and do not need to support everything. I can easily replace the clone3 crate with a few lines of code, so I did it in this PR. We usually favors safe syscall wrappers like nix over libc, but I believe the save is worth it here.
  • We use the raw clone syscall instead of glibc wrapper. Details are in the comments.
  • Using raw syscalls for both clone and clone3 actually makes the code well organized. For our usecase, they share the input types.

Otherwise, this PR does what the RFC outline. Unit tests using seccomp profile to simulate clone3 being blocked are added.

Also, I implemented fallback for ENOSYS only. Technically, we can add EPERM to the list as well.

@yihuaf yihuaf marked this pull request as ready for review June 23, 2023 06:46
@yihuaf yihuaf requested review from utam0k, Furisto and a team June 23, 2023 06:46
@yihuaf yihuaf self-assigned this Jun 23, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2023

Codecov Report

Merging #2081 (6dca5a1) into main (dfe6ee8) will increase coverage by 0.17%.
The diff coverage is 93.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2081      +/-   ##
==========================================
+ Coverage   64.82%   65.00%   +0.17%     
==========================================
  Files         129      129              
  Lines       14768    14863      +95     
==========================================
+ Hits         9573     9661      +88     
- Misses       5195     5202       +7     

@yihuaf yihuaf force-pushed the yihuaf/clone_syscall branch from 6dca5a1 to 2db208f Compare June 23, 2023 06:49
implements a clone fallback path when `clone3` is blocked with ENOSYS

Removed the use of clone3 crate. Our usecase for the clone3 crate is
very specific and do not need to support everything. I can easily
replace the clone3 crate with a few lines of code, so I did it in this
PR. We usually favors safe syscall wrappers like nix over libc, but I
believe the save is worth it here.  We use the raw clone syscall instead
of glibc wrapper. Details are in the comments.  Using raw syscalls for
both clone and clone3 actually makes the code well organized. For our
usecase, they share the input types.  Unit tests using seccomp profile
to simulate clone3 being blocked are added.

Signed-off-by: yihuaf <[email protected]>
@yihuaf yihuaf force-pushed the yihuaf/clone_syscall branch from 2db208f to 884d7e8 Compare June 23, 2023 06:57
@yihuaf yihuaf marked this pull request as draft June 23, 2023 08:06
@yihuaf yihuaf closed this Jun 23, 2023
@yihuaf yihuaf deleted the yihuaf/clone_syscall branch June 23, 2023 08:16
@yihuaf
Copy link
Collaborator Author

yihuaf commented Jun 23, 2023

Holding off on this one. It seems we should not be calling raw syscall directly without glibc for clone or clone3...

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.

[RFC] Implement a fallback when clone3 returns ENOSYS
2 participants