Eunomia
0.1.0
A lightweight eBPF-based CloudNative Monitor tool for Container Security and Observability
|
Go to the documentation of this file.
12 #ifndef _SECCOMP_BPF_H_
13 #define _SECCOMP_BPF_H_
24 #include <sys/prctl.h>
25 #ifndef PR_SET_NO_NEW_PRIVS
26 # define PR_SET_NO_NEW_PRIVS 38
29 #include <linux/unistd.h>
30 #include <linux/audit.h>
31 #include <linux/filter.h>
32 #ifdef HAVE_LINUX_SECCOMP_H
33 # include <linux/seccomp.h>
35 #ifndef SECCOMP_MODE_FILTER
36 # define SECCOMP_MODE_FILTER 2
37 # define SECCOMP_RET_KILL 0x00000000U
38 # define SECCOMP_RET_TRAP 0x00030000U
39 # define SECCOMP_RET_ALLOW 0x7fff0000U
48 # define SYS_SECCOMP 1
51 #define syscall_nr (offsetof(struct seccomp_data, nr))
52 #define arch_nr (offsetof(struct seccomp_data, arch))
55 # define REG_SYSCALL REG_EAX
56 # define ARCH_NR AUDIT_ARCH_I386
57 #elif defined(__x86_64__)
58 # define REG_SYSCALL REG_RAX
59 # define ARCH_NR AUDIT_ARCH_X86_64
61 # warning "Platform does not support seccomp filter yet"
62 # define REG_SYSCALL 0
66 #define VALIDATE_ARCHITECTURE \
67 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, arch_nr), \
68 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ARCH_NR, 1, 0), \
69 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
71 #define EXAMINE_SYSCALL \
72 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr)
74 #define ALLOW_SYSCALL(name) \
75 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
76 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)
78 #define KILL_PROCESS \
79 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
__u32 arch
Definition: seccomp-bpf.h:42
__u64 instruction_pointer
Definition: seccomp-bpf.h:43
int nr
Definition: seccomp-bpf.h:41
__u64 args[6]
Definition: seccomp-bpf.h:44
Definition: seccomp-bpf.h:40