Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_disco_events_generated_fd_event_tile_seccomp_h
3 : #define HEADER_fd_src_disco_events_generated_fd_event_tile_seccomp_h
4 :
5 : #if defined(__linux__)
6 :
7 : #include "../../../../src/util/fd_util_base.h"
8 : #include <linux/audit.h>
9 : #include <linux/capability.h>
10 : #include <linux/filter.h>
11 : #include <linux/seccomp.h>
12 : #include <linux/bpf.h>
13 : #include <linux/unistd.h>
14 : #include <sys/syscall.h>
15 : #include <signal.h>
16 : #include <stddef.h>
17 :
18 : #if defined(__i386__)
19 : # define ARCH_NR AUDIT_ARCH_I386
20 : #elif defined(__x86_64__)
21 : # define ARCH_NR AUDIT_ARCH_X86_64
22 : #elif defined(__aarch64__)
23 : # define ARCH_NR AUDIT_ARCH_AARCH64
24 : #else
25 : # error "Target architecture is unsupported by seccomp."
26 : #endif
27 : static const unsigned int sock_filter_policy_fd_event_tile_instr_cnt = 92;
28 :
29 0 : static void populate_sock_filter_policy_fd_event_tile( ulong out_cnt, struct sock_filter * out, unsigned int logfile_fd, uint etc_hosts_fd, uint etc_resolv_conf ) {
30 0 : FD_TEST( out_cnt >= 92 );
31 0 : struct sock_filter filter[92] = {
32 : /* Check: Jump to RET_KILL_PROCESS if the script's arch != the runtime arch */
33 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) ) ),
34 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 88 ),
35 : /* loading syscall number in accumulator */
36 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
37 : /* allow write based on expression */
38 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 14, 0 ),
39 : /* allow fsync based on expression */
40 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 17, 0 ),
41 : /* allow socket based on expression */
42 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_socket, /* check_socket */ 18, 0 ),
43 : /* allow bind based on expression */
44 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_bind, /* check_bind */ 21, 0 ),
45 : /* simply allow ppoll */
46 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ppoll, /* RET_ALLOW */ 83, 0 ),
47 : /* allow recvmsg based on expression */
48 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvmsg, /* check_recvmsg */ 23, 0 ),
49 : /* allow sendmsg based on expression */
50 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmsg, /* check_sendmsg */ 26, 0 ),
51 : /* allow connect based on expression */
52 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_connect, /* check_connect */ 31, 0 ),
53 : /* allow close based on expression */
54 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 38, 0 ),
55 : /* allow sendto based on expression */
56 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 45, 0 ),
57 : /* allow recvfrom based on expression */
58 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* check_recvfrom */ 54, 0 ),
59 : /* allow lseek based on expression */
60 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_lseek, /* check_lseek */ 63, 0 ),
61 : /* allow read based on expression */
62 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 70, 0 ),
63 : /* simply allow setsockopt */
64 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_setsockopt, /* RET_ALLOW */ 74, 0 ),
65 : /* none of the syscalls matched */
66 0 : { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 72 },
67 : // check_write:
68 : /* load syscall argument 0 in accumulator */
69 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
70 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_ALLOW */ 71, /* lbl_1 */ 0 ),
71 : // lbl_1:
72 : /* load syscall argument 0 in accumulator */
73 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
74 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 69, /* RET_KILL_PROCESS */ 68 ),
75 : // check_fsync:
76 : /* load syscall argument 0 in accumulator */
77 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
78 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 67, /* RET_KILL_PROCESS */ 66 ),
79 : // check_socket:
80 : /* load syscall argument 0 in accumulator */
81 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
82 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, AF_INET, /* lbl_2 */ 0, /* RET_KILL_PROCESS */ 64 ),
83 : // lbl_2:
84 : /* load syscall argument 2 in accumulator */
85 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
86 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* RET_ALLOW */ 63, /* RET_KILL_PROCESS */ 62 ),
87 : // check_bind:
88 : /* load syscall argument 2 in accumulator */
89 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
90 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, sizeof(struct sockaddr_in), /* RET_ALLOW */ 61, /* lbl_3 */ 0 ),
91 : // lbl_3:
92 : /* load syscall argument 2 in accumulator */
93 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
94 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, sizeof(struct sockaddr_in6), /* RET_ALLOW */ 59, /* RET_KILL_PROCESS */ 58 ),
95 : // check_recvmsg:
96 : /* load syscall argument 2 in accumulator */
97 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
98 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL|MSG_DONTWAIT, /* RET_ALLOW */ 57, /* lbl_4 */ 0 ),
99 : // lbl_4:
100 : /* load syscall argument 2 in accumulator */
101 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
102 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* RET_ALLOW */ 55, /* RET_KILL_PROCESS */ 54 ),
103 : // check_sendmsg:
104 : /* load syscall argument 2 in accumulator */
105 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
106 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL|MSG_DONTWAIT, /* RET_ALLOW */ 53, /* lbl_5 */ 0 ),
107 : // lbl_5:
108 : /* load syscall argument 2 in accumulator */
109 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
110 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_FASTOPEN|MSG_NOSIGNAL, /* RET_ALLOW */ 51, /* lbl_6 */ 0 ),
111 : // lbl_6:
112 : /* load syscall argument 2 in accumulator */
113 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
114 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 49, /* RET_KILL_PROCESS */ 48 ),
115 : // check_connect:
116 : /* load syscall argument 0 in accumulator */
117 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
118 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 46, /* lbl_7 */ 0 ),
119 : // lbl_7:
120 : /* load syscall argument 0 in accumulator */
121 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
122 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* RET_KILL_PROCESS */ 44, /* lbl_8 */ 0 ),
123 : // lbl_8:
124 : /* load syscall argument 0 in accumulator */
125 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
126 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* RET_KILL_PROCESS */ 42, /* lbl_9 */ 0 ),
127 : // lbl_9:
128 : /* load syscall argument 0 in accumulator */
129 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
130 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 40, /* RET_ALLOW */ 41 ),
131 : // check_close:
132 : /* load syscall argument 0 in accumulator */
133 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
134 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 38, /* lbl_10 */ 0 ),
135 : // lbl_10:
136 : /* load syscall argument 0 in accumulator */
137 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
138 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* RET_KILL_PROCESS */ 36, /* lbl_11 */ 0 ),
139 : // lbl_11:
140 : /* load syscall argument 0 in accumulator */
141 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
142 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* RET_KILL_PROCESS */ 34, /* lbl_12 */ 0 ),
143 : // lbl_12:
144 : /* load syscall argument 0 in accumulator */
145 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
146 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 32, /* RET_ALLOW */ 33 ),
147 : // check_sendto:
148 : /* load syscall argument 0 in accumulator */
149 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
150 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 30, /* lbl_14 */ 0 ),
151 : // lbl_14:
152 : /* load syscall argument 0 in accumulator */
153 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
154 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* RET_KILL_PROCESS */ 28, /* lbl_15 */ 0 ),
155 : // lbl_15:
156 : /* load syscall argument 0 in accumulator */
157 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
158 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* RET_KILL_PROCESS */ 26, /* lbl_16 */ 0 ),
159 : // lbl_16:
160 : /* load syscall argument 0 in accumulator */
161 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
162 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 24, /* lbl_13 */ 0 ),
163 : // lbl_13:
164 : /* load syscall argument 3 in accumulator */
165 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[3])),
166 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 23, /* RET_KILL_PROCESS */ 22 ),
167 : // check_recvfrom:
168 : /* load syscall argument 0 in accumulator */
169 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
170 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 20, /* lbl_18 */ 0 ),
171 : // lbl_18:
172 : /* load syscall argument 0 in accumulator */
173 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
174 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* RET_KILL_PROCESS */ 18, /* lbl_19 */ 0 ),
175 : // lbl_19:
176 : /* load syscall argument 0 in accumulator */
177 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
178 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* RET_KILL_PROCESS */ 16, /* lbl_20 */ 0 ),
179 : // lbl_20:
180 : /* load syscall argument 0 in accumulator */
181 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
182 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 14, /* lbl_17 */ 0 ),
183 : // lbl_17:
184 : /* load syscall argument 3 in accumulator */
185 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[3])),
186 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 13, /* RET_KILL_PROCESS */ 12 ),
187 : // check_lseek:
188 : /* load syscall argument 0 in accumulator */
189 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
190 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* lbl_21 */ 2, /* lbl_22 */ 0 ),
191 : // lbl_22:
192 : /* load syscall argument 0 in accumulator */
193 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
194 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* lbl_21 */ 0, /* RET_KILL_PROCESS */ 8 ),
195 : // lbl_21:
196 : /* load syscall argument 1 in accumulator */
197 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
198 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* lbl_23 */ 0, /* RET_KILL_PROCESS */ 6 ),
199 : // lbl_23:
200 : /* load syscall argument 2 in accumulator */
201 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
202 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SEEK_SET, /* RET_ALLOW */ 5, /* RET_KILL_PROCESS */ 4 ),
203 : // check_read:
204 : /* load syscall argument 0 in accumulator */
205 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
206 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* RET_ALLOW */ 3, /* lbl_24 */ 0 ),
207 : // lbl_24:
208 : /* load syscall argument 0 in accumulator */
209 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
210 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* RET_ALLOW */ 1, /* RET_KILL_PROCESS */ 0 ),
211 : // RET_KILL_PROCESS:
212 : /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
213 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
214 : // RET_ALLOW:
215 : /* ALLOW has to be reached by jumping */
216 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
217 0 : };
218 0 : fd_memcpy( out, filter, sizeof( filter ) );
219 0 : }
220 :
221 : #endif /* defined(__linux__) */
222 :
223 : #endif /* HEADER_fd_src_disco_events_generated_fd_event_tile_seccomp_h */
|