/*
 * QEMU seccomp mode 2 support with libseccomp
 *
 * Copyright IBM, Corp. 2012
 *
 * Authors:
 *  Eduardo Otubo    <eotubo@br.ibm.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 * Contributions after 2012-01-13 are licensed under the terms of the
 * GNU GPL, version 2 or (at your option) any later version.
 */
#include <stdio.h>
#include <seccomp.h>
#include "sysemu/seccomp.h"

struct QemuSeccompSyscall {
    int32_t num;
    uint8_t priority;
};

static const struct QemuSeccompSyscall seccomp_whitelist[] = {
    { SCMP_SYS(timer_settime), 255 },
    { SCMP_SYS(timer_gettime), 254 },
    { SCMP_SYS(futex), 253 },
    { SCMP_SYS(select), 252 },
    { SCMP_SYS(recvfrom), 251 },
    { SCMP_SYS(sendto), 250 },
    { SCMP_SYS(socketcall), 250 },
    { SCMP_SYS(read), 249 },
    { SCMP_SYS(brk), 248 },
    { SCMP_SYS(clone), 247 },
    { SCMP_SYS(mmap), 247 },
    { SCMP_SYS(mprotect), 246 },
    { SCMP_SYS(execve), 245 },
    { SCMP_SYS(open), 245 },
    { SCMP_SYS(ioctl), 245 },
    { SCMP_SYS(socket), 245 },
    { SCMP_SYS(setsockopt), 245 },
    { SCMP_SYS(recvmsg), 245 },
    { SCMP_SYS(sendmsg), 245 },
    { SCMP_SYS(accept), 245 },
    { SCMP_SYS(connect), 245 },
    { SCMP_SYS(socketpair), 245 },
    { SCMP_SYS(bind), 245 },
    { SCMP_SYS(listen), 245 },
    { SCMP_SYS(semget), 245 },
    { SCMP_SYS(ipc), 245 },
    { SCMP_SYS(gettimeofday), 245 },
    { SCMP_SYS(readlink), 245 },
    { SCMP_SYS(access), 245 },
    { SCMP_SYS(prctl), 245 },
    { SCMP_SYS(signalfd), 245 },
    { SCMP_SYS(getrlimit), 245 },
    { SCMP_SYS(set_tid_address), 245 },
    { SCMP_SYS(statfs), 245 },
    { SCMP_SYS(unlink), 245 },
    { SCMP_SYS(wait4), 245 },
    { SCMP_SYS(fcntl64), 245 },
    { SCMP_SYS(fstat64), 245 },
    { SCMP_SYS(stat64), 245 },
    { SCMP_SYS(getgid32), 245 },
    { SCMP_SYS(getegid32), 245 },
    { SCMP_SYS(getuid32), 245 },
    { SCMP_SYS(geteuid32), 245 },
    { SCMP_SYS(sigreturn), 245 },
    { SCMP_SYS(_newselect), 245 },
    { SCMP_SYS(_llseek), 245 },
    { SCMP_SYS(mmap2), 245 },
    { SCMP_SYS(sigprocmask), 245 },
    { SCMP_SYS(sched_getparam), 245 },
    { SCMP_SYS(sched_getscheduler), 245 },
    { SCMP_SYS(fstat), 245 },
    { SCMP_SYS(clock_getres), 245 },
    { SCMP_SYS(sched_get_priority_min), 245 },
    { SCMP_SYS(sched_get_priority_max), 245 },
    { SCMP_SYS(stat), 245 },
    { SCMP_SYS(uname), 245 },
    { SCMP_SYS(eventfd2), 245 },
    { SCMP_SYS(io_getevents), 245 },
    { SCMP_SYS(dup), 245 },
    { SCMP_SYS(dup2), 245 },
    { SCMP_SYS(dup3), 245 },
    { SCMP_SYS(gettid), 245 },
    { SCMP_SYS(getgid), 245 },
    { SCMP_SYS(getegid), 245 },
    { SCMP_SYS(getuid), 245 },
    { SCMP_SYS(geteuid), 245 },
    { SCMP_SYS(timer_create), 245 },
    { SCMP_SYS(exit), 245 },
    { SCMP_SYS(clock_gettime), 245 },
    { SCMP_SYS(time), 245 },
    { SCMP_SYS(restart_syscall), 245 },
    { SCMP_SYS(pwrite64), 245 },
    { SCMP_SYS(nanosleep), 245 },
    { SCMP_SYS(chown), 245 },
    { SCMP_SYS(openat), 245 },
    { SCMP_SYS(getdents), 245 },
    { SCMP_SYS(timer_delete), 245 },
    { SCMP_SYS(exit_group), 245 },
    { SCMP_SYS(rt_sigreturn), 245 },
    { SCMP_SYS(sync), 245 },
    { SCMP_SYS(pread64), 245 },
    { SCMP_SYS(madvise), 245 },
    { SCMP_SYS(set_robust_list), 245 },
    { SCMP_SYS(lseek), 245 },
    { SCMP_SYS(pselect6), 245 },
    { SCMP_SYS(fork), 245 },
    { SCMP_SYS(rt_sigprocmask), 245 },
    { SCMP_SYS(write), 244 },
    { SCMP_SYS(fcntl), 243 },
    { SCMP_SYS(tgkill), 242 },
    { SCMP_SYS(rt_sigaction), 242 },
    { SCMP_SYS(pipe2), 242 },
    { SCMP_SYS(munmap), 242 },
    { SCMP_SYS(mremap), 242 },
    { SCMP_SYS(fdatasync), 242 },
    { SCMP_SYS(close), 242 },
    { SCMP_SYS(rt_sigpending), 242 },
    { SCMP_SYS(rt_sigtimedwait), 242 },
    { SCMP_SYS(readv), 242 },
    { SCMP_SYS(writev), 242 },
    { SCMP_SYS(preadv), 242 },
    { SCMP_SYS(pwritev), 242 },
    { SCMP_SYS(setrlimit), 242 },
    { SCMP_SYS(ftruncate), 242 },
    { SCMP_SYS(lstat), 242 },
    { SCMP_SYS(pipe), 242 },
    { SCMP_SYS(umask), 242 },
    { SCMP_SYS(chdir), 242 },
    { SCMP_SYS(setitimer), 242 },
    { SCMP_SYS(setsid), 242 },
    { SCMP_SYS(poll), 242 },
    { SCMP_SYS(epoll_create), 242 },
    { SCMP_SYS(epoll_ctl), 242 },
    { SCMP_SYS(epoll_wait), 242 },
    { SCMP_SYS(waitpid), 242 },
    { SCMP_SYS(getsockname), 242 },
    { SCMP_SYS(getpeername), 242 },
    { SCMP_SYS(accept4), 242 },
    { SCMP_SYS(newfstatat), 241 },
    { SCMP_SYS(shutdown), 241 },
    { SCMP_SYS(getsockopt), 241 },
    { SCMP_SYS(semop), 241 },
    { SCMP_SYS(semtimedop), 241 },
    { SCMP_SYS(epoll_ctl_old), 241 },
    { SCMP_SYS(epoll_wait_old), 241 },
    { SCMP_SYS(epoll_pwait), 241 },
    { SCMP_SYS(epoll_create1), 241 },
    { SCMP_SYS(ppoll), 241 },
    { SCMP_SYS(creat), 241 },
    { SCMP_SYS(link), 241 },
    { SCMP_SYS(getpid), 241 },
    { SCMP_SYS(getppid), 241 },
    { SCMP_SYS(getpgrp), 241 },
    { SCMP_SYS(getpgid), 241 },
    { SCMP_SYS(getsid), 241 },
    { SCMP_SYS(getdents64), 241 },
    { SCMP_SYS(getresuid), 241 },
    { SCMP_SYS(getresgid), 241 },
    { SCMP_SYS(getgroups), 241 },
    { SCMP_SYS(getresuid32), 241 },
    { SCMP_SYS(getresgid32), 241 },
    { SCMP_SYS(getgroups32), 241 },
    { SCMP_SYS(signal), 241 },
    { SCMP_SYS(sigaction), 241 },
    { SCMP_SYS(sigsuspend), 241 },
    { SCMP_SYS(sigpending), 241 },
    { SCMP_SYS(truncate64), 241 },
    { SCMP_SYS(ftruncate64), 241 },
    { SCMP_SYS(fchown32), 241 },
    { SCMP_SYS(chown32), 241 },
    { SCMP_SYS(lchown32), 241 },
    { SCMP_SYS(statfs64), 241 },
    { SCMP_SYS(fstatfs64), 241 },
    { SCMP_SYS(fstatat64), 241 },
    { SCMP_SYS(lstat64), 241 },
    { SCMP_SYS(sendfile64), 241 },
    { SCMP_SYS(ugetrlimit), 241 },
    { SCMP_SYS(alarm), 241 },
    { SCMP_SYS(rt_sigsuspend), 241 },
    { SCMP_SYS(rt_sigqueueinfo), 241 },
    { SCMP_SYS(rt_tgsigqueueinfo), 241 },
    { SCMP_SYS(sigaltstack), 241 },
    { SCMP_SYS(signalfd4), 241 },
    { SCMP_SYS(truncate), 241 },
    { SCMP_SYS(fchown), 241 },
    { SCMP_SYS(lchown), 241 },
    { SCMP_SYS(fchownat), 241 },
    { SCMP_SYS(fstatfs), 241 },
    { SCMP_SYS(getitimer), 241 },
    { SCMP_SYS(syncfs), 241 },
    { SCMP_SYS(fsync), 241 },
    { SCMP_SYS(fchdir), 241 },
    { SCMP_SYS(msync), 241 },
    { SCMP_SYS(sched_setparam), 241 },
    { SCMP_SYS(sched_setscheduler), 241 },
    { SCMP_SYS(sched_yield), 241 },
    { SCMP_SYS(sched_rr_get_interval), 241 },
    { SCMP_SYS(sched_setaffinity), 241 },
    { SCMP_SYS(sched_getaffinity), 241 },
    { SCMP_SYS(readahead), 241 },
    { SCMP_SYS(timer_getoverrun), 241 },
    { SCMP_SYS(unlinkat), 241 },
    { SCMP_SYS(readlinkat), 241 },
    { SCMP_SYS(faccessat), 241 },
    { SCMP_SYS(get_robust_list), 241 },
    { SCMP_SYS(splice), 241 },
    { SCMP_SYS(vmsplice), 241 },
    { SCMP_SYS(getcpu), 241 },
    { SCMP_SYS(sendmmsg), 241 },
    { SCMP_SYS(recvmmsg), 241 },
    { SCMP_SYS(prlimit64), 241 },
    { SCMP_SYS(waitid), 241 },
    { SCMP_SYS(io_setup), 241 },
    { SCMP_SYS(io_destroy), 241 }
};

int seccomp_start(void)
{
    int rc = 0;
    unsigned int i = 0;
    scmp_filter_ctx ctx;

    ctx = seccomp_init(SCMP_ACT_KILL);
    if (ctx == NULL) {
        goto seccomp_return;
    }

    for (i = 0; i < ARRAY_SIZE(seccomp_whitelist); i++) {
        rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, seccomp_whitelist[i].num, 0);
        if (rc < 0) {
            goto seccomp_return;
        }
        rc = seccomp_syscall_priority(ctx, seccomp_whitelist[i].num,
                                      seccomp_whitelist[i].priority);
        if (rc < 0) {
            goto seccomp_return;
        }
    }

    rc = seccomp_load(ctx);

  seccomp_return:
    seccomp_release(ctx);
    return rc;
}
