Resolve "missing libc interception functions may lead to silently working calls"

Closes #357 (closed)

Merge request reports

Loading
+2 −0
Changes for include/client/env.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ static constexpr auto PROTECT_FILES_GENERATOR =
        ADD_PREFIX("PROTECT_FILES_GENERATOR");
static constexpr auto PROTECT_FILES_CONSUMER =
        ADD_PREFIX("PROTECT_FILES_CONSUMER");
static constexpr auto RANGE_FD = ADD_PREFIX("RANGE_FD");

static constexpr auto NUM_REPL = ADD_PREFIX("NUM_REPL");
static constexpr auto PROXY_PID_FILE = ADD_PREFIX("PROXY_PID_FILE");
namespace cache {
+8 −0
Changes for include/client/preload_context.hpp: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@ private:
    bool protect_fds_{false};
    bool protect_files_generator_{false};
    bool protect_files_consumer_{false};
    bool range_fd_{false};


    std::shared_ptr<gkfs::messagepack::ClientMetrics> write_metrics_;
    std::shared_ptr<gkfs::messagepack::ClientMetrics> read_metrics_;
@@ -336,6 +338,12 @@ public:
    void
    protect_files_consumer(bool protect);

    bool
    range_fd() const;

    void
    range_fd(bool fd);

    const std::shared_ptr<gkfs::messagepack::ClientMetrics>
    write_metrics();

+14 −1
Changes for src/client/open_file_map.cpp: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -162,7 +162,16 @@ OpenFileMap::safe_generate_fd_idx_() {
            }
        }
    } else {
        // Some architectures do not support SYS_open
        // Return a virtual fd from 10000, but avoid doing all the FD movements
        if(CTX->range_fd()) {
            if(fd_validation_needed) {
                while(exist(fd)) {
                    fd = generate_fd_idx();
                }
            }
            return fd;
        }

        fd = syscall_no_intercept(SYS_openat, AT_FDCWD, "/dev/null", O_RDWR,
                                  S_IRUSR | S_IWUSR);
    }
@@ -185,9 +194,13 @@ OpenFileMap::remove(const int fd) {
        return false;
    }
    files_.erase(fd);

    if(!CTX->protect_fds()) {
        if(!CTX->range_fd()) {
            // We close the dev null fd
            close(fd);
            return true;
        }
    }
    if(fd_validation_needed && files_.empty()) {
        fd_validation_needed = false;
+5 −0
Changes for src/client/preload.cpp: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -398,6 +398,11 @@ init_preload() {
    if(gkfs::env::var_is_set(gkfs::env::PROTECT_FD)) {
        CTX->protect_fds(true);
        LOG(INFO, "Protecting user fds");
    } else {
        // Another alternative is to use start issuing fds from gekko from a
        // offset. but without protecting the FDs
        CTX->range_fd(gkfs::env::var_is_set(gkfs::env::RANGE_FD));
        LOG(INFO, "Moving FDs to range");
    }

    if(CTX->protect_fds()) {
+10 −0
Changes for src/client/preload_context.cpp: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -677,6 +677,16 @@ PreloadContext::protect_files_consumer(bool protect) {
    protect_files_consumer_ = protect;
}

bool
PreloadContext::range_fd() const {
    return range_fd_;
}

void
PreloadContext::range_fd(bool fd) {
    range_fd_ = fd;
}


const std::shared_ptr<messagepack::ClientMetrics>
PreloadContext::write_metrics() {
Loading
Loading