Skip to content

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Oct 25, 2025

  • Replace process::Command execution with direct execvp call via libc for improved performance by avoiding process forking
  • Add validation to detect and error on commands containing null bytes
  • Capture and handle execution errors using the last OS error after execvp failure

fix this issue
#9010

- Replace process::Command execution with direct execvp call via libc for improved performance by avoiding process forking
- Add validation to detect and error on commands containing null bytes
- Capture and handle execution errors using the last OS error after execvp failure
@Arcterus
Copy link
Collaborator

Arcterus commented Oct 25, 2025

Rather than using execvp() directly, it'd probably be better to rely on the Command::exec() function provided by CommandExt.

CommandExt actually provides a number of things we do here manually with libc, so we might be able to move e.g. the actual chroot() and uid/gid changes and so on to the stdlib.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 25, 2025

CodSpeed Performance Report

Merging #9013 will not alter performance

Comparing mattsu2020:fix_chroot (6524f50) with main (3b2cb6a)

Summary

✅ 105 untouched
⏩ 74 skipped1

Footnotes

  1. 74 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

… execution

Simplified the command execution by using Rust's standard ProcessCommand instead of direct libc calls, improving code readability and reducing manual memory management.
@mattsu2020
Copy link
Contributor Author

Rather than using execvp() directly, it'd probably be better to rely on the Command::exec() function provided by CommandExt.

CommandExt actually provides a number of things we do here manually with libc, so we might be able to move e.g. the actual chroot() and uid/gid changes and so on to the stdlib.

I made some revisions based on your feedback.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@fulalas
Copy link

fulalas commented Oct 25, 2025

I confirm this change fixes #9010

Nice job! :)

@sylvestre
Copy link
Contributor

would it be possible to add a test? thanks

Added three new tests to verify chroot behavior:
- Test for command not found, expecting exit code 127 and "No such file or directory" error.
- Test for permission denied, expecting exit code 126 and "Permission denied" error.
- Test to confirm UID and GID are retained as root (0) inside the chroot.

These tests enhance coverage for edge cases and ensure robust error reporting, requiring root privileges to run.
Added 'noexec' to the jargon wordlist to recognize this technical term and avoid false positives during spell checking in the project.
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@mattsu2020
Copy link
Contributor Author

would it be possible to add a test? thanks

Done

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.

4 participants