diff --git a/changelog.d/+statfs-go-hook.removed.md b/changelog.d/+statfs-go-hook.removed.md new file mode 100644 index 00000000000..3c94b799360 --- /dev/null +++ b/changelog.d/+statfs-go-hook.removed.md @@ -0,0 +1 @@ +Removed faulty `statfs` hook for Go applications. diff --git a/mirrord/layer/src/file/hooks.rs b/mirrord/layer/src/file/hooks.rs index 3fcfc3c1280..289b10a34d6 100644 --- a/mirrord/layer/src/file/hooks.rs +++ b/mirrord/layer/src/file/hooks.rs @@ -906,7 +906,7 @@ unsafe extern "C" fn fstatat_detour( /// Hook for `libc::fstatfs`. #[hook_guard_fn] -pub(crate) unsafe extern "C" fn fstatfs_detour(fd: c_int, out_stat: *mut statfs) -> c_int { +unsafe extern "C" fn fstatfs_detour(fd: c_int, out_stat: *mut statfs) -> c_int { if out_stat.is_null() { return HookError::BadPointer.into(); } @@ -922,10 +922,7 @@ pub(crate) unsafe extern "C" fn fstatfs_detour(fd: c_int, out_stat: *mut statfs) /// Hook for `libc::statfs`. #[hook_guard_fn] -pub(crate) unsafe extern "C" fn statfs_detour( - raw_path: *const c_char, - out_stat: *mut statfs, -) -> c_int { +unsafe extern "C" fn statfs_detour(raw_path: *const c_char, out_stat: *mut statfs) -> c_int { if out_stat.is_null() { return HookError::BadPointer.into(); } diff --git a/mirrord/layer/src/go/linux_x64.rs b/mirrord/layer/src/go/linux_x64.rs index 622a24383d7..2b2cf5870ee 100644 --- a/mirrord/layer/src/go/linux_x64.rs +++ b/mirrord/layer/src/go/linux_x64.rs @@ -340,8 +340,10 @@ unsafe extern "C" fn c_abi_syscall_handler( faccessat_detour(param1 as _, param2 as _, param3 as _, 0) as i64 } libc::SYS_fstat => fstat_detour(param1 as _, param2 as _) as i64, - libc::SYS_statfs => statfs_detour(param1 as _, param2 as _) as i64, - libc::SYS_fstatfs => fstatfs_detour(param1 as _, param2 as _) as i64, + // Currently disabled due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). + // libc::SYS_statfs => statfs_detour(param1 as _, param2 as _) as i64, + // Currently disabled due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). + // libc::SYS_fstatfs => fstatfs_detour(param1 as _, param2 as _) as i64, libc::SYS_getdents64 => getdents64_detour(param1 as _, param2 as _, param3 as _) as i64, #[cfg(all(target_os = "linux", not(target_arch = "aarch64")))] libc::SYS_mkdir => mkdir_detour(param1 as _, param2 as _) as i64, diff --git a/mirrord/layer/src/go/mod.rs b/mirrord/layer/src/go/mod.rs index 6a28c3ebfd9..d5a596f2259 100644 --- a/mirrord/layer/src/go/mod.rs +++ b/mirrord/layer/src/go/mod.rs @@ -101,8 +101,10 @@ unsafe extern "C" fn c_abi_syscall6_handler( .into() } libc::SYS_fstat => fstat_detour(param1 as _, param2 as _) as i64, - libc::SYS_statfs => statfs_detour(param1 as _, param2 as _) as i64, - libc::SYS_fstatfs => fstatfs_detour(param1 as _, param2 as _) as i64, + // Currently disabled due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). + // libc::SYS_statfs => statfs_detour(param1 as _, param2 as _) as i64, + // Currently disabled due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). + // libc::SYS_fstatfs => fstatfs_detour(param1 as _, param2 as _) as i64, libc::SYS_fsync => fsync_detour(param1 as _) as i64, libc::SYS_fdatasync => fsync_detour(param1 as _) as i64, libc::SYS_openat => { diff --git a/mirrord/layer/tests/apps/fileops/go/main.go b/mirrord/layer/tests/apps/fileops/go/main.go index 69db336fb3e..16ef4b33009 100644 --- a/mirrord/layer/tests/apps/fileops/go/main.go +++ b/mirrord/layer/tests/apps/fileops/go/main.go @@ -7,21 +7,23 @@ import ( func main() { tempFile := "/tmp/test_file.txt" - fd, _ := syscall.Open(tempFile, syscall.O_CREAT|syscall.O_WRONLY, 0644) + syscall.Open(tempFile, syscall.O_CREAT|syscall.O_WRONLY, 0644) var stat syscall.Stat_t err := syscall.Stat(tempFile, &stat) if err != nil { panic(err) } - var statfs syscall.Statfs_t - err = syscall.Statfs(tempFile, &statfs) - if err != nil { - panic(err) - } + // statfs/fstatfs hooks are currently disabled in Go apps due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). - err = syscall.Fstatfs(fd, &statfs) - if err != nil { - panic(err) - } + // var statfs syscall.Statfs_t + // err = syscall.Statfs(tempFile, &statfs) + // if err != nil { + // panic(err) + // } + + // err = syscall.Fstatfs(fd, &statfs) + // if err != nil { + // panic(err) + // } } diff --git a/mirrord/layer/tests/fileops.rs b/mirrord/layer/tests/fileops.rs index de26b318f40..315542717c0 100644 --- a/mirrord/layer/tests/fileops.rs +++ b/mirrord/layer/tests/fileops.rs @@ -345,8 +345,9 @@ async fn go_stat( )))) .await; - intproxy.expect_statfs("/tmp/test_file.txt").await; - intproxy.expect_fstatfs(fd).await; + // statfs/fstatfs hooks are currently disabled in Go apps due to a [bug](https://github.com/metalbear-co/mirrord/issues/3044). + // intproxy.expect_statfs("/tmp/test_file.txt").await; + // intproxy.expect_fstatfs(fd).await; test_process.wait_assert_success().await; test_process.assert_no_error_in_stderr().await;