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

Add missing exec hooks on partial load, macOS #2840

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+enable-exec-hooks-on-sip.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing exec hooks on partial load, macOS
11 changes: 11 additions & 0 deletions mirrord/layer/src/exec_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
#[mirrord_layer_macro::instrument(level = "trace")]
pub(super) fn patch_if_sip(path: &str) -> Detour<String> {
let patch_binaries = PATCH_BINARIES.get().expect("patch binaries not set");
// some binaries don't need to be sip patched, because they don't chain-execute (i.e we don't
// care about the commands they run) for example, "go run" needs to be sip patched because

Check warning on line 66 in mirrord/layer/src/exec_utils.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/mirrord/mirrord/mirrord/layer/src/exec_utils.rs

Check warning on line 66 in mirrord/layer/src/exec_utils.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/mirrord/mirrord/mirrord/layer/src/exec_utils.rs
// it builds then executes. but gcc never executes the binary, so we don't need to sip patch
// it.
const BYPASS_BINARIES: &[&str] = &[
"/uname",
"/xcrun"
];
if BYPASS_BINARIES.iter().any(|bin| path.ends_with(bin)) {
return Bypass(NoSipDetected(path.to_string()));
}
match sip_patch(path, patch_binaries) {
Ok(None) => Bypass(NoSipDetected(path.to_string())),
Ok(Some(new_path)) => Success(new_path),
Expand Down
4 changes: 3 additions & 1 deletion mirrord/layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ fn sip_only_layer_start(mut config: LayerConfig, patch_binaries: Vec<String>) {
load_only_layer_start(&config);

let mut hook_manager = HookManager::default();

unsafe {
exec_hooks::hooks::enable_exec_hooks(&mut hook_manager);
}
unsafe { exec_utils::enable_macos_hooks(&mut hook_manager, patch_binaries) };

// we need to hook file access to patch path to our temp bin.
Expand Down
6 changes: 5 additions & 1 deletion mirrord/layer/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
"link",
"math",
"cargo",
"clang",
"compile",
"hpack",
"rustc",
"compile",
"collect2",
"cargo-watch",
"debugserver",
"jspawnhelper",

Check warning on line 37 in mirrord/layer/src/load.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/mirrord/mirrord/mirrord/layer/src/load.rs

Check warning on line 37 in mirrord/layer/src/load.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/mirrord/mirrord/mirrord/layer/src/load.rs
"strip",
"dsymutil",
"xcrun"
])
});

Expand Down
Loading