From 278e5d6d0c3fdc2e216c6bea1b16c458b3540c87 Mon Sep 17 00:00:00 2001 From: sktzwhj Date: Mon, 28 Feb 2022 09:52:19 +0800 Subject: [PATCH 1/2] add arm64-support prototype --- include/client/preload_context.hpp | 2 +- scripts/compile_dep.sh | 14 ++ scripts/dl_dep.sh | 27 +++- scripts/patches/syscall_intercept.patch.arm64 | 148 ++++++++++++++++++ scripts/profiles/0.9.0/agios.specs | 4 +- scripts/profiles/0.9.0/ci.specs | 4 +- scripts/profiles/0.9.0/default.specs | 4 +- scripts/profiles/0.9.0/direct.specs | 4 +- scripts/profiles/0.9.0/infiniband_verbs.specs | 4 +- .../profiles/0.9.0/install/rocksdb.install | 2 +- .../0.9.0/install/syscall_intercept.install | 6 +- scripts/profiles/0.9.0/marenostrum4.specs | 4 +- scripts/profiles/0.9.0/mogon2.specs | 4 +- scripts/profiles/0.9.0/ngio.specs | 4 +- scripts/profiles/0.9.0/omnipath_psm2.specs | 4 +- scripts/profiles/latest.arm64 | 1 + scripts/profiles/sources.list.arm64 | 75 +++++++++ src/client/CMakeLists.txt | 9 +- src/client/hooks.cpp | 25 ++- src/client/intercept.cpp | 90 +++++++++-- src/client/preload.cpp | 4 +- src/client/preload_context.cpp | 4 +- src/daemon/CMakeLists.txt | 1 + 23 files changed, 402 insertions(+), 42 deletions(-) create mode 100644 scripts/patches/syscall_intercept.patch.arm64 create mode 120000 scripts/profiles/latest.arm64 create mode 100644 scripts/profiles/sources.list.arm64 diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index bfdaacadf..5b78d9eeb 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -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(); diff --git a/scripts/compile_dep.sh b/scripts/compile_dep.sh index fe76c7063..0e872e92c 100755 --- a/scripts/compile_dep.sh +++ b/scripts/compile_dep.sh @@ -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 diff --git a/scripts/dl_dep.sh b/scripts/dl_dep.sh index 5cba6d0ca..00412d745 100755 --- a/scripts/dl_dep.sh +++ b/scripts/dl_dep.sh @@ -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= @@ -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 @@ -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 @@ -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 @@ -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 " } @@ -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 @@ -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 ;; diff --git a/scripts/patches/syscall_intercept.patch.arm64 b/scripts/patches/syscall_intercept.patch.arm64 new file mode 100644 index 000000000..72fd06e6c --- /dev/null +++ b/scripts/patches/syscall_intercept.patch.arm64 @@ -0,0 +1,148 @@ +From dc462223c52f97e94464eb597e1af9ab961aa781 Mon Sep 17 00:00:00 2001 +From: sktzwhj +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 + diff --git a/scripts/profiles/0.9.0/agios.specs b/scripts/profiles/0.9.0/agios.specs index 066cf7cb1..4f7b267bb 100644 --- a/scripts/profiles/0.9.0/agios.specs +++ b/scripts/profiles/0.9.0/agios.specs @@ -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" ) @@ -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 diff --git a/scripts/profiles/0.9.0/ci.specs b/scripts/profiles/0.9.0/ci.specs index 261f1e21f..1eab6190d 100644 --- a/scripts/profiles/0.9.0/ci.specs +++ b/scripts/profiles/0.9.0/ci.specs @@ -46,7 +46,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" ) @@ -58,7 +58,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 diff --git a/scripts/profiles/0.9.0/default.specs b/scripts/profiles/0.9.0/default.specs index 4c893a36a..25f1b8676 100644 --- a/scripts/profiles/0.9.0/default.specs +++ b/scripts/profiles/0.9.0/default.specs @@ -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" ) @@ -60,7 +60,7 @@ clonedeps_args=( # Patches that should be applied post-clone clonedeps_patches=( - ["syscall_intercept"]="syscall_intercept.patch" + ["syscall_intercept"]="syscall_intercept.64" ) # Ordering that MUST be followed when downloading diff --git a/scripts/profiles/0.9.0/direct.specs b/scripts/profiles/0.9.0/direct.specs index c65f528f7..53daf211c 100644 --- a/scripts/profiles/0.9.0/direct.specs +++ b/scripts/profiles/0.9.0/direct.specs @@ -46,7 +46,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ) # Extra arguments for git clone @@ -56,7 +56,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 diff --git a/scripts/profiles/0.9.0/infiniband_verbs.specs b/scripts/profiles/0.9.0/infiniband_verbs.specs index e7215869f..1fcfede99 100644 --- a/scripts/profiles/0.9.0/infiniband_verbs.specs +++ b/scripts/profiles/0.9.0/infiniband_verbs.specs @@ -49,7 +49,7 @@ clonedeps=( ["libfabric%verbs"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -60,7 +60,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/installing diff --git a/scripts/profiles/0.9.0/install/rocksdb.install b/scripts/profiles/0.9.0/install/rocksdb.install index 9350e9feb..bf03e109f 100644 --- a/scripts/profiles/0.9.0/install/rocksdb.install +++ b/scripts/profiles/0.9.0/install/rocksdb.install @@ -61,7 +61,7 @@ pkg_install() { -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" \ -DCMAKE_INSTALL_LIBDIR="${INSTALL_DIR}/lib" \ -DCMAKE_INSTALL_INCLUDEDIR="${INSTALL_DIR}/include" \ - -DROCKSDB_BUILD_SHARED=OFF \ + -DROCKSDB_BUILD_SHARED=ON \ -DWITH_LZ4=ON \ -DWITH_GFLAGS=OFF \ -DUSE_RTTI=1 \ diff --git a/scripts/profiles/0.9.0/install/syscall_intercept.install b/scripts/profiles/0.9.0/install/syscall_intercept.install index 9dd287271..ea82b944c 100644 --- a/scripts/profiles/0.9.0/install/syscall_intercept.install +++ b/scripts/profiles/0.9.0/install/syscall_intercept.install @@ -45,9 +45,13 @@ pkg_install() { ID="syscall_intercept" + echo "aarch64 install" CURR="${SOURCE_DIR}/${ID}" prepare_build_dir "${CURR}" - cd "${CURR}"/build + cd "${CURR}"/arch/aarch64/ + mkdir -p build + cd build + echo $PWD $CMAKE -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_BUILD_TYPE:STRING=Debug \ diff --git a/scripts/profiles/0.9.0/marenostrum4.specs b/scripts/profiles/0.9.0/marenostrum4.specs index 2f64676f6..170c411a9 100644 --- a/scripts/profiles/0.9.0/marenostrum4.specs +++ b/scripts/profiles/0.9.0/marenostrum4.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -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 diff --git a/scripts/profiles/0.9.0/mogon2.specs b/scripts/profiles/0.9.0/mogon2.specs index ee6c1d0a2..3e5e8860b 100644 --- a/scripts/profiles/0.9.0/mogon2.specs +++ b/scripts/profiles/0.9.0/mogon2.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -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 diff --git a/scripts/profiles/0.9.0/ngio.specs b/scripts/profiles/0.9.0/ngio.specs index ae633e44d..cebf7b8bc 100644 --- a/scripts/profiles/0.9.0/ngio.specs +++ b/scripts/profiles/0.9.0/ngio.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -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 diff --git a/scripts/profiles/0.9.0/omnipath_psm2.specs b/scripts/profiles/0.9.0/omnipath_psm2.specs index 779c3dadd..aa475d32e 100644 --- a/scripts/profiles/0.9.0/omnipath_psm2.specs +++ b/scripts/profiles/0.9.0/omnipath_psm2.specs @@ -50,7 +50,7 @@ clonedeps=( ["libfabric"]="HEAD@v1.13.2" ["mercury"]="v2.1.0" ["margo"]="v0.9.6" - ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d" + ["syscall_intercept"]="66a47ceb1c5c05e1d613ab3f1f7164f42d5aca6f" ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155" ) @@ -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 diff --git a/scripts/profiles/latest.arm64 b/scripts/profiles/latest.arm64 new file mode 120000 index 000000000..899f24fc7 --- /dev/null +++ b/scripts/profiles/latest.arm64 @@ -0,0 +1 @@ +0.9.0 \ No newline at end of file diff --git a/scripts/profiles/sources.list.arm64 b/scripts/profiles/sources.list.arm64 new file mode 100644 index 000000000..551fd1cdc --- /dev/null +++ b/scripts/profiles/sources.list.arm64 @@ -0,0 +1,75 @@ +################################################################################ +# Copyright 2018-2022, Barcelona Supercomputing Center (BSC), Spain # +# Copyright 2015-2022, Johannes Gutenberg Universitaet Mainz, Germany # +# # +# This software was partially supported by the # +# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). # +# # +# This software was partially supported by the # +# ADA-FS project under the SPPEXA project funded by the DFG. # +# # +# This file is part of GekkoFS. # +# # +# GekkoFS is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# GekkoFS is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with GekkoFS. If not, see . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +# vi: ft=bash + +declare -A sources + +sources=( + ["bzip2"]="https://sourceforge.net/projects/bzip2/files/bzip2-{{VERSION}}.tar.gz" + ["zstd"]="https://github.com/facebook/zstd/archive/v{{VERSION}}.tar.gz" + ["lz4"]="https://github.com/lz4/lz4/archive/v{{VERSION}}.tar.gz" + ["snappy"]="https://github.com/google/snappy/archive/{{VERSION}}.tar.gz" + ["capstone"]="https://github.com/aquynh/capstone/archive/{{VERSION}}.tar.gz" + ["argobots"]="https://github.com/pmodels/argobots/archive/v{{VERSION}}.tar.gz" + ["rocksdb"]="https://github.com/facebook/rocksdb/archive/v{{VERSION}}.tar.gz" + ["rocksdb%experimental"]="https://github.com/facebook/rocksdb/archive/v{{VERSION}}.tar.gz" + ["psm2"]="https://github.com/intel/opa-psm2/archive/PSM2_{{VERSION}}.tar.gz" + ["bmi"]="https://github.com/radix-io/bmi/" + ["libfabric"]="https://github.com/ofiwg/libfabric.git" + ["libfabric%experimental"]="https://github.com/ofiwg/libfabric.git" + ["libfabric%verbs"]="https://github.com/ofiwg/libfabric.git" + ["mercury"]="https://github.com/mercury-hpc/mercury" + ["margo"]="https://github.com/mochi-hpc/mochi-margo" + ["syscall_intercept"]="https://github.com/RIKEN-SysSoft/syscall_intercept.git" + ["date"]="https://github.com/HowardHinnant/date.git" + ["agios"]="https://github.com/francielizanon/agios.git" + ["json-c"]="https://github.com/json-c/json-c/archive/json-c-{{VERSION}}.tar.gz" +) + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 681c264f1..f017bc5a2 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -26,6 +26,13 @@ # # # SPDX-License-Identifier: LGPL-3.0-or-later # ################################################################################ + +set(syscall_info_file "") +if(x86_64) +set(syscall_info_file "MAKE_CURRENT_LIST_DIR}/syscalls/detail/syscall_info.c") +endif() + + set(PRELOAD_SOURCES PRIVATE ${CMAKE_CURRENT_LIST_DIR}/gkfs_functions.cpp @@ -43,7 +50,7 @@ set(PRELOAD_SOURCES ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_data.cpp ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_management.cpp ${CMAKE_CURRENT_LIST_DIR}/rpc/forward_metadata.cpp - ${CMAKE_CURRENT_LIST_DIR}/syscalls/detail/syscall_info.c + ${syscall_info_file} PUBLIC ${INCLUDE_DIR}/client/gkfs_functions.hpp ${INCLUDE_DIR}/config.hpp diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index d58302373..893c88ea1 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -71,6 +71,7 @@ syscall_no_intercept_wrapper(long syscall_number, Args... args) { namespace gkfs::hook { +#if defined x86_64 || defined ARM64 int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { @@ -98,7 +99,9 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { return -EINVAL; } } +#endif +#if defined x86_64 || defined ARM64 int hook_close(int fd) { @@ -118,7 +121,9 @@ hook_close(int fd) { return syscall_no_intercept_wrapper(SYS_close, fd); } +#endif +#if defined x86_64 int hook_stat(const char* path, struct stat* buf) { @@ -132,8 +137,10 @@ hook_stat(const char* path, struct stat* buf) { return syscall_no_intercept_wrapper(SYS_stat, rel_path.c_str(), buf); } +#endif #ifdef STATX_TYPE +#if defined x86_64 || defined ARM64 int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, @@ -169,8 +176,10 @@ hook_statx(int dirfd, const char* path, int flags, unsigned int mask, return syscall_no_intercept(SYS_statx, dirfd, path, flags, mask, buf); } +#endif #endif +#if defined x86_64 int hook_lstat(const char* path, struct stat* buf) { @@ -184,7 +193,9 @@ hook_lstat(const char* path, struct stat* buf) { return syscall_no_intercept_wrapper(SYS_lstat, rel_path.c_str(), buf); ; } +#endif +#if defined x86_64 || defined ARM64 int hook_fstat(unsigned int fd, struct stat* buf) { @@ -408,8 +419,9 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) { return -EINVAL; } } +#endif - +#if defined x86_64 int hook_access(const char* path, int mask) { @@ -425,7 +437,9 @@ hook_access(const char* path, int mask) { } return syscall_no_intercept_wrapper(SYS_access, rel_path.c_str(), mask); } +#endif +#if defined x86_64 || defined ARM64 int hook_faccessat(int dirfd, const char* cpath, int mode) { @@ -509,7 +523,9 @@ hook_dup(unsigned int fd) { } return syscall_no_intercept_wrapper(SYS_dup, fd); } +#endif +#if defined x86_64 int hook_dup2(unsigned int oldfd, unsigned int newfd) { @@ -520,7 +536,9 @@ hook_dup2(unsigned int oldfd, unsigned int newfd) { } return syscall_no_intercept_wrapper(SYS_dup2, oldfd, newfd); } +#endif +#if defined x86_64 || defined ARM64 int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags) { @@ -535,7 +553,9 @@ hook_dup3(unsigned int oldfd, unsigned int newfd, int flags) { } return syscall_no_intercept_wrapper(SYS_dup3, oldfd, newfd, flags); } +#endif +#if defined x86_64 int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { @@ -547,8 +567,10 @@ hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { } return syscall_no_intercept_wrapper(SYS_getdents, fd, dirp, count); } +#endif +#if defined x86_64 || defined ARM64 int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count) { @@ -920,5 +942,6 @@ hook_fsync(unsigned int fd) { return syscall_no_intercept_wrapper(SYS_fsync, fd); } +#endif } // namespace gkfs::hook diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index a403ddd05..1893d8a9d 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -92,7 +92,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, syscall_number, args); switch(syscall_number) { - + #if defined x86_64 case SYS_open: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -120,7 +120,8 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - + #endif + #if defined x86_64 || defined ARM64 case SYS_openat: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -134,7 +135,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = -syserror; } break; - + #if defined x86_64 case SYS_epoll_create: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -147,6 +148,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif case SYS_epoll_create1: *result = syscall_no_intercept(syscall_number, @@ -171,7 +173,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + #if defined x86_64 case SYS_dup2: *result = syscall_no_intercept(syscall_number, static_cast(arg0), @@ -183,7 +187,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + #if defined x86_64 || defined ARM64 case SYS_dup3: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -198,7 +204,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + #if defined x86_64 case SYS_inotify_init: *result = syscall_no_intercept(syscall_number); @@ -207,7 +215,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + #if defined x86_64 || defined ARM64 case SYS_inotify_init1: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -229,7 +239,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; + #endif + #if defined x86_64 case SYS_signalfd: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -239,7 +251,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; + #endif + #if defined x86_64 || defined ARM64 case SYS_signalfd4: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -287,7 +301,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + #if defined x86_64 case SYS_pipe: *result = syscall_no_intercept(syscall_number, reinterpret_cast(arg0)); @@ -300,7 +316,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + + #if defined x86_64 || defined ARM64 case SYS_pipe2: *result = syscall_no_intercept(syscall_number, @@ -314,6 +333,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; + #endif + + #if defined x86_64 case SYS_eventfd: @@ -324,7 +346,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; + #endif + + #if defined x86_64 || defined ARM64 case SYS_eventfd2: *result = @@ -412,6 +437,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, CTX->unregister_internal_fd(arg0); } break; + #endif default: // ignore any other syscalls, i.e.: pass them on to the kernel @@ -452,6 +478,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, switch(syscall_number) { + #if defined x86_64 || defined ARM64 case SYS_execve: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -466,8 +493,9 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg2), reinterpret_cast(arg3), arg4); break; + #endif #endif - + #if defined x86_64 case SYS_open: *result = gkfs::hook::hook_openat( AT_FDCWD, reinterpret_cast(arg0), @@ -479,7 +507,10 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, AT_FDCWD, reinterpret_cast(arg0), O_WRONLY | O_CREAT | O_TRUNC, static_cast(arg1)); break; + #endif + + #if defined x86_64 || defined ARM64 case SYS_openat: *result = gkfs::hook::hook_openat( static_cast(arg0), reinterpret_cast(arg1), @@ -490,12 +521,13 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_close(static_cast(arg0)); break; + #if defined x86_64 case SYS_stat: *result = gkfs::hook::hook_stat(reinterpret_cast(arg0), reinterpret_cast(arg1)); break; - + #endif #ifdef STATX_TYPE case SYS_statx: *result = gkfs::hook::hook_statx( @@ -503,14 +535,18 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg2), static_cast(arg3), reinterpret_cast(arg4)); break; + #endif #endif + #if defined x86_64 case SYS_lstat: *result = gkfs::hook::hook_lstat( reinterpret_cast(arg0), reinterpret_cast(arg1)); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_fstat: *result = gkfs::hook::hook_fstat( static_cast(arg0), @@ -582,16 +618,23 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg4)); break; + #endif + + #if defined x86_64 case SYS_unlink: *result = gkfs::hook::hook_unlinkat( AT_FDCWD, reinterpret_cast(arg0), 0); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_unlinkat: *result = gkfs::hook::hook_unlinkat( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; + #endif + #if defined x86_64 case SYS_rmdir: *result = gkfs::hook::hook_unlinkat( @@ -604,19 +647,26 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1)); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_symlinkat: *result = gkfs::hook::hook_symlinkat( reinterpret_cast(arg0), static_cast(arg1), reinterpret_cast(arg2)); break; + #endif + + #if defined x86_64 case SYS_access: *result = gkfs::hook::hook_access(reinterpret_cast(arg0), static_cast(arg1)); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_faccessat: *result = gkfs::hook::hook_faccessat( static_cast(arg0), reinterpret_cast(arg1), @@ -644,25 +694,33 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_dup: *result = gkfs::hook::hook_dup(static_cast(arg0)); break; + #endif + #if defined x86_64 case SYS_dup2: *result = gkfs::hook::hook_dup2(static_cast(arg0), static_cast(arg1)); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_dup3: *result = gkfs::hook::hook_dup3(static_cast(arg0), static_cast(arg1), static_cast(arg2)); - break; + break; + #endif + #if defined x86_64 case SYS_getdents: *result = gkfs::hook::hook_getdents( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; + #endif + #if defined x86_64 || defined ARM64 case SYS_getdents64: *result = gkfs::hook::hook_getdents64( static_cast(arg0), @@ -676,7 +734,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg1), static_cast(arg2)); break; - + #endif + #if defined x86_64 case SYS_mkdir: *result = gkfs::hook::hook_mkdirat( AT_FDCWD, reinterpret_cast(arg0), @@ -688,7 +747,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), static_cast(arg1)); break; - + #endif + #if defined x86_64 || defined ARM64 case SYS_fchmod: *result = gkfs::hook::hook_fchmod(static_cast(arg0), static_cast(arg1)); @@ -713,13 +773,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_getcwd(reinterpret_cast(arg0), static_cast(arg1)); break; - + #endif + #if defined x86_64 case SYS_readlink: *result = gkfs::hook::hook_readlinkat( AT_FDCWD, reinterpret_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; - + #endif + #if defined x86_64 || defined ARM64 case SYS_readlinkat: *result = gkfs::hook::hook_readlinkat( static_cast(arg0), reinterpret_cast(arg1), @@ -731,13 +793,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg1), static_cast(arg2)); break; - + #endif + #if defined x86_64 case SYS_rename: *result = gkfs::hook::hook_renameat( AT_FDCWD, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1), 0); break; - + #endif + #if defined x86_64 || defined ARM64 case SYS_renameat: *result = gkfs::hook::hook_renameat( static_cast(arg0), reinterpret_cast(arg1), @@ -767,7 +831,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_fsync: *result = gkfs::hook::hook_fsync(static_cast(arg0)); break; - + #endif default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in diff --git a/src/client/preload.cpp b/src/client/preload.cpp index ba3a87870..46cd21f5c 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -26,6 +26,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later */ +#include #include #include @@ -261,6 +262,7 @@ init_preload() { // The original errno value will be restored after initialization to not // leak internal error codes auto oerrno = errno; + int root_fd = dirfd(opendir("/")); CTX->enable_interception(); gkfs::preload::start_self_interception(); @@ -277,7 +279,7 @@ init_preload() { // [MAX_USER_FDS, MAX_OPEN_FDS) range. To prevent this for our internal // initialization code, we forcefully occupy the user fd range to force // such modules to create fds in our private range. - CTX->protect_user_fds(); + CTX->protect_user_fds(root_fd); log_prog_name(); gkfs::path::init_cwd(); diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 9a1f9f27d..e16d7ba66 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -386,11 +386,11 @@ PreloadContext::is_internal_fd(int fd) const { } void -PreloadContext::protect_user_fds() { +PreloadContext::protect_user_fds(int root_fd) { LOG(DEBUG, "Protecting application fds [{}, {}]", 0, MAX_USER_FDS - 1); - const int nullfd = ::syscall_no_intercept(SYS_open, "/dev/null", O_RDONLY); + const int nullfd = ::syscall_no_intercept(SYS_openat, root_fd, "/dev/null", O_RDONLY); assert(::syscall_error_code(nullfd) == 0); protected_fds_.set(nullfd); diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e3703d73b..4f308da69 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -72,6 +72,7 @@ set(DAEMON_LINK_LIBRARIES # margo libs ${ABT_LIBRARIES} mercury + rocksdb ${MARGO_LIBRARIES} # others Threads::Threads -- GitLab From 12fa961ad0711c950f0cf4a52c55057873107da6 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 1 Mar 2022 10:25:20 +0800 Subject: [PATCH 2/2] formatting --- src/client/hooks.cpp | 8 +- src/client/intercept.cpp | 142 ++++++++++++++++----------------- src/client/preload_context.cpp | 3 +- 3 files changed, 77 insertions(+), 76 deletions(-) diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index 893c88ea1..460f28cc8 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -419,7 +419,7 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) { return -EINVAL; } } -#endif +#endif #if defined x86_64 int @@ -523,7 +523,7 @@ hook_dup(unsigned int fd) { } return syscall_no_intercept_wrapper(SYS_dup, fd); } -#endif +#endif #if defined x86_64 int @@ -553,7 +553,7 @@ hook_dup3(unsigned int oldfd, unsigned int newfd, int flags) { } return syscall_no_intercept_wrapper(SYS_dup3, oldfd, newfd, flags); } -#endif +#endif #if defined x86_64 int @@ -942,6 +942,6 @@ hook_fsync(unsigned int fd) { return syscall_no_intercept_wrapper(SYS_fsync, fd); } -#endif +#endif } // namespace gkfs::hook diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 1893d8a9d..ae59676b5 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -92,7 +92,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, syscall_number, args); switch(syscall_number) { - #if defined x86_64 +#if defined x86_64 case SYS_open: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -120,8 +120,8 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif - #if defined x86_64 || defined ARM64 +#endif +#if defined x86_64 || defined ARM64 case SYS_openat: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -135,7 +135,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = -syserror; } break; - #if defined x86_64 +#if defined x86_64 case SYS_epoll_create: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -148,7 +148,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif case SYS_epoll_create1: *result = syscall_no_intercept(syscall_number, @@ -173,9 +173,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_dup2: *result = syscall_no_intercept(syscall_number, static_cast(arg0), @@ -187,9 +187,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_dup3: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -204,9 +204,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_inotify_init: *result = syscall_no_intercept(syscall_number); @@ -215,9 +215,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_inotify_init1: *result = syscall_no_intercept(syscall_number, static_cast(arg0)); @@ -239,9 +239,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_signalfd: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -251,9 +251,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_signalfd4: *result = syscall_no_intercept( syscall_number, static_cast(arg0), @@ -301,9 +301,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_pipe: *result = syscall_no_intercept(syscall_number, reinterpret_cast(arg0)); @@ -316,10 +316,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_pipe2: *result = syscall_no_intercept(syscall_number, @@ -333,9 +333,9 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, } break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_eventfd: @@ -346,10 +346,10 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, *result = CTX->register_internal_fd(*result); } break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_eventfd2: *result = @@ -437,7 +437,7 @@ hook_internal(long syscall_number, long arg0, long arg1, long arg2, long arg3, CTX->unregister_internal_fd(arg0); } break; - #endif +#endif default: // ignore any other syscalls, i.e.: pass them on to the kernel @@ -478,7 +478,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, switch(syscall_number) { - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_execve: *result = syscall_no_intercept( syscall_number, reinterpret_cast(arg0), @@ -493,9 +493,9 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg2), reinterpret_cast(arg3), arg4); break; - #endif #endif - #if defined x86_64 +#endif +#if defined x86_64 case SYS_open: *result = gkfs::hook::hook_openat( AT_FDCWD, reinterpret_cast(arg0), @@ -507,10 +507,10 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, AT_FDCWD, reinterpret_cast(arg0), O_WRONLY | O_CREAT | O_TRUNC, static_cast(arg1)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_openat: *result = gkfs::hook::hook_openat( static_cast(arg0), reinterpret_cast(arg1), @@ -521,13 +521,13 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_close(static_cast(arg0)); break; - #if defined x86_64 +#if defined x86_64 case SYS_stat: *result = gkfs::hook::hook_stat(reinterpret_cast(arg0), reinterpret_cast(arg1)); break; - #endif +#endif #ifdef STATX_TYPE case SYS_statx: *result = gkfs::hook::hook_statx( @@ -535,18 +535,18 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg2), static_cast(arg3), reinterpret_cast(arg4)); break; - #endif +#endif #endif - #if defined x86_64 +#if defined x86_64 case SYS_lstat: *result = gkfs::hook::hook_lstat( reinterpret_cast(arg0), reinterpret_cast(arg1)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_fstat: *result = gkfs::hook::hook_fstat( static_cast(arg0), @@ -618,23 +618,23 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg4)); break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_unlink: *result = gkfs::hook::hook_unlinkat( AT_FDCWD, reinterpret_cast(arg0), 0); break; - #endif - #if defined x86_64 || defined ARM64 +#endif +#if defined x86_64 || defined ARM64 case SYS_unlinkat: *result = gkfs::hook::hook_unlinkat( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; - #endif - #if defined x86_64 +#endif +#if defined x86_64 case SYS_rmdir: *result = gkfs::hook::hook_unlinkat( @@ -647,26 +647,26 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_symlinkat: *result = gkfs::hook::hook_symlinkat( reinterpret_cast(arg0), static_cast(arg1), reinterpret_cast(arg2)); break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_access: *result = gkfs::hook::hook_access(reinterpret_cast(arg0), static_cast(arg1)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_faccessat: *result = gkfs::hook::hook_faccessat( static_cast(arg0), reinterpret_cast(arg1), @@ -694,33 +694,33 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_dup: *result = gkfs::hook::hook_dup(static_cast(arg0)); break; - #endif +#endif - #if defined x86_64 +#if defined x86_64 case SYS_dup2: *result = gkfs::hook::hook_dup2(static_cast(arg0), static_cast(arg1)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_dup3: *result = gkfs::hook::hook_dup3(static_cast(arg0), static_cast(arg1), static_cast(arg2)); - break; - #endif + break; +#endif - #if defined x86_64 +#if defined x86_64 case SYS_getdents: *result = gkfs::hook::hook_getdents( static_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; - #endif +#endif - #if defined x86_64 || defined ARM64 +#if defined x86_64 || defined ARM64 case SYS_getdents64: *result = gkfs::hook::hook_getdents64( static_cast(arg0), @@ -734,8 +734,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg1), static_cast(arg2)); break; - #endif - #if defined x86_64 +#endif +#if defined x86_64 case SYS_mkdir: *result = gkfs::hook::hook_mkdirat( AT_FDCWD, reinterpret_cast(arg0), @@ -747,8 +747,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, reinterpret_cast(arg0), static_cast(arg1)); break; - #endif - #if defined x86_64 || defined ARM64 +#endif +#if defined x86_64 || defined ARM64 case SYS_fchmod: *result = gkfs::hook::hook_fchmod(static_cast(arg0), static_cast(arg1)); @@ -773,15 +773,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = gkfs::hook::hook_getcwd(reinterpret_cast(arg0), static_cast(arg1)); break; - #endif - #if defined x86_64 +#endif +#if defined x86_64 case SYS_readlink: *result = gkfs::hook::hook_readlinkat( AT_FDCWD, reinterpret_cast(arg0), reinterpret_cast(arg1), static_cast(arg2)); break; - #endif - #if defined x86_64 || defined ARM64 +#endif +#if defined x86_64 || defined ARM64 case SYS_readlinkat: *result = gkfs::hook::hook_readlinkat( static_cast(arg0), reinterpret_cast(arg1), @@ -793,15 +793,15 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, static_cast(arg1), static_cast(arg2)); break; - #endif - #if defined x86_64 +#endif +#if defined x86_64 case SYS_rename: *result = gkfs::hook::hook_renameat( AT_FDCWD, reinterpret_cast(arg0), AT_FDCWD, reinterpret_cast(arg1), 0); break; - #endif - #if defined x86_64 || defined ARM64 +#endif +#if defined x86_64 || defined ARM64 case SYS_renameat: *result = gkfs::hook::hook_renameat( static_cast(arg0), reinterpret_cast(arg1), @@ -831,7 +831,7 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, case SYS_fsync: *result = gkfs::hook::hook_fsync(static_cast(arg0)); break; - #endif +#endif default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index e16d7ba66..17b6e3cfd 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -390,7 +390,8 @@ PreloadContext::protect_user_fds(int root_fd) { LOG(DEBUG, "Protecting application fds [{}, {}]", 0, MAX_USER_FDS - 1); - const int nullfd = ::syscall_no_intercept(SYS_openat, root_fd, "/dev/null", O_RDONLY); + const int nullfd = + ::syscall_no_intercept(SYS_openat, root_fd, "/dev/null", O_RDONLY); assert(::syscall_error_code(nullfd) == 0); protected_fds_.set(nullfd); -- GitLab