Skip to content

Show exec-ed file name for OPEN_TREE_CLONE obtained rootdir #67

@kxxt

Description

@kxxt

Currently we show path fds obtained from operations with open_tree + OPEN_TREE_CLONE as / if they get used in a later execveat.

#define _GNU_SOURCE

#include <sched.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <unistd.h>
#include <fcntl.h> /* Definition of AT_* constants */

int open_tree(int dirfd, const char *pathname, unsigned int flags);
char *new_argv[] = {"I don't know why I am here", NULL};

extern char **environ;

int execveat(int dirfd, const char *pathname, char *const argv[],
    char *const envp[], int flags);

int main(int argc, char** argv) {
    if (unshare(CLONE_NEWNS|CLONE_NEWUSER)) {
        perror("unshare");
        return 1;
    }
    int path_fd = open_tree(-1, "/usr/bin/ls", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
    if (path_fd < 0) {
        perror("open tree");
        return 1;
    }
    // sleep(10086);
    execveat(path_fd, "", new_argv, environ, AT_EMPTY_PATH);
    perror("execveat");
    return 1;
}
$ tracexec log -- ./a.out
11046<tracer>: "/home/kxxt/repos/tracexec/fixtures/./a.out" ["./a.out"] fd [] with []
11046<a.out>: "/" ["I don't know why I am here"] fd [cloexec: 3="/"] with []

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions