Code Monkey home page Code Monkey logo

syscall_intercept's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syscall_intercept's Issues

Unable to intercept `openat` syscall made by `dlopen`

I am trying to intercept all openat syscalls. This involves those made by dlopen when loading shared libraries in the program.

What I have noticed is that I am able to intercept openat if I explicitly call this function from my application. However, if I try to open a .so using dlopen which internally should still call openat (ref:) then it does not intercept and goes on to make the syscall as usual.

I inspected the disassembly and noticed that even though __open64_nocancel is being hotpatched and the syscall is replaced by jmp, this is done in the __open64_nocancel in libc.so. However, when I call dlopen, it ends up calling __open64_nocancel from ld-linux-x86-64.so.2 which does not seem to have the hotpatch.

Below is a screenshot showing the disassembly:
image

This is the screenshot of the hotpatched instance:
image

This is the screenshot showing these __open64_nocancel are in apparently two different .so files:
image

Is there any guess on why:
a) There are two instances of __open64_nocancel? ld.so is supposed to load these so not sure why these come up as duplicates.
b) Only one of the two instances was hotpatched?


Here is a sample application I am using:

#include <string>
#include <iostream>

#include <dlfcn.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int test_openat() {
        int fd = openat(AT_FDCWD, "/home/gochaudh/.local/lib/python3.10/site-packages/pandas/io/__pycache__/parquet.cpython-310.pyc", O_RDONLY|O_CLOEXEC);
        if (fd != -1) {
                std::cout << "Opened file at: " << fd << std::endl;
        } else {
                std::cerr << "Cannot open file" << std::endl;
                perror("openat");
                return -1;
        }

        int ret = close(fd);
        if (!ret) {
                std::cout << "File closed" << std::endl;
        } else {
                std::cerr << "Cannot close file" << std::endl;
                return -1;
        }

        return 0;
}

int test_dlopen() {
        const std::string lib_path("/home/gochaudh/functions_kernel/lib/python/3.10.0/lib/libpython3.10.so.1.0");

        void *lib = dlopen(lib_path.c_str(), RTLD_NOW);
        if (lib) {
                std::cout << "Library loaded at: " << lib << std::endl;
        } else {
                std::cerr << "Could not open library: " << dlerror() << std::endl;
                return -1;
        }

        int ret = dlclose(lib);
        if (!ret) {
                std::cout << "Library closed" << std::endl;
        } else {
                std::cerr << "Cannot close library" << std::endl;
                return -1;
        }

        return 0;
}

int main() {
        test_openat();
        test_dlopen();

        return 0;
}

Valgrind checks

The way valgrind does instrumentation seems to be conflicting with syscall_intercept's patching methods. This needs to be investigated -- probably it can be fixed.
Run existing tests under valgrind when it is possible.

Undefined reference when trying to make

Hi

I'm using cmake for syscall_intercept. Now, when I want to make, I get the following error:

[  0%] Built target gen_ctags
[  0%] Built target check_whitespace
[  2%] Built target cpp_test
[  2%] Built target cstyle
Scanning dependencies of target syscall_intercept_base_c
[  3%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/disasm_wrapper.c.o
[  4%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/intercept.c.o
[  4%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/intercept_desc.c.o
[  5%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/intercept_log.c.o
[  6%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/intercept_util.c.o
[  6%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/patcher.c.o
[  7%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/magic_syscalls.c.o
[  8%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/syscall_formats.c.o
[  8%] Built target syscall_intercept_base_c
Scanning dependencies of target syscall_intercept_base_clf
[  8%] Building C object CMakeFiles/syscall_intercept_base_clf.dir/src/cmdline_filter.c.o
[  8%] Built target syscall_intercept_base_clf
Scanning dependencies of target syscall_intercept_base_asm
[  8%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_template.S.o
[  9%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/util.S.o
[  9%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_wrapper.S.o
[  9%] Built target syscall_intercept_base_asm
Scanning dependencies of target syscall_intercept_unscoped
[ 10%] Linking C static library libsyscall_intercept_unscoped.a
[ 10%] Built target syscall_intercept_unscoped
Scanning dependencies of target generate_syscall_intercept_scoped
[ 11%] Generating syscall_intercept_unscoped.o
[ 12%] Generating syscall_intercept_scoped.o
[ 12%] Built target generate_syscall_intercept_scoped
Scanning dependencies of target syscall_intercept_shared
[ 12%] Linking C shared library libsyscall_intercept.so
[ 14%] Built target syscall_intercept_shared
Scanning dependencies of target syscall_intercept_static
[ 15%] Linking C static library libsyscall_intercept.a
[ 16%] Built target syscall_intercept_static
Scanning dependencies of target check_license_executable
[ 16%] Building C object CMakeFiles/check_license_executable.dir/utils/check_license/check-license.c.o
[ 17%] Linking C executable check_license_executable
[ 17%] Built target check_license_executable
Scanning dependencies of target syscall_logger
[ 17%] Building C object examples/CMakeFiles/syscall_logger.dir/syscall_logger.c.o
[ 18%] Building C object examples/CMakeFiles/syscall_logger.dir/syscall_desc.c.o
[ 19%] Linking C shared library libsyscall_logger.so
[ 19%] Built target syscall_logger
Scanning dependencies of target fork_ban
[ 19%] Building C object examples/CMakeFiles/fork_ban.dir/fork_ban.c.o
[ 20%] Linking C shared library libfork_ban.so
[ 20%] Built target fork_ban
Scanning dependencies of target icap
[ 21%] Building C object examples/CMakeFiles/icap.dir/icap.c.o
[ 21%] Linking C shared library libicap.so
[ 21%] Built target icap
Scanning dependencies of target vfork_logging
[ 22%] Building C object test/CMakeFiles/vfork_logging.dir/vfork_logging.c.o
[ 23%] Linking C executable vfork_logging
[ 23%] Built target vfork_logging
Scanning dependencies of target intercept_sys_write
[ 24%] Building C object test/CMakeFiles/intercept_sys_write.dir/intercept_sys_write.c.o
[ 25%] Linking C shared library libintercept_sys_write.so
[ 25%] Built target intercept_sys_write
Scanning dependencies of target test_clone_thread_preload
[ 26%] Building C object test/CMakeFiles/test_clone_thread_preload.dir/test_clone_thread_preload.c.o
[ 26%] Linking C shared library libtest_clone_thread_preload.so
[ 26%] Built target test_clone_thread_preload
Scanning dependencies of target test_clone_thread
[ 26%] Building C object test/CMakeFiles/test_clone_thread.dir/test_clone_thread.c.o
[ 27%] Linking C executable test_clone_thread
[ 27%] Built target test_clone_thread
Scanning dependencies of target filter_test
[ 27%] Building C object test/CMakeFiles/filter_test.dir/filter_test.c.o
[ 28%] Linking C executable filter_test
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_option'
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_free'
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_disasm_iter'
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_malloc'
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_open'
../libsyscall_intercept.so.0.1.0: undefined reference to `cs_close'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/filter_test] Error 1
make[1]: *** [test/CMakeFiles/filter_test.dir/all] Error 2
make: *** [all] Error 2

What does this "undefined reference" mean? And how can I solve the issue? Thanks

Add examples and/or tests involving signals.

Make sure the whole library is signal safe.
Add tests with some signal related syscalls, at least these two: SYS_rt_sigaction, SYS_rt_sigreturn.
Reevaluate the nr == SYS_rt_sigreturn special case in intercept.c.

make: build fails on fedora 23

Build fails on fedora 23:

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

HEAD is now at 570b638... Merge pull request #1 from GBuella/master

  • ./utils/build-rpm.sh
    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.FydfGT

  • umask 022

  • cd /root/rpmbuild/BUILD

  • cd /root/rpmbuild/BUILD

  • rm -rf syscall_intercept-0.1

  • /usr/bin/gzip -dc /syscall_intercept/syscall_intercept-0.1.tar.gz

  • /usr/bin/tar -xof -

  • STATUS=0

  • '[' 0 -ne 0 ']'

  • cd syscall_intercept-0.1

  • /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .

  • exit 0
    Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.IQmzBk

  • umask 022

  • cd /root/rpmbuild/BUILD

  • cd syscall_intercept-0.1

  • mkdir build

  • cd build

  • CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'

  • export CFLAGS

  • CXXFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'

  • export CXXFLAGS

  • FFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules'

  • export FFLAGS

  • FCFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules'

  • export FCFLAGS

  • LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'

  • export LDFLAGS

  • /usr/bin/cmake -DCMAKE_C_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_Fortran_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib64 -DSYSCONF_INSTALL_DIR:PATH=/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DLIB_SUFFIX=64 -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE=Release ..
    -- The C compiler identification is GNU 5.3.1
    -- The CXX compiler identification is GNU 5.3.1
    -- The ASM compiler identification is GNU
    -- Found assembler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found Perl: /usr/bin/perl (found version "5.22.2")
    -- Performing Test HAS_WERROR
    -- Performing Test HAS_WERROR - Success
    -- Performing Test HAS_WALL
    -- Performing Test HAS_WALL - Success
    -- Performing Test HAS_WEXTRA
    -- Performing Test HAS_WEXTRA - Success
    -- Performing Test HAS_PEDANTIC
    -- Performing Test HAS_PEDANTIC - Success
    -- Performing Test HAS_NOMFI
    -- Performing Test HAS_NOMFI - Success
    -- Performing Test HAS_NO9099
    -- Performing Test HAS_NO9099 - Success
    -- Performing Test LINKER_HAS_NOSTDLIB
    -- Performing Test LINKER_HAS_NOSTDLIB - Success
    -- Performing Test HAS_WLFATAL
    -- Performing Test HAS_WLFATAL - Success
    -- Performing Test HAS_NOUNUSEDARG
    -- Performing Test HAS_NOUNUSEDARG - Success
    -- Performing Test HAS_GCC_ATTR_CONSTR
    -- Performing Test HAS_GCC_ATTR_CONSTR - Success
    -- Performing Test HAS_GCC_PRAGMA_SYSH
    -- Performing Test HAS_GCC_PRAGMA_SYSH - Success
    -- Looking for include file elf.h
    -- Looking for include file elf.h - found
    -- Looking for dladdr
    -- Looking for dladdr - found
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    -- Configuring done
    -- Generating done
    CMake Warning:
    Manually-specified variables were not used by the project:

    CMAKE_Fortran_FLAGS_RELEASE
    INCLUDE_INSTALL_DIR
    LIB_INSTALL_DIR
    LIB_SUFFIX
    SHARE_INSTALL_PREFIX
    SYSCONF_INSTALL_DIR

-- Build files have been written to: /root/rpmbuild/BUILD/syscall_intercept-0.1/build

  • make -j8
    /usr/bin/cmake -H/root/rpmbuild/BUILD/syscall_intercept-0.1 -B/root/rpmbuild/BUILD/syscall_intercept-0.1/build --check-build-system CMakeFiles/Makefile.cmake 0
    /usr/bin/cmake -E cmake_progress_start /root/rpmbuild/BUILD/syscall_intercept-0.1/build/CMakeFiles /root/rpmbuild/BUILD/syscall_intercept-0.1/build/CMakeFiles/progress.marks
    make -f CMakeFiles/Makefile2 all
    make[1]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f CMakeFiles/check_license_executable.dir/build.make CMakeFiles/check_license_executable.dir/depend
    make -f CMakeFiles/cpp_test.dir/build.make CMakeFiles/cpp_test.dir/depend
    make -f CMakeFiles/syscall_intercept_base_asm.dir/build.make CMakeFiles/syscall_intercept_base_asm.dir/depend
    make -f test/CMakeFiles/hook_test.dir/build.make test/CMakeFiles/hook_test.dir/depend
    make -f test/CMakeFiles/logging_test.dir/build.make test/CMakeFiles/logging_test.dir/depend
    make -f test/CMakeFiles/nosyscall.in.dir/build.make test/CMakeFiles/nosyscall.in.dir/depend
    make -f test/CMakeFiles/nosyscall.out.dir/build.make test/CMakeFiles/nosyscall.out.dir/depend
    make -f test/CMakeFiles/pattern1.in.dir/build.make test/CMakeFiles/pattern1.in.dir/depend
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/CMakeFiles/check_license_executable.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/CMakeFiles/cpp_test.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/CMakeFiles/syscall_intercept_base_asm.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/hook_test.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/logging_test.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern1.in.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/nosyscall.in.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/nosyscall.out.dir/DependInfo.cmake --color=
    Scanning dependencies of target nosyscall.out
    Scanning dependencies of target nosyscall.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/nosyscall.out.dir/build.make test/CMakeFiles/nosyscall.out.dir/build
    Scanning dependencies of target check_license_executable
    Scanning dependencies of target cpp_test
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/nosyscall.in.dir/build.make test/CMakeFiles/nosyscall.in.dir/build
    Scanning dependencies of target syscall_intercept_base_asm
    Scanning dependencies of target pattern1.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f CMakeFiles/check_license_executable.dir/build.make CMakeFiles/check_license_executable.dir/build
    make -f CMakeFiles/cpp_test.dir/build.make CMakeFiles/cpp_test.dir/build
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f CMakeFiles/syscall_intercept_base_asm.dir/build.make CMakeFiles/syscall_intercept_base_asm.dir/build
    make -f test/CMakeFiles/pattern1.in.dir/build.make test/CMakeFiles/pattern1.in.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    Scanning dependencies of target logging_test
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/logging_test.dir/build.make test/CMakeFiles/logging_test.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    Scanning dependencies of target hook_test
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/hook_test.dir/build.make test/CMakeFiles/hook_test.dir/build
    [ 3%] Building ASM object test/CMakeFiles/nosyscall.in.dir/nosyscall.in.s.o
    [ 3%] Building ASM object test/CMakeFiles/pattern1.in.dir/pattern1.in.s.o
    [ 3%] Building ASM object test/CMakeFiles/nosyscall.out.dir/nosyscall.out.s.o
    [ 5%] Building C object CMakeFiles/check_license_executable.dir/utils/check_license/check-license.c.o
    [ 5%] Building CXX object CMakeFiles/cpp_test.dir/src/cpp_compile_test.cc.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dnosyscall_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/nosyscall.in.dir/nosyscall.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/nosyscall.in.s
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern1_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern1.in.dir/pattern1.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern1.in.s
    /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -fPIE -std=c99 -o CMakeFiles/check_license_executable.dir/utils/check_license/check-license.c.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/utils/check_license/check-license.c
    /usr/bin/c++ -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -DNDEBUG -fPIE -std=gnu++11 -o CMakeFiles/cpp_test.dir/src/cpp_compile_test.cc.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/src/cpp_compile_test.cc
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dnosyscall_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/nosyscall.out.dir/nosyscall.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/nosyscall.out.s
    [ 5%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_template.s.o
    /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_template.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/src/intercept_template.s
    [ 6%] Building C object test/CMakeFiles/logging_test.dir/logging_test.c.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -fPIE -std=c99 -o CMakeFiles/logging_test.dir/logging_test.c.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/logging_test.c
    [ 7%] Building C object test/CMakeFiles/hook_test.dir/hook_test.c.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -fPIE -std=c99 -o CMakeFiles/hook_test.dir/hook_test.c.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/hook_test.c
    [ 8%] Linking ASM shared library libnosyscall.in.so
    [ 8%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/util.s.o
    /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/syscall_intercept_base_asm.dir/src/util.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/src/util.s
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/nosyscall.in.dir/link.txt --verbose=1
    [ 9%] Linking ASM shared library libnosyscall.out.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/nosyscall.out.dir/link.txt --verbose=1
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libnosyscall.in.so CMakeFiles/nosyscall.in.dir/nosyscall.in.s.o
    [ 10%] Building C object CMakeFiles/cpp_test.dir/src/cpp_compile_mock.c.o
    /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -fPIE -std=c99 -o CMakeFiles/cpp_test.dir/src/cpp_compile_mock.c.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/src/cpp_compile_mock.c
    [ 11%] Linking ASM shared library libpattern1.in.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern1.in.dir/link.txt --verbose=1
    [ 12%] Linking ASM static library libsyscall_intercept_base_asm.a
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cmake -P CMakeFiles/syscall_intercept_base_asm.dir/cmake_clean_target.cmake
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libnosyscall.out.so CMakeFiles/nosyscall.out.dir/nosyscall.out.s.o
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern1.in.so CMakeFiles/pattern1.in.dir/pattern1.in.s.o
    [ 12%] Built target nosyscall.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern1.out.dir/build.make test/CMakeFiles/pattern1.out.dir/depend
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern1.out.dir/DependInfo.cmake --color=
    /usr/bin/cmake -E cmake_link_script CMakeFiles/syscall_intercept_base_asm.dir/link.txt --verbose=1
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 13%] Linking CXX executable cpp_test
    [ 13%] Linking C executable hook_test
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cpp_test.dir/link.txt --verbose=1
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/hook_test.dir/link.txt --verbose=1
    Scanning dependencies of target pattern1.out
    [ 13%] Built target pattern1.in
    make -f test/CMakeFiles/pattern2.in.dir/build.make test/CMakeFiles/pattern2.in.dir/depend
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern1.out.dir/build.make test/CMakeFiles/pattern1.out.dir/build
    /usr/bin/ar cr libsyscall_intercept_base_asm.a CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_template.s.o CMakeFiles/syscall_intercept_base_asm.dir/src/util.s.o
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern2.in.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/ranlib libsyscall_intercept_base_asm.a
    [ 13%] Built target nosyscall.out
    make -f test/CMakeFiles/pattern2.out.dir/build.make test/CMakeFiles/pattern2.out.dir/depend
    /usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/hook_test.dir/hook_test.c.o -o hook_test -rdynamic
    /usr/bin/c++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -DNDEBUG -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/cpp_test.dir/src/cpp_compile_test.cc.o CMakeFiles/cpp_test.dir/src/cpp_compile_mock.c.o -o cpp_test -rdynamic
    [ 14%] Linking C executable logging_test
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/logging_test.dir/link.txt --verbose=1
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern2.out.dir/DependInfo.cmake --color=
    Scanning dependencies of target pattern2.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern2.in.dir/build.make test/CMakeFiles/pattern2.in.dir/build
    [ 15%] Building ASM object test/CMakeFiles/pattern1.out.dir/pattern1.out.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern1_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern1.out.dir/pattern1.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern1.out.s
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/logging_test.dir/logging_test.c.o -o logging_test -rdynamic
    [ 15%] Built target syscall_intercept_base_asm
    Scanning dependencies of target pattern2.out
    make -f test/CMakeFiles/pattern_double_syscall.in.dir/build.make test/CMakeFiles/pattern_double_syscall.in.dir/depend
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern2.out.dir/build.make test/CMakeFiles/pattern2.out.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_double_syscall.in.dir/DependInfo.cmake --color=
    [ 15%] Building ASM object test/CMakeFiles/pattern2.in.dir/pattern2.in.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern2_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern2.in.dir/pattern2.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern2.in.s
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    Scanning dependencies of target pattern_double_syscall.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_double_syscall.in.dir/build.make test/CMakeFiles/pattern_double_syscall.in.dir/build
    [ 16%] Linking ASM shared library libpattern1.out.so
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern1.out.dir/link.txt --verbose=1
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 17%] Building ASM object test/CMakeFiles/pattern2.out.dir/pattern2.out.s.o
    [ 17%] Built target hook_test
    [ 18%] Linking ASM shared library libpattern2.in.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern2_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern2.out.dir/pattern2.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern2.out.s
    make -f test/CMakeFiles/pattern_double_syscall.out.dir/build.make test/CMakeFiles/pattern_double_syscall.out.dir/depend
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern2.in.dir/link.txt --verbose=1
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_double_syscall.out.dir/DependInfo.cmake --color=
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern1.out.so CMakeFiles/pattern1.out.dir/pattern1.out.s.o
    [ 19%] Building ASM object test/CMakeFiles/pattern_double_syscall.in.dir/pattern_double_syscall.in.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_double_syscall_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_double_syscall.in.dir/pattern_double_syscall.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_double_syscall.in.s
    [ 19%] Built target logging_test
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern2.in.so CMakeFiles/pattern2.in.dir/pattern2.in.s.o
    make -f test/CMakeFiles/pattern_jmps.in.dir/build.make test/CMakeFiles/pattern_jmps.in.dir/depend
    Scanning dependencies of target pattern_double_syscall.out
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_double_syscall.out.dir/build.make test/CMakeFiles/pattern_double_syscall.out.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_jmps.in.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 20%] Linking ASM shared library libpattern2.out.so
    [ 20%] Built target pattern1.out
    [ 21%] Building ASM object test/CMakeFiles/pattern_double_syscall.out.dir/pattern_double_syscall.out.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern2.out.dir/link.txt --verbose=1
    Scanning dependencies of target pattern_jmps.in
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_double_syscall_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_double_syscall.out.dir/pattern_double_syscall.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_double_syscall.out.s
    make -f test/CMakeFiles/pattern_jmps.out.dir/build.make test/CMakeFiles/pattern_jmps.out.dir/depend
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_jmps.in.dir/build.make test/CMakeFiles/pattern_jmps.in.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_jmps.out.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern2.out.so CMakeFiles/pattern2.out.dir/pattern2.out.s.o
    [ 22%] Linking ASM shared library libpattern_double_syscall.in.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_double_syscall.in.dir/link.txt --verbose=1
    [ 22%] Built target pattern2.in
    make -f test/CMakeFiles/pattern_loop.in.dir/build.make test/CMakeFiles/pattern_loop.in.dir/depend
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_loop.in.dir/DependInfo.cmake --color=
    Scanning dependencies of target pattern_jmps.out
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_jmps.out.dir/build.make test/CMakeFiles/pattern_jmps.out.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 23%] Building ASM object test/CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_jmps_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_jmps.in.s
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_double_syscall.in.so CMakeFiles/pattern_double_syscall.in.dir/pattern_double_syscall.in.s.o
    [ 23%] Linking ASM shared library libpattern_double_syscall.out.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_double_syscall.out.dir/link.txt --verbose=1
    [ 23%] Built target pattern2.out
    make -f test/CMakeFiles/pattern_loop.out.dir/build.make test/CMakeFiles/pattern_loop.out.dir/depend
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_loop.out.dir/DependInfo.cmake --color=
    [ 24%] Building ASM object test/CMakeFiles/pattern_jmps.out.dir/pattern_jmps.out.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_jmps_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_jmps.out.dir/pattern_jmps.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_jmps.out.s
    Scanning dependencies of target pattern_loop.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 24%] Built target cpp_test
    make -f test/CMakeFiles/pattern_loop.in.dir/build.make test/CMakeFiles/pattern_loop.in.dir/build
    make -f test/CMakeFiles/pattern_loop2.in.dir/build.make test/CMakeFiles/pattern_loop2.in.dir/depend
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_loop2.in.dir/DependInfo.cmake --color=
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_double_syscall.out.so CMakeFiles/pattern_double_syscall.out.dir/pattern_double_syscall.out.s.o
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    Scanning dependencies of target pattern_loop.out
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_loop.out.dir/build.make test/CMakeFiles/pattern_loop.out.dir/build
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    Scanning dependencies of target pattern_loop2.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_loop2.in.dir/build.make test/CMakeFiles/pattern_loop2.in.dir/build
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 25%] Linking C executable check_license_executable
    [ 26%] Building ASM object test/CMakeFiles/pattern_loop.in.dir/pattern_loop.in.s.o
    /usr/bin/cmake -E cmake_link_script CMakeFiles/check_license_executable.dir/link.txt --verbose=1
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_loop_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_loop.in.dir/pattern_loop.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_loop.in.s
    [ 27%] Linking ASM shared library libpattern_jmps.out.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_jmps.out.dir/link.txt --verbose=1
    [ 27%] Built target pattern_double_syscall.in
    make -f test/CMakeFiles/pattern_loop2.out.dir/build.make test/CMakeFiles/pattern_loop2.out.dir/depend
    [ 27%] Built target pattern_double_syscall.out
    make -f test/CMakeFiles/pattern_nop_padding0.in.dir/build.make test/CMakeFiles/pattern_nop_padding0.in.dir/depend
    [ 28%] Building ASM object test/CMakeFiles/pattern_loop2.in.dir/pattern_loop2.in.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_loop2_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_loop2.in.dir/pattern_loop2.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_loop2.in.s
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_loop2.out.dir/DependInfo.cmake --color=
    make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/rpmbuild/BUILD/syscall_intercept-0.1 /root/rpmbuild/BUILD/syscall_intercept-0.1/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test/CMakeFiles/pattern_nop_padding0.in.dir/DependInfo.cmake --color=
    [ 29%] Linking ASM shared library libpattern_jmps.in.so
    [ 29%] Building ASM object test/CMakeFiles/pattern_loop.out.dir/pattern_loop.out.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_jmps.in.dir/link.txt --verbose=1
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_loop_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_loop.out.dir/pattern_loop.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_loop.out.s
    /usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wextra -pedantic -Wno-c90-c99-compat -DNDEBUG -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/check_license_executable.dir/utils/check_license/check-license.c.o -o check_license_executable -rdynamic
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_jmps.out.so CMakeFiles/pattern_jmps.out.dir/pattern_jmps.out.s.o
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_jmps.in.so CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.s.o
    [ 30%] Linking ASM shared library libpattern_loop.in.so
    Scanning dependencies of target pattern_nop_padding0.in
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_loop.in.dir/link.txt --verbose=1
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make -f test/CMakeFiles/pattern_nop_padding0.in.dir/build.make test/CMakeFiles/pattern_nop_padding0.in.dir/build
    /usr/bin/ld: CMakeFiles/pattern_jmps.out.dir/pattern_jmps.out.s.o: relocation R_X86_64_PC32 against symbol text_end' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status Scanning dependencies of target pattern_loop2.out test/CMakeFiles/pattern_jmps.out.dir/build.make:89: recipe for target 'test/libpattern_jmps.out.so' failed make[2]: *** [test/libpattern_jmps.out.so] Error 1 make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build' make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build' CMakeFiles/Makefile2:1089: recipe for target 'test/CMakeFiles/pattern_jmps.out.dir/all' failed make[1]: *** [test/CMakeFiles/pattern_jmps.out.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build' make -f test/CMakeFiles/pattern_loop2.out.dir/build.make test/CMakeFiles/pattern_loop2.out.dir/build [ 31%] Linking ASM shared library libpattern_loop2.in.so cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_loop2.in.dir/link.txt --verbose=1 /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_loop.in.so CMakeFiles/pattern_loop.in.dir/pattern_loop.in.s.o [ 32%] Building ASM object test/CMakeFiles/pattern_nop_padding0.in.dir/pattern_nop_padding0.in.s.o cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_nop_padding0_in_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_nop_padding0.in.dir/pattern_nop_padding0.in.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_nop_padding0.in.s [ 33%] Linking ASM shared library libpattern_loop.out.so cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_loop.out.dir/link.txt --verbose=1 make[2]: Entering directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build' /usr/bin/ld: CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.s.o: relocation R_X86_64_PC32 against symbol text_end' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status
    make[2]: *** [test/libpattern_jmps.in.so] Error 1
    test/CMakeFiles/pattern_jmps.in.dir/build.make:89: recipe for target 'test/libpattern_jmps.in.so' failed
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[1]: *** [test/CMakeFiles/pattern_jmps.in.dir/all] Error 2
    CMakeFiles/Makefile2:1052: recipe for target 'test/CMakeFiles/pattern_jmps.in.dir/all' failed
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_loop2.in.so CMakeFiles/pattern_loop2.in.dir/pattern_loop2.in.s.o
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_loop.out.so CMakeFiles/pattern_loop.out.dir/pattern_loop.out.s.o
    [ 34%] Building ASM object test/CMakeFiles/pattern_loop2.out.dir/pattern_loop2.out.s.o
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cc -DHAS_GCC_PRAGMA_SYSH -D_GNU_SOURCE -Dpattern_loop2_out_EXPORTS -I/root/rpmbuild/BUILD/syscall_intercept-0.1/include -I/root/rpmbuild/BUILD/syscall_intercept-0.1/src -I/root/rpmbuild/BUILD/syscall_intercept-0.1/test -O3 -DNDEBUG -fPIC -Wno-unused-command-line-argument -o CMakeFiles/pattern_loop2.out.dir/pattern_loop2.out.s.o -c /root/rpmbuild/BUILD/syscall_intercept-0.1/test/pattern_loop2.out.s
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 34%] Linking ASM shared library libpattern_nop_padding0.in.so
    [ 34%] Built target pattern_loop.in
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_nop_padding0.in.dir/link.txt --verbose=1
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 34%] Built target check_license_executable
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_nop_padding0.in.so CMakeFiles/pattern_nop_padding0.in.dir/pattern_nop_padding0.in.s.o
    [ 34%] Built target pattern_loop2.in
    [ 34%] Built target pattern_loop.out
    [ 35%] Linking ASM shared library libpattern_loop2.out.so
    cd /root/rpmbuild/BUILD/syscall_intercept-0.1/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_loop2.out.dir/link.txt --verbose=1
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    /usr/bin/cc -fPIC -O3 -DNDEBUG -nostdlib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -o libpattern_loop2.out.so CMakeFiles/pattern_loop2.out.dir/pattern_loop2.out.s.o
    [ 35%] Built target pattern_nop_padding0.in
    make[2]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    [ 35%] Built target pattern_loop2.out
    make[1]: Leaving directory '/root/rpmbuild/BUILD/syscall_intercept-0.1/build'
    make: *** [all] Error 2
    Makefile:141: recipe for target 'all' failed
    error: Bad exit status from /var/tmp/rpm-tmp.IQmzBk (%build)
    Bad exit status from /var/tmp/rpm-tmp.IQmzBk (%build)

RPM build errors:
The command '/bin/sh -c ./install-syscall_intercept.sh rpm' returned a non-zero code: 1

Handling vfork

Add a test and or an example which uses vfork.
Reevaluate the special case in intercept.c for nr == SYS_vfork.

37 tests failed on Ubuntu 18.04

Running tests...
      Start  1: asm_pattern_nosyscall
 1/40 Test  #1: asm_pattern_nosyscall ..................***Exception: SegFault  0.08 sec
      Start  2: asm_pattern_pattern1
 2/40 Test  #2: asm_pattern_pattern1 ...................***Exception: SegFault  0.08 sec
      Start  3: asm_pattern_pattern2
 3/40 Test  #3: asm_pattern_pattern2 ...................***Exception: SegFault  0.08 sec
      Start  4: asm_pattern_pattern3
 4/40 Test  #4: asm_pattern_pattern3 ...................***Exception: SegFault  0.08 sec
      Start  5: asm_pattern_pattern4
 5/40 Test  #5: asm_pattern_pattern4 ...................***Exception: SegFault  0.08 sec
      Start  6: asm_pattern_pattern_loop
 6/40 Test  #6: asm_pattern_pattern_loop ...............***Exception: SegFault  0.08 sec
      Start  7: asm_pattern_pattern_loop2
 7/40 Test  #7: asm_pattern_pattern_loop2 ..............***Exception: SegFault  0.08 sec
      Start  8: asm_pattern_pattern_symbol_boundary0
 8/40 Test  #8: asm_pattern_pattern_symbol_boundary0 ...***Exception: SegFault  0.08 sec
      Start  9: asm_pattern_pattern_symbol_boundary1
 9/40 Test  #9: asm_pattern_pattern_symbol_boundary1 ...***Exception: SegFault  0.08 sec
      Start 10: asm_pattern_pattern_symbol_boundary2
10/40 Test #10: asm_pattern_pattern_symbol_boundary2 ...***Exception: SegFault  0.08 sec
      Start 11: asm_pattern_pattern_symbol_boundary3
11/40 Test #11: asm_pattern_pattern_symbol_boundary3 ...***Exception: SegFault  0.08 sec
      Start 12: asm_pattern_pattern_nop_padding0
12/40 Test #12: asm_pattern_pattern_nop_padding0 .......***Exception: SegFault  0.08 sec
      Start 13: asm_pattern_pattern_nop_padding1
13/40 Test #13: asm_pattern_pattern_nop_padding1 .......***Exception: SegFault  0.08 sec
      Start 14: asm_pattern_pattern_nop_padding2
14/40 Test #14: asm_pattern_pattern_nop_padding2 .......***Exception: SegFault  0.08 sec
      Start 15: asm_pattern_pattern_nop_padding3
15/40 Test #15: asm_pattern_pattern_nop_padding3 .......***Exception: SegFault  0.08 sec
      Start 16: asm_pattern_pattern_nop_padding4
16/40 Test #16: asm_pattern_pattern_nop_padding4 .......***Exception: SegFault  0.08 sec
      Start 17: asm_pattern_pattern_nop_padding5
17/40 Test #17: asm_pattern_pattern_nop_padding5 .......***Exception: SegFault  0.08 sec
      Start 18: asm_pattern_pattern_nop_padding6
18/40 Test #18: asm_pattern_pattern_nop_padding6 .......***Exception: SegFault  0.08 sec
      Start 19: asm_pattern_pattern_nop_padding7
19/40 Test #19: asm_pattern_pattern_nop_padding7 .......***Exception: SegFault  0.08 sec
      Start 20: asm_pattern_pattern_nop_padding8
20/40 Test #20: asm_pattern_pattern_nop_padding8 .......***Exception: SegFault  0.08 sec
      Start 21: asm_pattern_pattern_nop_padding9
21/40 Test #21: asm_pattern_pattern_nop_padding9 .......***Exception: SegFault  0.08 sec
      Start 22: asm_pattern_pattern_double_syscall
22/40 Test #22: asm_pattern_pattern_double_syscall .....***Exception: SegFault  0.08 sec
      Start 23: asm_pattern_pattern_rets
23/40 Test #23: asm_pattern_pattern_rets ...............***Exception: SegFault  0.08 sec
      Start 24: asm_pattern_pattern_jmps
24/40 Test #24: asm_pattern_pattern_jmps ...............***Exception: SegFault  0.08 sec
      Start 25: fork_logging
25/40 Test #25: fork_logging ...........................***Failed    0.10 sec
      Start 26: hook_with_shared
26/40 Test #26: hook_with_shared .......................***Failed    0.10 sec
      Start 27: hook_with_static
27/40 Test #27: hook_with_static .......................***Failed    0.09 sec
      Start 28: hook_clone
28/40 Test #28: hook_clone .............................***Failed    0.10 sec
      Start 29: filter_none
29/40 Test #29: filter_none ............................***Failed  Required regular expression not found.Regex=[hooked - allowed
]  0.10 sec
      Start 30: filter_positive
30/40 Test #30: filter_positive ........................***Failed  Required regular expression not found.Regex=[hooked - allowed
]  0.09 sec
      Start 31: filter_negative
31/40 Test #31: filter_negative ........................   Passed    0.01 sec
      Start 32: filter_negative_substring0
32/40 Test #32: filter_negative_substring0 .............   Passed    0.01 sec
      Start 33: filter_negative_substring1
33/40 Test #33: filter_negative_substring1 .............   Passed    0.01 sec
      Start 34: clone_thread
34/40 Test #34: clone_thread ...........................***Failed  Required regular expression not found.Regex=[clone_hook_child called
]  0.09 sec
      Start 35: prog_pie_intercept_libc_only
35/40 Test #35: prog_pie_intercept_libc_only ...........***Failed  Required regular expression not found.Regex=[original_syscall
]  0.09 sec
      Start 36: prog_no_pie_intercept_libc_only
36/40 Test #36: prog_no_pie_intercept_libc_only ........***Failed  Required regular expression not found.Regex=[original_syscall
]  0.09 sec
      Start 37: prog_pie_intercept_all
37/40 Test #37: prog_pie_intercept_all .................***Failed  Required regular expression not found.Regex=[intercepted_call
]  0.09 sec
      Start 38: prog_no_pie_intercept_all
38/40 Test #38: prog_no_pie_intercept_all ..............***Failed  Required regular expression not found.Regex=[intercepted_call
]  0.09 sec
      Start 39: vfork_logging
39/40 Test #39: vfork_logging ..........................***Failed  Required regular expression not found.Regex=[in_child_created_using_vfork
]  0.09 sec
      Start 40: syscall_format_logging
40/40 Test #40: syscall_format_logging .................***Failed    0.09 sec

8% tests passed, 37 tests failed out of 40

Total Test time (real) =   3.19 sec
The following tests FAILED:
      1 - asm_pattern_nosyscall (SEGFAULT)
      2 - asm_pattern_pattern1 (SEGFAULT)
      3 - asm_pattern_pattern2 (SEGFAULT)
      4 - asm_pattern_pattern3 (SEGFAULT)
      5 - asm_pattern_pattern4 (SEGFAULT)
      6 - asm_pattern_pattern_loop (SEGFAULT)
      7 - asm_pattern_pattern_loop2 (SEGFAULT)
      8 - asm_pattern_pattern_symbol_boundary0 (SEGFAULT)
      9 - asm_pattern_pattern_symbol_boundary1 (SEGFAULT)
     10 - asm_pattern_pattern_symbol_boundary2 (SEGFAULT)
     11 - asm_pattern_pattern_symbol_boundary3 (SEGFAULT)
     12 - asm_pattern_pattern_nop_padding0 (SEGFAULT)
     13 - asm_pattern_pattern_nop_padding1 (SEGFAULT)
     14 - asm_pattern_pattern_nop_padding2 (SEGFAULT)
     15 - asm_pattern_pattern_nop_padding3 (SEGFAULT)
     16 - asm_pattern_pattern_nop_padding4 (SEGFAULT)
     17 - asm_pattern_pattern_nop_padding5 (SEGFAULT)
     18 - asm_pattern_pattern_nop_padding6 (SEGFAULT)
     19 - asm_pattern_pattern_nop_padding7 (SEGFAULT)
     20 - asm_pattern_pattern_nop_padding8 (SEGFAULT)
     21 - asm_pattern_pattern_nop_padding9 (SEGFAULT)
     22 - asm_pattern_pattern_double_syscall (SEGFAULT)
     23 - asm_pattern_pattern_rets (SEGFAULT)
     24 - asm_pattern_pattern_jmps (SEGFAULT)
     25 - fork_logging (Failed)
     26 - hook_with_shared (Failed)
     27 - hook_with_static (Failed)
     28 - hook_clone (Failed)
     29 - filter_none (Failed)
     30 - filter_positive (Failed)
     34 - clone_thread (Failed)
     35 - prog_pie_intercept_libc_only (Failed)
     36 - prog_no_pie_intercept_libc_only (Failed)
     37 - prog_pie_intercept_all (Failed)
     38 - prog_no_pie_intercept_all (Failed)
     39 - vfork_logging (Failed)
     40 - syscall_format_logging (Failed)
Makefile:129: recipe for target 'test' failed

Ubuntu 18.04 LTS, GCC 7.5.0, GLIBC 2.27

Support long lines in /proc/self/maps

The fgets call from allocate_trampoline_table in intercept_desc.c uses a fixed-size line buffer. If entries in /proc/self/maps are longer than 0x100 characters the sscanf code fails to parse the line correctly, since fgets will return the remainder of the previous line.

How to place `intercept_hook_point*` pointers on thread local storge and actually use it?

I want to make these hooking function pointers to be placed on thread local storage, in order to selectively disable and enable hooking on individual thread. But change definition of these variables with __attribute((tls_model("initial-exec"))) _Thread_local leads to having uninitialized (NULL) value on child threads. Is it related to the disassembly process? Is there a known way to put instruction address to jump for syscall instruction wrapper?

Also, assigning function address to intercept_hook_point_clone_child seems to not call hooked function at clone() at all with or without __attribute((tls_model("initial-exec"))) _Thread_local. Is it normal behavior?

Minor issues left over from initial review

Make the number of ELF section headers being tracked dynamic, or just add a comment about the array size being dynamic.
Elf64_Shdr headers[0x10];
"magic number - pls, comment on why it's 0x10"

Document in Readme.md what each dependancy is used for.
"perl -- for checking code style errors (or something similar)"

Fix man page installation
See debian/libsyscall-intercept.dev.manpages

segfault in mprotect

trying to mark mprotect as not avail.
ubuntu 22.04, x86-64.
below will segfault.

#include <libsyscall_intercept_hook_point.h>
#include <syscall.h>
#include <errno.h>

static int
hook(long syscall_number,
                        long arg0, long arg1,
                        long arg2, long arg3,
                        long arg4, long arg5,
                        long *result)
{
        if (syscall_number == SYS_mprotect) {
                *result = -ENOTSUP;
                return 0;
        } else {
                return 1;
        }
}

static __attribute__((constructor)) void
init(void)
{
        intercept_hook_point = hook;
}

Workaround SYS_clone3 in Ubuntu 22.04

The GLIBC 2.35 in Ubuntu 22.04 uses SYS_clone3 to create threads, that seems to cause segfault in hook. I use the following workaround to force a fall back to SYS_clone.

if (syscall_number == SYS_clone3)
{
    *result = -ENOSYS;
    return 0;
}

But I guess this may not work if actual call is clone3.

Cannot print backtrace after syscall interception

All backtrace functions are not working in the syscall overriden functions, e.g.

int backtrace(void **buffer, int size);
#include <boost/stacktrace.hpp>
std::cout << boost::stacktrace::stacktrace();

Looks like the interception assembly doesn't set the ss and sp back correctly. Not sure if this is the root cause.
Is it possible to recover the full stack trace to ease trouble-shooting?

capstone library not found

On ubuntu xenial:

I'm compiling capstone from git, and using ./make.sh install:

$ cd /usr/include/capstone/
$ ls
arm64.h arm.h capstone.h mips.h platform.h ppc.h sparc.h systemz.h x86.h xcore.h
$ ls -la /usr/lib/libcapstone.so
lrwxrwxrwx 1 root root 16 Jun 4 17:00 /usr/lib/libcapstone.so -> libcapstone.so.3

Then I try to compile syscall_intercept:

$cmake ~/syscall_intercept/ -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc

CMake Error at cmake/find_capstone.cmake:42 (message):
capstone library not found
Call Stack (most recent call first):
CMakeLists.txt:55 (include)

what am I doing wrong?

ld.so is not intercepted

When a binary program has some dyn-libs stored in a user space file system who uses the syscall_intercept, these dyn-libs are loaded by ld.so instead of libc.so, where the read syscall is not intercepted.

Fix conflict with code sanitizers (UBSAN, ASAN)

  • Use UBSAN and ASAN when it is possible.
    The way UBSAN, ASAN do code instrumentation seems to be conflicting with syscall_intercept's syscall hooking. They insert syscall instructions to places other than libc. Looking for all syscalls, and patching all of them outside libc as well probably fixes the conflict.

syscall_intercept does not build with clang 5.0.0

GCC 7.2.0 works fine though

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
make -j8
Scanning dependencies of target check_whitespace
Scanning dependencies of target syscall_intercept_base_clf
Scanning dependencies of target cpp_test
Scanning dependencies of target check_license_executable
Scanning dependencies of target test_clone_thread
Scanning dependencies of target syscall_intercept_base_asm
Scanning dependencies of target executable_with_syscall_pie
Scanning dependencies of target cstyle
[  0%] Building C object CMakeFiles/syscall_intercept_base_clf.dir/src/cmdline_filter.c.o
[  1%] Building CXX object CMakeFiles/cpp_test.dir/src/cpp_compile_test.cc.o
[  1%] Building C object CMakeFiles/check_license_executable.dir/utils/check_license/check-license.c.o
[  2%] Building C object test/CMakeFiles/test_clone_thread.dir/test_clone_thread.c.o
[  2%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_template.s.o
[  3%] Building ASM object test/CMakeFiles/executable_with_syscall_pie.dir/executable_with_syscall.s.o
[  3%] Built target check_whitespace
Scanning dependencies of target hook_test_preload_o
[  4%] Building C object test/CMakeFiles/hook_test_preload_o.dir/hook_test_preload.c.o
[  5%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/util.s.o
[  5%] Building C object CMakeFiles/cpp_test.dir/src/cpp_compile_mock.c.o
[  5%] Built target syscall_intercept_base_clf
[  6%] Linking ASM executable executable_with_syscall_pie
[  6%] Linking C executable test_clone_thread
Scanning dependencies of target hook_test
[  6%] Building C object test/CMakeFiles/hook_test.dir/hook_test.c.o
[  6%] Built target hook_test_preload_o
[  7%] Linking CXX executable cpp_test
[  8%] Building ASM object CMakeFiles/syscall_intercept_base_asm.dir/src/intercept_wrapper.s.o
Scanning dependencies of target pattern_jmps.out
[  9%] Linking C executable check_license_executable
[  9%] Built target executable_with_syscall_pie
[  9%] Built target cstyle
[ 10%] Building ASM object test/CMakeFiles/pattern_jmps.out.dir/pattern_jmps.out.s.o
Scanning dependencies of target pattern_jmps.in
Scanning dependencies of target pattern_rets.in
[ 10%] Built target test_clone_thread
[ 11%] Building ASM object test/CMakeFiles/pattern_rets.in.dir/pattern_rets.in.s.o
[ 12%] Building ASM object test/CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.s.o
Scanning dependencies of target pattern_rets.out
[ 12%] Built target syscall_intercept_base_asm
[ 13%] Building ASM object test/CMakeFiles/pattern_rets.out.dir/pattern_rets.out.s.o
[ 13%] Linking C executable hook_test
Scanning dependencies of target pattern_double_syscall.out
[ 13%] Built target check_license_executable
[ 13%] Building ASM object test/CMakeFiles/pattern_double_syscall.out.dir/pattern_double_syscall.out.s.o
Scanning dependencies of target pattern_nop_padding8.in
[ 14%] Linking ASM shared library libpattern_jmps.out.so
[ 14%] Linking ASM shared library libpattern_jmps.in.so
[ 15%] Linking ASM shared library libpattern_rets.in.so
[ 16%] Building ASM object test/CMakeFiles/pattern_nop_padding8.in.dir/pattern_nop_padding8.in.s.o
[ 17%] Linking ASM shared library libpattern_rets.out.so
[ 17%] Built target hook_test
[ 17%] Built target pattern_jmps.out
[ 18%] Linking ASM shared library libpattern_double_syscall.out.so
Scanning dependencies of target pattern_nop_padding7.in
[ 18%] Built target pattern_rets.in
[ 18%] Built target cpp_test
[ 18%] Built target pattern_jmps.in
Scanning dependencies of target pattern_nop_padding6.out
Scanning dependencies of target pattern_nop_padding9.in
Scanning dependencies of target pattern_symbol_boundary0.in
[ 19%] Building ASM object test/CMakeFiles/pattern_nop_padding7.in.dir/pattern_nop_padding7.in.s.o
Scanning dependencies of target prog_using_vfork
[ 20%] Building ASM object test/CMakeFiles/pattern_nop_padding6.out.dir/pattern_nop_padding6.out.s.o
[ 20%] Linking ASM shared library libpattern_nop_padding8.in.so
[ 20%] Building ASM object test/CMakeFiles/pattern_nop_padding9.in.dir/pattern_nop_padding9.in.s.o
[ 21%] Building C object test/CMakeFiles/prog_using_vfork.dir/prog_using_vfork.c.o
[ 22%] Building ASM object test/CMakeFiles/pattern_symbol_boundary0.in.dir/pattern_symbol_boundary0.in.s.o
[ 22%] Built target pattern_rets.out
Scanning dependencies of target pattern_loop2.out
[ 22%] Built target pattern_double_syscall.out
[ 22%] Building ASM object test/CMakeFiles/pattern_loop2.out.dir/pattern_loop2.out.s.o
Scanning dependencies of target pattern_loop2.in
[ 23%] Linking ASM shared library libpattern_nop_padding7.in.so
[ 24%] Building ASM object test/CMakeFiles/pattern_loop2.in.dir/pattern_loop2.in.s.o
[ 24%] Built target pattern_nop_padding8.in
[ 24%] Linking ASM shared library libpattern_nop_padding6.out.so
[ 24%] Linking ASM shared library libpattern_symbol_boundary0.in.so
[ 25%] Linking ASM shared library libpattern_nop_padding9.in.so
Scanning dependencies of target pattern_loop.out
/home/szychows/repo/syscall_intercept/test/pattern_loop2.out.s:59:3: error: invalid operand for instruction
                loop    0b
                ^
make[2]: *** [test/CMakeFiles/pattern_loop2.out.dir/build.make:63: test/CMakeFiles/pattern_loop2.out.dir/pattern_loop2.out.s.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1553: test/CMakeFiles/pattern_loop2.out.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 26%] Building ASM object test/CMakeFiles/pattern_loop.out.dir/pattern_loop.out.s.o
[ 26%] Built target pattern_nop_padding7.in
/home/szychows/repo/syscall_intercept/test/pattern_loop2.in.s:55:3: error: invalid operand for instruction
                loop    0b # this one as well
                ^
[ 26%] Built target pattern_nop_padding6.out
make[2]: *** [test/CMakeFiles/pattern_loop2.in.dir/build.make:63: test/CMakeFiles/pattern_loop2.in.dir/pattern_loop2.in.s.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1590: test/CMakeFiles/pattern_loop2.in.dir/all] Error 2
[ 27%] Linking C executable prog_using_vfork
[ 27%] Built target pattern_nop_padding9.in
[ 27%] Built target pattern_symbol_boundary0.in
/home/szychows/repo/syscall_intercept/test/pattern_loop.out.s:61:3: error: invalid operand for instruction
                loop    0b
                ^
make[2]: *** [test/CMakeFiles/pattern_loop.out.dir/build.make:63: test/CMakeFiles/pattern_loop.out.dir/pattern_loop.out.s.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1627: test/CMakeFiles/pattern_loop.out.dir/all] Error 2
[ 27%] Built target prog_using_vfork
make: *** [Makefile:141: all] Error 2

Intercept works with libc 2.29-4 but not with libc 2.30-1

After upgrading libc to 2.30-1, I am seeing the next message :

not enough space for patching around syscal libsyscall_intercept error

The log has the next contents:

tempfile=$(mktemp) ; tempfile2=$(mktemp) ; grep "^/" $0 | cut -d " " -f 1,2 | sed "s/^/addr2line -p -f -e /" > $tempfile ; { echo ; . $tempfile ; echo ; } > $tempfile2 ; paste $tempfile2 $0 ; exit 0
unintercepted syscall at: /usr/lib/libc.so.6 0x2588b

Going to the previous version of glibc shows the correct behaviour:

tempfile=$(mktemp) ; tempfile2=$(mktemp) ; grep "^/" $0 | cut -d " " -f 1,2 | sed "s/^/addr2line -p -f -e /" > $tempfile ; { echo ; . $tempfile ; echo ; } > $tempfile2 ; paste $tempfile2 $0 ; exit 0
/usr/lib/libc.so.6 0xf24ca -- openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY | O_CLOEXEC) = ?

Missing "NOT" in CMakeLists.txt

if(",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_BINARY_DIR},")

According to CMake doc, CMAKE_SOURCE_DIR should be the same as CMAKE_BINARY_DIR for an in-source build. Thus, I assume the above line missed a NOT?
After I changed to this, the compile works:

if(NOT ",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_BINARY_DIR},")

aarch64 support

Hi,

It seems the current code does not support aarch64 arch, at least the system call numbers are different. Am I understand it correctly? Are there any existing alternatives?

Thanks.

I am unable to compile the code on ubuntu 16.4 LTS after cloning source.

avocado@build-u16:~/Dev/preload/syscall_intercept/build$ make
[ 0%] Built target check_whitespace
[ 2%] Built target cpp_test
[ 2%] Built target cstyle
[ 7%] Built target syscall_intercept_base_c
[ 9%] Built target syscall_intercept_base_asm
[ 10%] Built target syscall_intercept_base_clf
[ 11%] Built target syscall_intercept_unscoped
[ 12%] Generating syscall_intercept_scoped.o
make[2]: localize-hidden: Command not found
[ 13%] Built target generate_syscall_intercept_scoped
[ 13%] Generating syscall_intercept_scoped.o
make[2]: localize-hidden: Command not found
[ 13%] Generating syscall_intercept_scoped.o
make[2]: localize-hidden: Command not found
[ 14%] Linking C shared library libsyscall_intercept.so
gcc: error: syscall_intercept_scoped.o: No such file or directory
CMakeFiles/syscall_intercept_shared.dir/build.make:78: recipe for target 'libsyscall_intercept.so.0.1.0' failed
make[2]: *** [libsyscall_intercept.so.0.1.0] Error 1
CMakeFiles/Makefile2:284: recipe for target 'CMakeFiles/syscall_intercept_shared.dir/all' failed
make[1]: *** [CMakeFiles/syscall_intercept_shared.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

example.c does not work

I try to intercept a few syscalls. And I decided to run example.c listed inside README to see if it works.

#include <libsyscall_intercept_hook_point.h>
#include <syscall.h>
#include <errno.h>

static int
hook(long syscall_number,
			long arg0, long arg1,
			long arg2, long arg3,
			long arg4, long arg5,
			long *result)
{
	if (syscall_number == SYS_getdents) {
		/*
		 * Prevent the application from
		 * using the getdents syscall. From
		 * the point of view of the calling
		 * process, it is as if the kernel
		 * would return the ENOTSUP error
		 * code from the syscall.
		 */
		*result = -ENOTSUP;
		return 0;
	} else {
		/*
		 * Ignore any other syscalls
		 * i.e.: pass them on to the kernel
		 * as would normally happen.
		 */
		return 1;
	}
}

static __attribute__((constructor)) void
init(void)
{
	// Set up the callback function
	intercept_hook_point = hook;
}
$ cc example.c -lsyscall_intercept -fpic -shared -o example.so
$ LD_LIBRARY_PATH=. LD_PRELOAD=example.so ls

However, ls works. It shows everything under the current directory.

I am using Ubuntu 22.04.2 LTS.

Could anyone help me with that?

syscall_no_intercept() doesn't match return semantics of real syscall()

syscall_no_intercept() returns a negated error value rather than setting errno and returning -1 (like syscall() does).
This is documented, and the library does include a syscall_error_code() helper, but it seems a pretty confusing way to do it since syscall_no_intercept() is presented as a drop in replacement for syscall().

For my use I hacked together a little macro to marshal the return values into errno where appropriate, but it'd be nice to see this in the library. What are your thoughts?

#define REAL_SYSCALL(calln, ...) ({                          \
    long __tmp = syscall_no_intercept(calln, ##__VA_ARGS__); \
    errno = syscall_error_code(__tmp);                       \
    if(errno != 0) {                                         \
        __tmp = -1;                                          \
    }                                                        \
    __tmp;                                                   \
})

Cheers,

  • Alex.

Linking error when new external variable is introduced in intercept_wrapper.S

This is more like a question other than a issue since this issue is related to the added feature that I'm currently working on, but I don't have any other place to get help on this.

I'm currently working on the version where intercept_hook_point is a static TLS variable that allows each thread to turn on and off the syscall interception dynamically (and a front-end library providing AS-safety against signal as well). You can check it here (except the AS-safe front-end library yet). This solution is for the users who wants to use glibc C/C++ function for some reasons (e.g. don't want to use syscall_no_intercept or additional dlopen() to link original object, want to use complex standard functions or STL things, etc.) during the interception with the cost of inefficiency (as it still goes through the intercepting routines).

In order to relax the overhead when intercept_hook_point is set to NULL (i.e. disable the interception by the thread), I insert the procedure into intercept_wrapper.S in the above fork repository (starting from the line 55):


.global intercept_hook_point
.hidden intercept_hook_point
.type intercept_hook_point, @tls_object

.text

/*
 * Local stack layout:
 *
 * 0x448(%rsp)  -- return address, to the generated asm wrapper
 * Arguments recieved on stack:
 * 0x450(%rsp)  -- original value of rsp
 * 0x458(%rsp)  -- pointer to a struct patch_desc instance
 * Locals on stack:
 * 0xe8(%rsp) - 0x168(%rsp) -- saved GPRs
 * 0x200(%rsp) - 0x400(%rsp) -- saved SIMD registers
 *
 * A pointer to these saved register is passed to intercept_routine, so the
 * layout of `struct context` must match this part of the stack layout.
 *
 * Other arguments:
 * %rcx  -- which C function to call
 */
intercept_wrapper:
	.cfi_startproc

	/*
	 * Stack size used locally: 0x448 bytes.
	 *
	 * This size assumes the stack pointer was correctly aligned before
	 * executing the call instruction calling this function. The return
	 * address pushed to the stack uses 8 bytes. This gives the equation:
	 *
	 * new_rsp = original_rsp - 8 - 0x448 == original_rsp - 0x450
	 * The number 0x450 is a multiple of 16, so the stack is still correctly
	 * aligned. It is very easy to forget about this when making changes to this
	 * code.
	 */
	subq        $0x448, %rsp
	.cfi_def_cfa_offset 0x0

	cmp         $0x1, %rcx
	je          4f

	/* SYS_vfork */
	cmp         $58, %eax
	je          0f
	/* SYS_rt_sigreturn */
	cmp         $15, %eax
	je          0f
	/* SYS_clone */
	cmp         $56, %eax
	je          1f
	/* SYS_clone3 */
	cmp         $435, %eax
	je          1f

	movq        %rcx, 0x160 (%rsp)
	movq        intercept_hook_point (%rip), %rcx
	cmp         $0x0, %rcx
	jne         3f

	movq        0x160 (%rsp), %rcx
0:
	/* SYS_vfork & SYS_rt_sigreturn */
	movq        0x00, %r11
	jmp         2f
1:
	/* SYS_clone & SYS_clone3 */
	movq        0x02, %r11
2:
	addq        $0x448, %rsp
	retq

3:
	movq        0x160 (%rsp), %rcx

4:
	/* Save all GPRs on the stack */

This modification will make intercept_wrapper() to decide on whether the interception will be done or not (or handle differently depending on the syscall number) before intercept_routine() and the stack saving & restoration, in order to lower the false interception overhead for the current implementation (before intercept_wrapper(), intercept_asm_wrapper_tmpl() locates in many addresses for each syscall instruction address so putting the code there is risking the I-cache/I-TLB pollution).

However, this introduces a link error:

/usr/bin/ld: CMakeFiles/filter_test.dir/filter_test.c.o: in function `main':
filter_test.c:(.text+0xb): undefined reference to `intercept_hook_point'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

While the main library file, libsyscall_intercept.so is built successfully, undefined reference to `intercept_hook_point' is still there when trying to preloading it.

Test 25, 28 and 40 fail on Debian Jessie and Buster

The following tests fail on Debian Jessie (8) and Debian Buster (10). All tests pass on Debian Stretch (9).

The following tests FAILED:
	 25 - fork_logging (Failed)
	 28 - hook_clone (Failed)
	 40 - syscall_format_logging (Failed)

Note that the failure in the last test could be related to the commit I submitted to fix the build
bb10939

However this test already failed on Debian Buster before this commit, so... Maybe not related.

Compilation error

After calling make I get the following, any help appreciated, thanks.

$ make
[ 0%] Built target check_whitespace
[ 2%] Built target cpp_test
[ 2%] Built target cstyle
[ 8%] Built target syscall_intercept_base_c
[ 8%] Built target syscall_intercept_base_clf
[ 9%] Built target syscall_intercept_base_asm
[ 10%] Built target syscall_intercept_unscoped
[ 12%] Built target generate_syscall_intercept_scoped
[ 14%] Built target syscall_intercept_shared
[ 16%] Built target syscall_intercept_static
[ 17%] Built target check_license_executable
[ 19%] Built target syscall_logger
[ 20%] Built target fork_ban
[ 21%] Built target icap
[ 23%] Built target vfork_logging
[ 25%] Built target intercept_sys_write
[ 26%] Built target test_clone_thread_preload
[ 27%] Built target test_clone_thread
[ 28%] Built target filter_test
[ 29%] Built target hook_test_preload_o
[ 29%] Built target hook_test_preload_with_static
[ 30%] Built target hook_test_preload_with_shared
[ 31%] Building ASM object test/CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.S.o
/home/ivanc/dev/syscall_intercept/test/pattern_jmps.in.S:51:9: error: unknown token in expression
jmp 0f
^
/home/ivanc/dev/syscall_intercept/test/pattern_jmps.in.S:54:9: error: unknown token in expression
jmp 0f
^
make[2]: *** [test/CMakeFiles/pattern_jmps.in.dir/pattern_jmps.in.S.o] Error 1
make[1]: *** [test/CMakeFiles/pattern_jmps.in.dir/all] Error 2
make: *** [all] Error 2

intercept_disasm_next_instruction error

What could be the cause of following error when using syscall_intecerpt?

syscall_intercept/src/disasm_wrapper.c:259: intercept_disasm_next_instruction: Assertion `context->insn->detail->x86.op_count == 1' failed.
Aborted (core dumped)

I am using it with the following versions:

  • Ubuntu 18.04.4 LTS
  • 4.15.0-70-generic x86_64
  • GNU ld (GNU Binutils for Ubuntu) 2.30
  • gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

An compilation error

Hello,

I met an error when compiling your project, which is listed below:

make

......
[ 23%] Building ASM object test/CMakeFiles/executable_with_syscall_no_pie.dir/executable_with_syscall.S.o
/root/scylla/syscall_intercept-master/test/executable_with_syscall.S:72:1: error: unknown token in expression
add rsi, 8 # inc argv
^
make[2]: *** [test/CMakeFiles/executable_with_syscall_no_pie.dir/executable_with_syscall.S.o] Error 1
make[1]: *** [test/CMakeFiles/executable_with_syscall_no_pie.dir/all] Error 2
make: *** [all] Error 2

I've installed capstone and upgraded cmake to the version 3.3.2. However, I'm not sure if C99 toolchain has been configured already. When I run cmake, the output is list below:

-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= clang

-- The C compiler identification is Clang 3.4.2
-- The CXX compiler identification is GNU 4.8.5
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAS_WERROR
-- Performing Test HAS_WERROR - Success
-- Performing Test HAS_WALL
-- Performing Test HAS_WALL - Success
-- Performing Test HAS_WEXTRA
-- Performing Test HAS_WEXTRA - Success
-- Performing Test HAS_PEDANTIC
-- Performing Test HAS_PEDANTIC - Success
-- Performing Test HAS_NOMFI
-- Performing Test HAS_NOMFI - Success
-- Performing Test HAS_NO9099
-- Performing Test HAS_NO9099 - Failed
-- Performing Test LINKER_HAS_NOSTDLIB
-- Performing Test LINKER_HAS_NOSTDLIB - Success
-- Performing Test HAS_WLFATAL
-- Performing Test HAS_WLFATAL - Success
-- Performing Test HAS_NOUNUSEDARG
-- Performing Test HAS_NOUNUSEDARG - Success
-- Performing Test HAS_ARG_PIE
-- Performing Test HAS_ARG_PIE - Success
-- Performing Test HAS_ARG_NOPIE
-- Performing Test HAS_ARG_NOPIE - Success
-- Performing Test HAS_ARG_NO_PIE
-- Performing Test HAS_ARG_NO_PIE - Failed
-- Performing Test HAS_GCC_ATTR_CONSTR
-- Performing Test HAS_GCC_ATTR_CONSTR - Success
-- Performing Test HAS_GCC_PRAGMA_SYSH
-- Performing Test HAS_GCC_PRAGMA_SYSH - Success
-- Looking for include file elf.h
-- Looking for include file elf.h - found
-- Looking for dladdr
-- Looking for dladdr - found
-- Found Perl: /usr/bin/perl (found version "5.16.3")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /root/scylla/syscall_intercept-master/my_build_dir

Thank you!

Why isn't it transparent? Does it change some variables/functions related to a path?

Hello,

Great job for this library!

I am trying to filter only stat syscall with this code (called example.c):

[...]
    if (syscall_number == SYS_stat) {
        printf("###############intercepted stat syscall######## %s #######\n", arg0); // print the path
    }
    return 1; //Use the default kernel syscall
[...]

int stat(const char *path, struct stat *buf);

  1. I copy the file to the include folder to be in the same directory as libsyscall_intercept_hook_point.h
  2. I run cc -lsyscall_intercept -fpic -shared example.c -o example.so
  3. Using LD_PRELOAD=/tmp/example.so app => app crashes because it can't find some files

Why isn't it transparent? It seems the whole library changes some variables that is used in some apps to get a path.

Just a simple check was to export LD_PRELOAD and the git script for my PS1 of my terminal doesn't work anymore.

Thanks!

tests compilation error: restrict-qualified parameter

test/syscall_format.c:389:2: error: passing argument 2 to restrict-qualified parameter aliases with argument 5 [-Werror=restrict]
  select(2, p0, p1, p1, p0);
  ^~~~~~
test/syscall_format.c:389:2: error: passing argument 3 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]

Glibc tested version: 2.28
Gcc tested version: 8.2.1 20180831 (GCC)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.