Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_discof_genesis_generated_fd_genesi_tile_seccomp_h
3 : #define HEADER_fd_src_discof_genesis_generated_fd_genesi_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 :
28 : #define FD_SECCOMP_ARG_LO_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) )
29 : #define FD_SECCOMP_ARG_HI_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) + 4U )
30 :
31 : #define FD_SECCOMP_ARG_LO(x) ((uint)(((ulong)(uint)(int)(x) ) & 0xffffffffUL))
32 : #define FD_SECCOMP_ARG_HI(x) ((uint)(((ulong)(x) >> 32) & 0xffffffffUL))
33 :
34 : static const uint sock_filter_policy_fd_genesi_tile_instr_cnt = 114;
35 :
36 0 : static void populate_sock_filter_policy_fd_genesi_tile( ulong out_cnt, struct sock_filter out[ static 114 ], uint logfile_fd, uint in_genesis_fd, uint out_genesis_fd, uint out_dir_fd, uint accounts_fd ) {
37 0 : FD_TEST( out_cnt >= 114 );
38 0 : struct sock_filter filter[114] = {
39 : /* validate architecture */
40 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) )),
41 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 14 ),
42 : /* load syscall number */
43 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) )),
44 : /* check write */
45 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 14, 0 ),
46 : /* check fsync */
47 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 21, 0 ),
48 : /* check fstat */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fstat, /* check_fstat */ 24, 0 ),
50 : /* check close */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 27, 0 ),
52 : /* check read */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 36, 0 ),
54 : /* check exit */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_exit, /* check_exit */ 39, 0 ),
56 : /* check pwritev2 */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_pwritev2, /* check_pwritev2 */ 42, 0 ),
58 : /* check preadv2 */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_preadv2, /* check_preadv2 */ 45, 0 ),
60 : /* check fallocate */
61 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fallocate, /* check_fallocate */ 48, 0 ),
62 : /* allow ppoll */
63 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ppoll, /* RET_ALLOW */ 4, 0 ),
64 : /* check sendto */
65 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 52, 0 ),
66 : /* check recvfrom */
67 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* check_recvfrom */ 71, 0 ),
68 : /* check renameat2 */
69 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_renameat2, /* check_renameat2 */ 92, 0 ),
70 : // RET_KILL_PROCESS:
71 : /* default deny */
72 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
73 : // RET_ALLOW:
74 : /* allow */
75 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
76 : // check_write:
77 : /* arg 0 low 32 bits */
78 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
79 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 5, /* or_1 */ 0 ),
80 : // or_1:
81 : /* arg 0 low 32 bits */
82 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
83 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_genesis_fd)), /* write_ALLOW */ 3, /* or_2 */ 0 ),
84 : // or_2:
85 : /* arg 0 low 32 bits */
86 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
87 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
88 : // write_KILL:
89 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
90 : // write_ALLOW:
91 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
92 : // check_fsync:
93 : /* arg 0 low 32 bits */
94 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
95 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
96 : // fsync_KILL:
97 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
98 : // fsync_ALLOW:
99 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
100 : // check_fstat:
101 : /* arg 0 low 32 bits */
102 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
103 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(in_genesis_fd)), /* fstat_ALLOW */ 1, /* fstat_KILL */ 0 ),
104 : // fstat_KILL:
105 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
106 : // fstat_ALLOW:
107 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
108 : // check_close:
109 : /* arg 0 low 32 bits */
110 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
111 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* close_KILL */ 6, /* or_3 */ 0 ),
112 : // or_3:
113 : /* arg 0 low 32 bits */
114 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
115 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_dir_fd)), /* close_KILL */ 4, /* or_4 */ 0 ),
116 : // or_4:
117 : /* arg 0 low 32 bits */
118 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
119 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_genesis_fd)), /* close_KILL */ 2, /* or_5 */ 0 ),
120 : // or_5:
121 : /* arg 0 low 32 bits */
122 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
123 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* close_KILL */ 0, /* close_ALLOW */ 1 ),
124 : // close_KILL:
125 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
126 : // close_ALLOW:
127 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
128 : // check_read:
129 : /* arg 0 low 32 bits */
130 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
131 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(in_genesis_fd)), /* read_ALLOW */ 1, /* read_KILL */ 0 ),
132 : // read_KILL:
133 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
134 : // read_ALLOW:
135 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
136 : // check_exit:
137 : /* arg 0 low 32 bits */
138 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
139 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* exit_ALLOW */ 1, /* exit_KILL */ 0 ),
140 : // exit_KILL:
141 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
142 : // exit_ALLOW:
143 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
144 : // check_pwritev2:
145 : /* arg 0 low 32 bits */
146 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
147 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(accounts_fd)), /* pwritev2_ALLOW */ 1, /* pwritev2_KILL */ 0 ),
148 : // pwritev2_KILL:
149 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
150 : // pwritev2_ALLOW:
151 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
152 : // check_preadv2:
153 : /* arg 0 low 32 bits */
154 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
155 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(accounts_fd)), /* preadv2_ALLOW */ 1, /* preadv2_KILL */ 0 ),
156 : // preadv2_KILL:
157 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
158 : // preadv2_ALLOW:
159 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
160 : // check_fallocate:
161 : /* arg 0 low 32 bits */
162 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
163 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(accounts_fd)), /* and_6 */ 0, /* fallocate_KILL */ 2 ),
164 : // and_6:
165 : /* arg 1 low 32 bits */
166 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
167 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* fallocate_ALLOW */ 1, /* fallocate_KILL */ 0 ),
168 : // fallocate_KILL:
169 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
170 : // fallocate_ALLOW:
171 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
172 : // check_sendto:
173 : /* arg 0 low 32 bits */
174 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
175 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* sendto_KILL */ 16, /* or_8 */ 0 ),
176 : // or_8:
177 : /* arg 0 low 32 bits */
178 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
179 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(in_genesis_fd)), /* sendto_KILL */ 14, /* or_9 */ 0 ),
180 : // or_9:
181 : /* arg 0 low 32 bits */
182 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
183 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_dir_fd)), /* sendto_KILL */ 12, /* or_10 */ 0 ),
184 : // or_10:
185 : /* arg 0 low 32 bits */
186 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
187 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_genesis_fd)), /* sendto_KILL */ 10, /* or_11 */ 0 ),
188 : // or_11:
189 : /* arg 0 low 32 bits */
190 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
191 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* sendto_KILL */ 8, /* and_7 */ 0 ),
192 : // and_7:
193 : /* arg 3 low 32 bits */
194 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
195 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_NOSIGNAL), /* and_12 */ 0, /* sendto_KILL */ 6 ),
196 : // and_12:
197 : /* arg 4 high 32 bits */
198 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
199 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_14 */ 0, /* sendto_KILL */ 4 ),
200 : // arg_hi_eq_14:
201 : /* arg 4 low 32 bits */
202 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
203 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_13 */ 0, /* sendto_KILL */ 2 ),
204 : // and_13:
205 : /* arg 5 low 32 bits */
206 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
207 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
208 : // sendto_KILL:
209 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
210 : // sendto_ALLOW:
211 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
212 : // check_recvfrom:
213 : /* arg 0 low 32 bits */
214 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
215 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* recvfrom_KILL */ 18, /* or_16 */ 0 ),
216 : // or_16:
217 : /* arg 0 low 32 bits */
218 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
219 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(in_genesis_fd)), /* recvfrom_KILL */ 16, /* or_17 */ 0 ),
220 : // or_17:
221 : /* arg 0 low 32 bits */
222 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
223 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_dir_fd)), /* recvfrom_KILL */ 14, /* or_18 */ 0 ),
224 : // or_18:
225 : /* arg 0 low 32 bits */
226 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
227 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_genesis_fd)), /* recvfrom_KILL */ 12, /* or_19 */ 0 ),
228 : // or_19:
229 : /* arg 0 low 32 bits */
230 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
231 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* recvfrom_KILL */ 10, /* and_15 */ 0 ),
232 : // and_15:
233 : /* arg 3 low 32 bits */
234 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
235 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_20 */ 0, /* recvfrom_KILL */ 8 ),
236 : // and_20:
237 : /* arg 4 high 32 bits */
238 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
239 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_22 */ 0, /* recvfrom_KILL */ 6 ),
240 : // arg_hi_eq_22:
241 : /* arg 4 low 32 bits */
242 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
243 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_21 */ 0, /* recvfrom_KILL */ 4 ),
244 : // and_21:
245 : /* arg 5 high 32 bits */
246 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(5)),
247 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_23 */ 0, /* recvfrom_KILL */ 2 ),
248 : // arg_hi_eq_23:
249 : /* arg 5 low 32 bits */
250 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
251 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* recvfrom_ALLOW */ 1, /* recvfrom_KILL */ 0 ),
252 : // recvfrom_KILL:
253 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
254 : // recvfrom_ALLOW:
255 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
256 : // check_renameat2:
257 : /* arg 0 low 32 bits */
258 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
259 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_dir_fd)), /* and_24 */ 0, /* renameat2_KILL */ 2 ),
260 : // and_24:
261 : /* arg 2 low 32 bits */
262 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
263 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(out_dir_fd)), /* renameat2_ALLOW */ 1, /* renameat2_KILL */ 0 ),
264 : // renameat2_KILL:
265 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
266 : // renameat2_ALLOW:
267 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
268 0 : };
269 0 : fd_memcpy( out, filter, sizeof( filter ) );
270 0 : }
271 :
272 : #endif /* defined(__linux__) */
273 :
274 : #endif /* HEADER_fd_src_discof_genesis_generated_fd_genesi_tile_seccomp_h */
|