Loading hermes @ 0c62b331 Compare 32356080 to 0c62b331 Original line number Diff line number Diff line Subproject commit 32356080bcb1b089957252e25ff3dceb715b572b Subproject commit 0c62b3319e660a5a30d0ad24a8ddaec8924b6388 scripts/compile_dep.sh +9 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,15 @@ fi # Mercury if [[ ( "${DEPENDENCY}" == "" ) || ( "${DEPENDENCY}" == "mercury" ) ]]; then if [ "$NA_LAYER" == "bmi" ] || [ "$NA_LAYER" == "all" ]; then USE_BMI="-DNA_USE_BMI:BOOL=ON" fi if [ "$NA_LAYER" == "ofi" ] || [ "$NA_LAYER" == "all" ]; then USE_OFI="-DNA_USE_OFI:BOOL=ON" fi echo "############################################################ Installing: Mercury" CURR=${SOURCE}/mercury prepare_build_dir ${CURR} Loading src/client/intercept.cpp +75 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ #include <syscall.h> #include <errno.h> #include <boost/optional.hpp> #include <sys/types.h> #include <sys/socket.h> #include <printf.h> Loading Loading @@ -283,6 +285,67 @@ hook_internal(long syscall_number, break; case SYS_eventfd: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0)); if(*result >= 0) { *result = CTX->register_internal_fd(*result); } break; case SYS_eventfd2: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), static_cast<int>(arg1)); if(*result >= 0) { *result = CTX->register_internal_fd(*result); } break; case SYS_recvmsg: { *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), reinterpret_cast<struct msghdr*>(arg1), static_cast<int>(arg2)); // The recvmsg() syscall can receive file descriptors from another // process that the kernel automatically adds to the client's fds // as if dup2 had been called. Whenever that happens, we need to // make sure that we register these additional fds as internal, or // we could inadvertently overwrite them if(*result >= 0) { auto* hdr = reinterpret_cast<struct msghdr*>(arg1); struct cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); for(; cmsg != NULL; cmsg = CMSG_NXTHDR(hdr, cmsg)) { if(cmsg->cmsg_type == SCM_RIGHTS) { size_t nfd = cmsg->cmsg_len > CMSG_LEN(0) ? (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int) : 0; int* fds = reinterpret_cast<int*>(CMSG_DATA(cmsg)); for(size_t i = 0; i < nfd; ++i) { LOG(DEBUG, "recvmsg() provided extra fd {}", fds[i]); // ensure we update the fds in cmsg // if they have been relocated fds[i] = CTX->register_internal_fd(fds[i]); } } } } break; } case SYS_accept: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), Loading @@ -294,6 +357,18 @@ hook_internal(long syscall_number, } break; case SYS_fcntl: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), static_cast<int>(arg1), arg2); if(*result >= 0 && (static_cast<int>(arg1) == F_DUPFD || static_cast<int>(arg1) == F_DUPFD_CLOEXEC)) { *result = CTX->register_internal_fd(*result); } break; case SYS_close: *result = syscall_no_intercept(syscall_number, Loading src/client/preload_util.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,8 @@ void load_hosts() { CTX->local_host_id(id); local_host_found = true; } LOG(DEBUG, "Found peer: {}", addrs[id].to_string()); } if (!local_host_found) { Loading Loading
hermes @ 0c62b331 Compare 32356080 to 0c62b331 Original line number Diff line number Diff line Subproject commit 32356080bcb1b089957252e25ff3dceb715b572b Subproject commit 0c62b3319e660a5a30d0ad24a8ddaec8924b6388
scripts/compile_dep.sh +9 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,15 @@ fi # Mercury if [[ ( "${DEPENDENCY}" == "" ) || ( "${DEPENDENCY}" == "mercury" ) ]]; then if [ "$NA_LAYER" == "bmi" ] || [ "$NA_LAYER" == "all" ]; then USE_BMI="-DNA_USE_BMI:BOOL=ON" fi if [ "$NA_LAYER" == "ofi" ] || [ "$NA_LAYER" == "all" ]; then USE_OFI="-DNA_USE_OFI:BOOL=ON" fi echo "############################################################ Installing: Mercury" CURR=${SOURCE}/mercury prepare_build_dir ${CURR} Loading
src/client/intercept.cpp +75 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ #include <syscall.h> #include <errno.h> #include <boost/optional.hpp> #include <sys/types.h> #include <sys/socket.h> #include <printf.h> Loading Loading @@ -283,6 +285,67 @@ hook_internal(long syscall_number, break; case SYS_eventfd: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0)); if(*result >= 0) { *result = CTX->register_internal_fd(*result); } break; case SYS_eventfd2: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), static_cast<int>(arg1)); if(*result >= 0) { *result = CTX->register_internal_fd(*result); } break; case SYS_recvmsg: { *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), reinterpret_cast<struct msghdr*>(arg1), static_cast<int>(arg2)); // The recvmsg() syscall can receive file descriptors from another // process that the kernel automatically adds to the client's fds // as if dup2 had been called. Whenever that happens, we need to // make sure that we register these additional fds as internal, or // we could inadvertently overwrite them if(*result >= 0) { auto* hdr = reinterpret_cast<struct msghdr*>(arg1); struct cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); for(; cmsg != NULL; cmsg = CMSG_NXTHDR(hdr, cmsg)) { if(cmsg->cmsg_type == SCM_RIGHTS) { size_t nfd = cmsg->cmsg_len > CMSG_LEN(0) ? (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int) : 0; int* fds = reinterpret_cast<int*>(CMSG_DATA(cmsg)); for(size_t i = 0; i < nfd; ++i) { LOG(DEBUG, "recvmsg() provided extra fd {}", fds[i]); // ensure we update the fds in cmsg // if they have been relocated fds[i] = CTX->register_internal_fd(fds[i]); } } } } break; } case SYS_accept: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), Loading @@ -294,6 +357,18 @@ hook_internal(long syscall_number, } break; case SYS_fcntl: *result = syscall_no_intercept(syscall_number, static_cast<int>(arg0), static_cast<int>(arg1), arg2); if(*result >= 0 && (static_cast<int>(arg1) == F_DUPFD || static_cast<int>(arg1) == F_DUPFD_CLOEXEC)) { *result = CTX->register_internal_fd(*result); } break; case SYS_close: *result = syscall_no_intercept(syscall_number, Loading
src/client/preload_util.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,8 @@ void load_hosts() { CTX->local_host_id(id); local_host_found = true; } LOG(DEBUG, "Found peer: {}", addrs[id].to_string()); } if (!local_host_found) { Loading