Unverified Commit 0086eaa6 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Partial fix for post clone inconsistency

parent 7976f782
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -687,10 +687,14 @@ hook_clone_at_child(unsigned long flags,
        0};
#endif

    reentrance_guard_flag = true;

    LOG(SYSCALL, 
        ::get_current_syscall_info() | 
        gkfs::syscall::executed, 
        SYS_clone, args, 0);

    reentrance_guard_flag = false;
}

static void
@@ -711,10 +715,14 @@ hook_clone_at_parent(unsigned long flags,
        0};
#endif

    reentrance_guard_flag = true;

    LOG(SYSCALL, 
        ::get_current_syscall_info() | 
        gkfs::syscall::executed, 
        SYS_clone, args, returned_pid);

    reentrance_guard_flag = false;
}


+6 −3
Original line number Diff line number Diff line
@@ -192,13 +192,14 @@ bool PreloadContext::interception_enabled() const {

int PreloadContext::register_internal_fd(int fd) {

    LOG(DEBUG, "registering fd {} as internal", fd);

    assert(fd >= 0);

    std::lock_guard<std::mutex> lock(internal_fds_mutex_);
    const int pos = internal_fds_._Find_first();
    internal_fds_.reset(pos);

    LOG(DEBUG, "registering internal fd: {} -> {}", fd, pos + INTERNAL_FD_BASE);

#if !defined(GKFS_DISABLE_LOGGING) && defined(GKFS_DEBUG_BUILD)
    long args[gkfs::syscall::MAX_ARGS]{fd, pos + INTERNAL_FD_BASE, O_CLOEXEC};
@@ -243,19 +244,21 @@ int PreloadContext::register_internal_fd(int fd) {
        gkfs::syscall::executed, 
        SYS_close, args2, rv);

    LOG(DEBUG, "    (fd {} reassigned to ifd {})", fd, ifd);

    return ifd;
}

void PreloadContext::unregister_internal_fd(int fd) {

    LOG(DEBUG, "unregistering internal fd {}", fd);

    assert(fd >= INTERNAL_FD_BASE);

    const auto pos = fd - INTERNAL_FD_BASE;

    std::lock_guard<std::mutex> lock(internal_fds_mutex_);
    internal_fds_.set(pos);

    LOG(DEBUG, "unregistering internal fd: {}", fd);
}

bool PreloadContext::is_internal_fd(int fd) const {