diff --git a/mirrord/layer/src/common.rs b/mirrord/layer/src/common.rs index ef0d801a072..bd0d1ce3ac9 100644 --- a/mirrord/layer/src/common.rs +++ b/mirrord/layer/src/common.rs @@ -1,5 +1,10 @@ //! Shared place for a few types and functions that are used everywhere by the layer. -use std::{ffi::CStr, fmt::Debug, ops::Not, path::PathBuf}; +use std::{ + ffi::CStr, + fmt::{Debug, Display}, + ops::Not, + path::PathBuf, +}; use libc::c_char; use mirrord_intproxy_protocol::{IsLayerRequest, IsLayerRequestWithResponse, MessageId}; @@ -118,6 +123,8 @@ impl CheckedInto for *const c_char { } } +// **Warning**: The implementation here expects that `*const *const c_char` be a valid, +// null-terminated list! We're using `Nul::new_unchecked`, which doesn't check for this. impl CheckedInto for *const *const c_char { fn checked_into(self) -> Detour { let c_list = self diff --git a/mirrord/layer/src/exec_hooks/hooks.rs b/mirrord/layer/src/exec_hooks/hooks.rs index aabf45c086e..9c36eddb480 100644 --- a/mirrord/layer/src/exec_hooks/hooks.rs +++ b/mirrord/layer/src/exec_hooks/hooks.rs @@ -19,7 +19,7 @@ use crate::{ /// Converts the [`SOCKETS`] map into a vector of pairs `(Fd, UserSocket)`, so we can rebuild /// it as a map. -#[tracing::instrument(level = Level::TRACE, ret)] +#[mirrord_layer_macro::instrument(level = Level::TRACE, ret)] fn shared_sockets() -> Vec<(i32, UserSocket)> { SOCKETS .iter() @@ -95,6 +95,7 @@ pub(crate) unsafe extern "C" fn execve_detour( argv: *const *const c_char, envp: *const *const c_char, ) -> c_int { + // Hopefully `envp` is a properly null-terminated list. let checked_envp = envp.checked_into(); if let Detour::Success(modified_envp) = execve(checked_envp) { @@ -108,7 +109,6 @@ pub(crate) unsafe extern "C" fn execve_detour( _ => FN_EXECVE(path, argv, envp), } - // tracing::info!("Success execve!"); #[cfg(target_os = "linux")] FN_EXECVE(path, argv, modified_envp) } else {