Loading include/client/preload_context.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public: is_internal_fd(int fd) const; void protect_user_fds(); protect_user_fds(int root_fd); void unprotect_user_fds(); Loading scripts/compile_dep.sh +14 −0 Original line number Diff line number Diff line Loading @@ -471,6 +471,20 @@ while [[ $# -gt 0 ]]; do help_msg exit ;; -a | --arch) ARCH=$2 echo "System arch is $ARCH" if [[ "$ARCH" == "arm64" ]];then SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" PROFILE_VERSION="${DEFAULT_VERSION}.arm64" else SOURCES_FILE="${PROFILES_DIR}/sources.list" fi echo "SOURCES_FILE is set to ${SOURCES_FILE}" shift # past argument shift # past value ;; -n | --dry-run) DRY_RUN=true shift Loading scripts/dl_dep.sh +24 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ COMMON_CURL_FLAGS="--silent --fail --show-error --location -O" COMMON_GIT_FLAGS="--quiet --single-branch -c advice.detachedHead=false" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PATCH_DIR="${SCRIPT_DIR}/patches" ARCH="" DEPENDENCY="" EXECUTION_MODE= Loading @@ -42,7 +43,9 @@ DEFAULT_VERSION="latest" PROFILE_NAME=${DEFAULT_PROFILE} PROFILE_VERSION=${DEFAULT_VERSION} PROFILES_DIR="${SCRIPT_DIR}/profiles" SOURCES_FILE="${PROFILES_DIR}/sources.list" SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" declare -a PROFILE_DEP_LIST declare -A PROFILE_DEP_NAMES declare -A PROFILE_WGETDEPS PROFILE_CLONEDEPS PROFILE_SOURCES Loading Loading @@ -174,7 +177,7 @@ load_profile() { PROFILE_WGETDEPS=() local filename="${PROFILES_DIR}/${version}/${profile}.specs" echo "filename is $filename" if [[ ! -f "${filename}" ]]; then echo "Profile '${profile}:${version}' does not exist." exit 1 Loading Loading @@ -307,6 +310,7 @@ usage_short() { usage: dl_dep.sh -p PROFILE_NAME[:PROFILE_VERSION] | -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | -l [[PROFILE_NAME:]PROFILE_VERSION] | -a [ARCH] | -h [ -P PROFILES_DIR ] [ -n ] DESTINATION_PATH Loading Loading @@ -345,6 +349,7 @@ optional arguments: Choose the directory to be used when searching for profiles. If unspecified, PROFILES_DIR defaults to \${PWD}/profiles. -n, --dry-run Do not actually run, print only what would be done. -a, --arch The arch of the target host. -v, --verbose Increase download verbosity " } Loading Loading @@ -439,6 +444,20 @@ while [[ $# -gt 0 ]]; do exit ;; -a | --arch) ARCH=$2 echo "System arch is $ARCH" if [[ "$ARCH" == "arm64" ]];then SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" PROFILE_VERSION="${DEFAULT_VERSION}.arm64" else SOURCES_FILE="${PROFILES_DIR}/sources.list" fi echo "SOURCES_FILE is set to ${SOURCES_FILE}" shift # past argument shift # past value ;; -h | --help) help_msg exit Loading @@ -455,7 +474,9 @@ while [[ $# -gt 0 ]]; do fi PROFILES_DIR="$2" SOURCES_FILE="${PROFILES_DIR}/sources.list" if [[ -f "${SOURCES_FILE}" ]];then SOURCES_FILE=${SOURCES_FILE} fi shift # past argument shift # past value ;; Loading scripts/patches/syscall_intercept.patch.arm64 0 → 100644 +148 −0 Original line number Diff line number Diff line From dc462223c52f97e94464eb597e1af9ab961aa781 Mon Sep 17 00:00:00 2001 From: sktzwhj <whj_nudt@foxmail.com> Date: Thu, 24 Feb 2022 17:34:40 +0800 Subject: [PATCH] changes for gekkofs --- CMakeLists.txt | 16 +++--- .../include/libsyscall_intercept_hook_point.h | 17 ++++++- arch/aarch64/src/intercept.c | 50 ++++++++++++++++--- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13fcdb9..11b621a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,14 +220,14 @@ install(TARGETS syscall_intercept_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -if (NOT SUBMOUDLE_BUILD) - install(TARGETS syscall_intercept_static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - add_subdirectory(doc) -endif() +# if (NOT SUBMOUDLE_BUILD) +# install(TARGETS syscall_intercept_static +# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +# add_subdirectory(doc) +# endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" diff --git a/arch/aarch64/include/libsyscall_intercept_hook_point.h b/arch/aarch64/include/libsyscall_intercept_hook_point.h index 2fe7d57..46f7eff 100644 --- a/arch/aarch64/include/libsyscall_intercept_hook_point.h +++ b/arch/aarch64/include/libsyscall_intercept_hook_point.h @@ -57,8 +57,21 @@ extern int (*intercept_hook_point)(long syscall_number, long arg4, long arg5, long *result); -extern void (*intercept_hook_point_clone_child)(void); -extern void (*intercept_hook_point_clone_parent)(long pid); + +extern void (*intercept_hook_point_clone_child)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, long newtls); + +extern void (*intercept_hook_point_clone_parent)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, long newtls, + long returned_pid); + +extern void (*intercept_hook_point_post_kernel)(long syscall_number, + long arg0, long arg1, + long arg2, long arg3, + long arg4, long arg5, + long result); /* * syscall_no_intercept - syscall without interception diff --git a/arch/aarch64/src/intercept.c b/arch/aarch64/src/intercept.c index a15aa97..72e4b7a 100644 --- a/arch/aarch64/src/intercept.c +++ b/arch/aarch64/src/intercept.c @@ -68,11 +68,24 @@ int (*intercept_hook_point)(long syscall_number, long *result) __attribute__((visibility("default"))); -void (*intercept_hook_point_clone_child)(void) - __attribute__((visibility("default"))); -void (*intercept_hook_point_clone_parent)(long) - __attribute__((visibility("default"))); - +void (*intercept_hook_point_clone_child)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, + long newtls) +__attribute__((visibility("default"))); + +void (*intercept_hook_point_clone_parent)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, + long newtls, long returned_pid) +__attribute__((visibility("default"))); + +void (*intercept_hook_point_post_kernel)(long syscall_number, + long arg0, long arg1, + long arg2, long arg3, + long arg4, long arg5, + long result) +__attribute__((visibility("default"))); bool debug_dumps_on; void @@ -630,7 +643,15 @@ intercept_routine(struct context *context) if (handle_magic_syscalls(&desc, &result) == 0) return (struct wrapper_ret){.x0 = result, .x1 = 1 }; - + if (intercept_hook_point_post_kernel != NULL) + intercept_hook_point_post_kernel(desc.nr, + desc.args[0], + desc.args[1], + desc.args[2], + desc.args[3], + desc.args[4], + desc.args[5], + result); intercept_log_syscall(patch, &desc, UNKNOWN, 0); if (intercept_hook_point != NULL) @@ -693,12 +714,25 @@ intercept_routine(struct context *context) struct wrapper_ret intercept_routine_post_clone(struct context *context) { + struct syscall_desc desc; + get_syscall_in_context(context, &desc); if (context->x0 == 0) { if (intercept_hook_point_clone_child != NULL) - intercept_hook_point_clone_child(); + intercept_hook_point_clone_child( + (unsigned long)desc.args[0], + (void *)desc.args[1], + (int *)desc.args[2], + (int *)desc.args[3], + desc.args[4]); } else { if (intercept_hook_point_clone_parent != NULL) - intercept_hook_point_clone_parent(context->x0); + intercept_hook_point_clone_parent( + (unsigned long)desc.args[0], + (void *)desc.args[1], + (int *)desc.args[2], + (int *)desc.args[3], + desc.args[4], + context->x0); } return (struct wrapper_ret){.x0 = context->x0, .x1 = 1 }; -- 2.17.1 scripts/profiles/0.9.0/agios.specs +2 −2 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ["agios"]="c26a6544200f823ebb8f890dd94e653d148bf226@development" ) Loading @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( ["syscall_intercept"]="syscall_intercept.patch" ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading Loading Loading
include/client/preload_context.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public: is_internal_fd(int fd) const; void protect_user_fds(); protect_user_fds(int root_fd); void unprotect_user_fds(); Loading
scripts/compile_dep.sh +14 −0 Original line number Diff line number Diff line Loading @@ -471,6 +471,20 @@ while [[ $# -gt 0 ]]; do help_msg exit ;; -a | --arch) ARCH=$2 echo "System arch is $ARCH" if [[ "$ARCH" == "arm64" ]];then SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" PROFILE_VERSION="${DEFAULT_VERSION}.arm64" else SOURCES_FILE="${PROFILES_DIR}/sources.list" fi echo "SOURCES_FILE is set to ${SOURCES_FILE}" shift # past argument shift # past value ;; -n | --dry-run) DRY_RUN=true shift Loading
scripts/dl_dep.sh +24 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ COMMON_CURL_FLAGS="--silent --fail --show-error --location -O" COMMON_GIT_FLAGS="--quiet --single-branch -c advice.detachedHead=false" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PATCH_DIR="${SCRIPT_DIR}/patches" ARCH="" DEPENDENCY="" EXECUTION_MODE= Loading @@ -42,7 +43,9 @@ DEFAULT_VERSION="latest" PROFILE_NAME=${DEFAULT_PROFILE} PROFILE_VERSION=${DEFAULT_VERSION} PROFILES_DIR="${SCRIPT_DIR}/profiles" SOURCES_FILE="${PROFILES_DIR}/sources.list" SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" declare -a PROFILE_DEP_LIST declare -A PROFILE_DEP_NAMES declare -A PROFILE_WGETDEPS PROFILE_CLONEDEPS PROFILE_SOURCES Loading Loading @@ -174,7 +177,7 @@ load_profile() { PROFILE_WGETDEPS=() local filename="${PROFILES_DIR}/${version}/${profile}.specs" echo "filename is $filename" if [[ ! -f "${filename}" ]]; then echo "Profile '${profile}:${version}' does not exist." exit 1 Loading Loading @@ -307,6 +310,7 @@ usage_short() { usage: dl_dep.sh -p PROFILE_NAME[:PROFILE_VERSION] | -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | -l [[PROFILE_NAME:]PROFILE_VERSION] | -a [ARCH] | -h [ -P PROFILES_DIR ] [ -n ] DESTINATION_PATH Loading Loading @@ -345,6 +349,7 @@ optional arguments: Choose the directory to be used when searching for profiles. If unspecified, PROFILES_DIR defaults to \${PWD}/profiles. -n, --dry-run Do not actually run, print only what would be done. -a, --arch The arch of the target host. -v, --verbose Increase download verbosity " } Loading Loading @@ -439,6 +444,20 @@ while [[ $# -gt 0 ]]; do exit ;; -a | --arch) ARCH=$2 echo "System arch is $ARCH" if [[ "$ARCH" == "arm64" ]];then SOURCES_FILE="${PROFILES_DIR}/sources.list.arm64" PROFILE_VERSION="${DEFAULT_VERSION}.arm64" else SOURCES_FILE="${PROFILES_DIR}/sources.list" fi echo "SOURCES_FILE is set to ${SOURCES_FILE}" shift # past argument shift # past value ;; -h | --help) help_msg exit Loading @@ -455,7 +474,9 @@ while [[ $# -gt 0 ]]; do fi PROFILES_DIR="$2" SOURCES_FILE="${PROFILES_DIR}/sources.list" if [[ -f "${SOURCES_FILE}" ]];then SOURCES_FILE=${SOURCES_FILE} fi shift # past argument shift # past value ;; Loading
scripts/patches/syscall_intercept.patch.arm64 0 → 100644 +148 −0 Original line number Diff line number Diff line From dc462223c52f97e94464eb597e1af9ab961aa781 Mon Sep 17 00:00:00 2001 From: sktzwhj <whj_nudt@foxmail.com> Date: Thu, 24 Feb 2022 17:34:40 +0800 Subject: [PATCH] changes for gekkofs --- CMakeLists.txt | 16 +++--- .../include/libsyscall_intercept_hook_point.h | 17 ++++++- arch/aarch64/src/intercept.c | 50 ++++++++++++++++--- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13fcdb9..11b621a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,14 +220,14 @@ install(TARGETS syscall_intercept_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -if (NOT SUBMOUDLE_BUILD) - install(TARGETS syscall_intercept_static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - add_subdirectory(doc) -endif() +# if (NOT SUBMOUDLE_BUILD) +# install(TARGETS syscall_intercept_static +# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# install(PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsyscall_intercept.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +# add_subdirectory(doc) +# endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" diff --git a/arch/aarch64/include/libsyscall_intercept_hook_point.h b/arch/aarch64/include/libsyscall_intercept_hook_point.h index 2fe7d57..46f7eff 100644 --- a/arch/aarch64/include/libsyscall_intercept_hook_point.h +++ b/arch/aarch64/include/libsyscall_intercept_hook_point.h @@ -57,8 +57,21 @@ extern int (*intercept_hook_point)(long syscall_number, long arg4, long arg5, long *result); -extern void (*intercept_hook_point_clone_child)(void); -extern void (*intercept_hook_point_clone_parent)(long pid); + +extern void (*intercept_hook_point_clone_child)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, long newtls); + +extern void (*intercept_hook_point_clone_parent)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, long newtls, + long returned_pid); + +extern void (*intercept_hook_point_post_kernel)(long syscall_number, + long arg0, long arg1, + long arg2, long arg3, + long arg4, long arg5, + long result); /* * syscall_no_intercept - syscall without interception diff --git a/arch/aarch64/src/intercept.c b/arch/aarch64/src/intercept.c index a15aa97..72e4b7a 100644 --- a/arch/aarch64/src/intercept.c +++ b/arch/aarch64/src/intercept.c @@ -68,11 +68,24 @@ int (*intercept_hook_point)(long syscall_number, long *result) __attribute__((visibility("default"))); -void (*intercept_hook_point_clone_child)(void) - __attribute__((visibility("default"))); -void (*intercept_hook_point_clone_parent)(long) - __attribute__((visibility("default"))); - +void (*intercept_hook_point_clone_child)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, + long newtls) +__attribute__((visibility("default"))); + +void (*intercept_hook_point_clone_parent)( + unsigned long flags, void *child_stack, + int *ptid, int *ctid, + long newtls, long returned_pid) +__attribute__((visibility("default"))); + +void (*intercept_hook_point_post_kernel)(long syscall_number, + long arg0, long arg1, + long arg2, long arg3, + long arg4, long arg5, + long result) +__attribute__((visibility("default"))); bool debug_dumps_on; void @@ -630,7 +643,15 @@ intercept_routine(struct context *context) if (handle_magic_syscalls(&desc, &result) == 0) return (struct wrapper_ret){.x0 = result, .x1 = 1 }; - + if (intercept_hook_point_post_kernel != NULL) + intercept_hook_point_post_kernel(desc.nr, + desc.args[0], + desc.args[1], + desc.args[2], + desc.args[3], + desc.args[4], + desc.args[5], + result); intercept_log_syscall(patch, &desc, UNKNOWN, 0); if (intercept_hook_point != NULL) @@ -693,12 +714,25 @@ intercept_routine(struct context *context) struct wrapper_ret intercept_routine_post_clone(struct context *context) { + struct syscall_desc desc; + get_syscall_in_context(context, &desc); if (context->x0 == 0) { if (intercept_hook_point_clone_child != NULL) - intercept_hook_point_clone_child(); + intercept_hook_point_clone_child( + (unsigned long)desc.args[0], + (void *)desc.args[1], + (int *)desc.args[2], + (int *)desc.args[3], + desc.args[4]); } else { if (intercept_hook_point_clone_parent != NULL) - intercept_hook_point_clone_parent(context->x0); + intercept_hook_point_clone_parent( + (unsigned long)desc.args[0], + (void *)desc.args[1], + (int *)desc.args[2], + (int *)desc.args[3], + desc.args[4], + context->x0); } return (struct wrapper_ret){.x0 = context->x0, .x1 = 1 }; -- 2.17.1
scripts/profiles/0.9.0/agios.specs +2 −2 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ["agios"]="c26a6544200f823ebb8f890dd94e653d148bf226@development" ) Loading @@ -61,7 +61,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( ["syscall_intercept"]="syscall_intercept.patch" ["syscall_intercept"]="syscall_intercept.patch.arm64" ) # Ordering that MUST be followed when downloading Loading