1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/filter.h>
6 #include <linux/seccomp.h>
10 #include <sys/resource.h>
11 #include "trace_helpers.h"
13 /* install fake seccomp program to enable seccomp code path inside the kernel,
14 * so that our kprobe attached to seccomp_phase1() can be triggered
16 static void install_accept_all_seccomp(void)
18 struct sock_filter filter[] = {
19 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
21 struct sock_fprog prog = {
22 .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
25 if (prctl(PR_SET_SECCOMP, 2, &prog))
29 int main(int ac, char **argv)
33 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
35 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
36 setrlimit(RLIMIT_MEMLOCK, &r);
38 if (load_bpf_file(filename)) {
39 printf("%s", bpf_log_buf);
43 install_accept_all_seccomp();
45 f = popen("dd if=/dev/zero of=/dev/null count=5", "r");