Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_disco_gui_generated_fd_gui_tile_seccomp_h
3 : #define HEADER_fd_src_disco_gui_generated_fd_gui_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 : #elif defined(__riscv) && __riscv_xlen == 64
25 : # define ARCH_NR AUDIT_ARCH_RISCV64
26 : #else
27 : # error "Target architecture is unsupported by seccomp."
28 : #endif
29 :
30 : #define FD_SECCOMP_ARG_LO_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) )
31 : #define FD_SECCOMP_ARG_HI_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) + 4U )
32 :
33 : #define FD_SECCOMP_ARG_LO(x) ((uint)(((ulong)(uint)(int)(x) ) & 0xffffffffUL))
34 : #define FD_SECCOMP_ARG_HI(x) ((uint)(((ulong)(x) >> 32) & 0xffffffffUL))
35 :
36 : static const uint sock_filter_policy_fd_gui_tile_instr_cnt = 111;
37 :
38 0 : static void populate_sock_filter_policy_fd_gui_tile( ulong out_cnt, struct sock_filter out[ static 111 ], uint logfile_fd, uint gui_socket_fd, uint db_fd, uint epoll_inner_fd, uint epoll_outer_fd ) {
39 0 : FD_TEST( out_cnt >= 111 );
40 0 : struct sock_filter filter[111] = {
41 : /* validate architecture */
42 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) )),
43 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 13 ),
44 : /* load syscall number */
45 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) )),
46 : /* check write */
47 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 13, 0 ),
48 : /* check fsync */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 18, 0 ),
50 : /* check accept4 */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_accept4, /* check_accept4 */ 21, 0 ),
52 : /* check read */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 34, 0 ),
54 : /* check sendto */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 43, 0 ),
56 : /* check sendmsg */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmsg, /* check_sendmsg */ 52, 0 ),
58 : /* check close */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 63, 0 ),
60 : /* check fallocate */
61 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fallocate, /* check_fallocate */ 72, 0 ),
62 : /* check epoll_pwait */
63 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_pwait, /* check_epoll_pwait */ 77, 0 ),
64 : /* check epoll_ctl */
65 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_ctl, /* check_epoll_ctl */ 84, 0 ),
66 : /* check futex */
67 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_futex, /* check_futex */ 91, 0 ),
68 : /* allow restart_syscall */
69 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_restart_syscall, /* RET_ALLOW */ 1, 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 */ 3, /* 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)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
84 : // write_KILL:
85 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
86 : // write_ALLOW:
87 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
88 : // check_fsync:
89 : /* arg 0 low 32 bits */
90 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
91 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
92 : // fsync_KILL:
93 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
94 : // fsync_ALLOW:
95 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
96 : // check_accept4:
97 : /* arg 0 low 32 bits */
98 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
99 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(gui_socket_fd)), /* and_2 */ 0, /* accept4_KILL */ 10 ),
100 : // and_2:
101 : /* arg 1 high 32 bits */
102 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(1)),
103 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_4 */ 0, /* accept4_KILL */ 8 ),
104 : // arg_hi_eq_4:
105 : /* arg 1 low 32 bits */
106 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
107 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_3 */ 0, /* accept4_KILL */ 6 ),
108 : // and_3:
109 : /* arg 2 high 32 bits */
110 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(2)),
111 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_6 */ 0, /* accept4_KILL */ 4 ),
112 : // arg_hi_eq_6:
113 : /* arg 2 low 32 bits */
114 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
115 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_5 */ 0, /* accept4_KILL */ 2 ),
116 : // and_5:
117 : /* arg 3 low 32 bits */
118 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
119 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SOCK_CLOEXEC|SOCK_NONBLOCK), /* accept4_ALLOW */ 1, /* accept4_KILL */ 0 ),
120 : // accept4_KILL:
121 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
122 : // accept4_ALLOW:
123 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
124 : // check_read:
125 : /* arg 0 low 32 bits */
126 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
127 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* read_KILL */ 6, /* or_7 */ 0 ),
128 : // or_7:
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)(logfile_fd)), /* read_KILL */ 4, /* or_8 */ 0 ),
132 : // or_8:
133 : /* arg 0 low 32 bits */
134 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
135 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(gui_socket_fd)), /* read_KILL */ 2, /* or_9 */ 0 ),
136 : // or_9:
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, ((uint)(db_fd)), /* read_KILL */ 0, /* read_ALLOW */ 1 ),
140 : // read_KILL:
141 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
142 : // read_ALLOW:
143 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
144 : // check_sendto:
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, 0x00000002U, /* sendto_KILL */ 6, /* or_10 */ 0 ),
148 : // or_10:
149 : /* arg 0 low 32 bits */
150 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
151 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* sendto_KILL */ 4, /* or_11 */ 0 ),
152 : // or_11:
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)(gui_socket_fd)), /* sendto_KILL */ 2, /* or_12 */ 0 ),
156 : // or_12:
157 : /* arg 0 low 32 bits */
158 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
159 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(db_fd)), /* sendto_KILL */ 0, /* sendto_ALLOW */ 1 ),
160 : // sendto_KILL:
161 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
162 : // sendto_ALLOW:
163 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
164 : // check_sendmsg:
165 : /* arg 0 low 32 bits */
166 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
167 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* sendmsg_KILL */ 8, /* or_14 */ 0 ),
168 : // or_14:
169 : /* arg 0 low 32 bits */
170 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
171 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* sendmsg_KILL */ 6, /* or_15 */ 0 ),
172 : // or_15:
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)(gui_socket_fd)), /* sendmsg_KILL */ 4, /* or_16 */ 0 ),
176 : // or_16:
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)(db_fd)), /* sendmsg_KILL */ 2, /* and_13 */ 0 ),
180 : // and_13:
181 : /* arg 2 low 32 bits */
182 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
183 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_NOSIGNAL), /* sendmsg_ALLOW */ 1, /* sendmsg_KILL */ 0 ),
184 : // sendmsg_KILL:
185 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
186 : // sendmsg_ALLOW:
187 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
188 : // check_close:
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, /* close_KILL */ 6, /* or_17 */ 0 ),
192 : // or_17:
193 : /* arg 0 low 32 bits */
194 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
195 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* close_KILL */ 4, /* or_18 */ 0 ),
196 : // or_18:
197 : /* arg 0 low 32 bits */
198 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
199 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(gui_socket_fd)), /* close_KILL */ 2, /* or_19 */ 0 ),
200 : // or_19:
201 : /* arg 0 low 32 bits */
202 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
203 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(db_fd)), /* close_KILL */ 0, /* close_ALLOW */ 1 ),
204 : // close_KILL:
205 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
206 : // close_ALLOW:
207 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
208 : // check_fallocate:
209 : /* arg 0 low 32 bits */
210 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
211 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(db_fd)), /* and_20 */ 0, /* fallocate_KILL */ 2 ),
212 : // and_20:
213 : /* arg 1 low 32 bits */
214 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
215 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* fallocate_ALLOW */ 1, /* fallocate_KILL */ 0 ),
216 : // fallocate_KILL:
217 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
218 : // fallocate_ALLOW:
219 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
220 : // check_epoll_pwait:
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)(epoll_inner_fd)), /* and_21 */ 0, /* epoll_pwait_KILL */ 4 ),
224 : // and_21:
225 : /* arg 4 high 32 bits */
226 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
227 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_22 */ 0, /* epoll_pwait_KILL */ 2 ),
228 : // arg_hi_eq_22:
229 : /* arg 4 low 32 bits */
230 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
231 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* epoll_pwait_ALLOW */ 1, /* epoll_pwait_KILL */ 0 ),
232 : // epoll_pwait_KILL:
233 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
234 : // epoll_pwait_ALLOW:
235 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
236 : // check_epoll_ctl:
237 : /* arg 0 low 32 bits */
238 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
239 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* epoll_ctl_ALLOW */ 5, /* or_23 */ 0 ),
240 : // or_23:
241 : /* arg 0 low 32 bits */
242 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
243 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_outer_fd)), /* and_24 */ 0, /* epoll_ctl_KILL */ 2 ),
244 : // and_24:
245 : /* arg 2 low 32 bits */
246 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
247 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* epoll_ctl_ALLOW */ 1, /* epoll_ctl_KILL */ 0 ),
248 : // epoll_ctl_KILL:
249 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
250 : // epoll_ctl_ALLOW:
251 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
252 : // check_futex:
253 : /* arg 1 low 32 bits */
254 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
255 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FUTEX_WAIT_BITSET), /* and_25 */ 0, /* futex_KILL */ 2 ),
256 : // and_25:
257 : /* arg 2 low 32 bits */
258 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
259 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* futex_ALLOW */ 1, /* futex_KILL */ 0 ),
260 : // futex_KILL:
261 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
262 : // futex_ALLOW:
263 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
264 0 : };
265 0 : fd_memcpy( out, filter, sizeof( filter ) );
266 0 : }
267 :
268 : #endif /* defined(__linux__) */
269 :
270 : #endif /* HEADER_fd_src_disco_gui_generated_fd_gui_tile_seccomp_h */
|