|
Packit Service |
8eee21 |
/**
|
|
Packit Service |
8eee21 |
* Seccomp System Interfaces
|
|
Packit Service |
8eee21 |
*
|
|
Packit Service |
8eee21 |
* Copyright (c) 2012 Red Hat <pmoore@redhat.com>
|
|
Packit Service |
8eee21 |
* Author: Paul Moore <paul@paul-moore.com>
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/*
|
|
Packit Service |
8eee21 |
* This library is free software; you can redistribute it and/or modify it
|
|
Packit Service |
8eee21 |
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
Packit Service |
8eee21 |
* published by the Free Software Foundation.
|
|
Packit Service |
8eee21 |
*
|
|
Packit Service |
8eee21 |
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
8eee21 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit Service |
8eee21 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
Packit Service |
8eee21 |
* for more details.
|
|
Packit Service |
8eee21 |
*
|
|
Packit Service |
8eee21 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
8eee21 |
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#ifndef _SYSTEM_H
|
|
Packit Service |
8eee21 |
#define _SYSTEM_H
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#include <linux/filter.h>
|
|
Packit Service |
8eee21 |
#include <sys/prctl.h>
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#include "configure.h"
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* NOTE: this was taken from the Linux Kernel sources */
|
|
Packit Service |
8eee21 |
#define MAX_ERRNO 4095
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
struct db_filter_col;
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#ifdef HAVE_LINUX_SECCOMP_H
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* system header file */
|
|
Packit Service |
8eee21 |
#include <linux/seccomp.h>
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#else
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* NOTE: the definitions below were taken from the Linux Kernel sources */
|
|
Packit Service |
8eee21 |
#include <linux/types.h>
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* Valid values for seccomp.mode and prctl(PR_SET_SECCOMP, <mode>) */
|
|
Packit Service |
8eee21 |
#define SECCOMP_MODE_DISABLED 0 /* seccomp is not in use. */
|
|
Packit Service |
8eee21 |
#define SECCOMP_MODE_STRICT 1 /* uses hard-coded filter. */
|
|
Packit Service |
8eee21 |
#define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/*
|
|
Packit Service |
8eee21 |
* All BPF programs must return a 32-bit value.
|
|
Packit Service |
8eee21 |
* The bottom 16-bits are for optional return data.
|
|
Packit Service |
8eee21 |
* The upper 16-bits are ordered from least permissive values to most.
|
|
Packit Service |
8eee21 |
*
|
|
Packit Service |
8eee21 |
* The ordering ensures that a min_t() over composed return values always
|
|
Packit Service |
8eee21 |
* selects the least permissive choice.
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_KILL_PROCESS 0x80000000U /* kill the process immediately */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_KILL_THREAD 0x00000000U /* kill the thread immediately */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_KILL SECCOMP_RET_KILL_THREAD /* default to killing the thread */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_ERRNO 0x00050000U /* returns an errno */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_TRACE 0x7ff00000U /* pass to a tracer or disallow */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_LOG 0x7ffc0000U /* allow after logging */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* Masks for the return value sections. */
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_ACTION_FULL 0xffff0000U
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_ACTION 0x7fff0000U
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_DATA 0x0000ffffU
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/**
|
|
Packit Service |
8eee21 |
* struct seccomp_data - the format the BPF program executes over.
|
|
Packit Service |
8eee21 |
* @nr: the system call number
|
|
Packit Service |
8eee21 |
* @arch: indicates system call convention as an AUDIT_ARCH_* value
|
|
Packit Service |
8eee21 |
* as defined in <linux/audit.h>.
|
|
Packit Service |
8eee21 |
* @instruction_pointer: at the time of the system call.
|
|
Packit Service |
8eee21 |
* @args: up to 6 system call arguments always stored as 64-bit values
|
|
Packit Service |
8eee21 |
* regardless of the architecture.
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
struct seccomp_data {
|
|
Packit Service |
8eee21 |
int nr;
|
|
Packit Service |
8eee21 |
__u32 arch;
|
|
Packit Service |
8eee21 |
__u64 instruction_pointer;
|
|
Packit Service |
8eee21 |
__u64 args[6];
|
|
Packit Service |
8eee21 |
};
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#endif /* HAVE_LINUX_SECCOMP_H */
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* rename some of the socket filter types to make more sense */
|
|
Packit Service |
8eee21 |
typedef struct sock_filter bpf_instr_raw;
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* no new privs defintions */
|
|
Packit Service |
8eee21 |
#ifndef PR_SET_NO_NEW_PRIVS
|
|
Packit Service |
8eee21 |
#define PR_SET_NO_NEW_PRIVS 38
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#ifndef PR_GET_NO_NEW_PRIVS
|
|
Packit Service |
8eee21 |
#define PR_GET_NO_NEW_PRIVS 39
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* operations for the seccomp() syscall */
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_SET_MODE_STRICT
|
|
Packit Service |
8eee21 |
#define SECCOMP_SET_MODE_STRICT 0
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_SET_MODE_FILTER
|
|
Packit Service |
8eee21 |
#define SECCOMP_SET_MODE_FILTER 1
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_GET_ACTION_AVAIL
|
|
Packit Service |
8eee21 |
#define SECCOMP_GET_ACTION_AVAIL 2
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* flags for the seccomp() syscall */
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_FILTER_FLAG_TSYNC
|
|
Packit Service |
8eee21 |
#define SECCOMP_FILTER_FLAG_TSYNC (1UL << 0)
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_FILTER_FLAG_LOG
|
|
Packit Service |
8eee21 |
#define SECCOMP_FILTER_FLAG_LOG (1UL << 1)
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* SECCOMP_RET_ACTION_FULL was added in kernel v4.14. It may not be
|
|
Packit Service |
8eee21 |
* defined on older kernels
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_RET_ACTION_FULL
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_ACTION_FULL 0xffff0000U
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
/* SECCOMP_RET_LOG was added in kernel v4.14. It may not be defined on
|
|
Packit Service |
8eee21 |
* older kernels.
|
|
Packit Service |
8eee21 |
*/
|
|
Packit Service |
8eee21 |
#ifndef SECCOMP_RET_LOG
|
|
Packit Service |
8eee21 |
#define SECCOMP_RET_LOG 0x7fc00000U
|
|
Packit Service |
8eee21 |
#endif
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
int sys_chk_seccomp_syscall(void);
|
|
Packit Service |
8eee21 |
void sys_set_seccomp_syscall(bool enable);
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
int sys_chk_seccomp_action(uint32_t action);
|
|
Packit Service |
8eee21 |
void sys_set_seccomp_action(uint32_t action, bool enable);
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
int sys_chk_seccomp_flag(int flag);
|
|
Packit Service |
8eee21 |
void sys_set_seccomp_flag(int flag, bool enable);
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
int sys_filter_load(const struct db_filter_col *col);
|
|
Packit Service |
8eee21 |
|
|
Packit Service |
8eee21 |
#endif
|