4 #include <linux/filter.h>
5 #include <linux/seccomp.h>
9 #include <sys/resource.h>
11 /* install fake seccomp program to enable seccomp code path inside the kernel,
12 * so that our kprobe attached to seccomp_phase1() can be triggered
14 static void install_accept_all_seccomp(void)
16 struct sock_filter filter[] = {
17 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
19 struct sock_fprog prog = {
20 .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
23 if (prctl(PR_SET_SECCOMP, 2, &prog))
27 int main(int ac, char **argv)
31 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
33 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
34 setrlimit(RLIMIT_MEMLOCK, &r);
36 if (load_bpf_file(filename)) {
37 printf("%s", bpf_log_buf);
41 install_accept_all_seccomp();
43 f = popen("dd if=/dev/zero of=/dev/null count=5", "r");