Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_disco_bundle_generated_fd_bundle_tile_seccomp_h
3 : #define HEADER_fd_src_disco_bundle_generated_fd_bundle_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_bundle_tile_instr_cnt = 97;
28 :
29 0 : static void populate_sock_filter_policy_fd_bundle_tile( ulong out_cnt, struct sock_filter * out, uint logfile_fd, uint keylog_fd, uint etc_hosts_fd, uint etc_resolv_conf ) {
30 0 : FD_TEST( out_cnt >= 97 );
31 0 : struct sock_filter filter[97] = {
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 */ 93 ),
35 : /* loading syscall number in accumulator */
36 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
37 : /* simply allow read */
38 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* RET_ALLOW */ 92, 0 ),
39 : /* allow recvmsg based on expression */
40 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvmsg, /* check_recvmsg */ 20, 0 ),
41 : /* simply allow write */
42 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* RET_ALLOW */ 90, 0 ),
43 : /* allow writev based on expression */
44 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_writev, /* check_writev */ 22, 0 ),
45 : /* allow sendmsg based on expression */
46 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmsg, /* check_sendmsg */ 25, 0 ),
47 : /* allow sendto based on expression */
48 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 30, 0 ),
49 : /* allow fsync based on expression */
50 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 31, 0 ),
51 : /* allow socket based on expression */
52 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_socket, /* check_socket */ 32, 0 ),
53 : /* simply allow connect */
54 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_connect, /* RET_ALLOW */ 84, 0 ),
55 : /* allow shutdown based on expression */
56 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_shutdown, /* check_shutdown */ 48, 0 ),
57 : /* simply allow close */
58 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* RET_ALLOW */ 82, 0 ),
59 : /* allow fcntl based on expression */
60 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fcntl, /* check_fcntl */ 48, 0 ),
61 : /* allow bind based on expression */
62 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_bind, /* check_bind */ 51, 0 ),
63 : /* simply allow ppoll */
64 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ppoll, /* RET_ALLOW */ 79, 0 ),
65 : /* allow setsockopt based on expression */
66 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_setsockopt, /* check_setsockopt */ 53, 0 ),
67 : /* simply allow getsockname */
68 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getsockname, /* RET_ALLOW */ 77, 0 ),
69 : /* simply allow getpid */
70 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getpid, /* RET_ALLOW */ 76, 0 ),
71 : /* simply allow getrandom */
72 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getrandom, /* RET_ALLOW */ 75, 0 ),
73 : /* allow lseek based on expression */
74 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_lseek, /* check_lseek */ 65, 0 ),
75 : /* simply allow sched_yield */
76 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sched_yield, /* RET_ALLOW */ 73, 0 ),
77 : /* simply allow clock_nanosleep */
78 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_clock_nanosleep, /* RET_ALLOW */ 72, 0 ),
79 : /* none of the syscalls matched */
80 0 : { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 70 },
81 : // check_recvmsg:
82 : /* load syscall argument 2 in accumulator */
83 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
84 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL|MSG_DONTWAIT, /* RET_ALLOW */ 69, /* lbl_1 */ 0 ),
85 : // lbl_1:
86 : /* load syscall argument 2 in accumulator */
87 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
88 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* RET_ALLOW */ 67, /* RET_KILL_PROCESS */ 66 ),
89 : // check_writev:
90 : /* load syscall argument 0 in accumulator */
91 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
92 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, keylog_fd, /* lbl_2 */ 0, /* RET_KILL_PROCESS */ 64 ),
93 : // lbl_2:
94 : /* load syscall argument 2 in accumulator */
95 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
96 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_ALLOW */ 63, /* RET_KILL_PROCESS */ 62 ),
97 : // check_sendmsg:
98 : /* load syscall argument 2 in accumulator */
99 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
100 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL|MSG_DONTWAIT, /* RET_ALLOW */ 61, /* lbl_3 */ 0 ),
101 : // lbl_3:
102 : /* load syscall argument 2 in accumulator */
103 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
104 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_FASTOPEN|MSG_NOSIGNAL, /* RET_ALLOW */ 59, /* lbl_4 */ 0 ),
105 : // lbl_4:
106 : /* load syscall argument 2 in accumulator */
107 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
108 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 57, /* RET_KILL_PROCESS */ 56 ),
109 : // check_sendto:
110 : /* load syscall argument 3 in accumulator */
111 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[3])),
112 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 55, /* RET_KILL_PROCESS */ 54 ),
113 : // check_fsync:
114 : /* load syscall argument 0 in accumulator */
115 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
116 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 53, /* RET_KILL_PROCESS */ 52 ),
117 : // check_socket:
118 : /* load syscall argument 0 in accumulator */
119 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
120 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, AF_INET, /* lbl_5 */ 2, /* lbl_6 */ 0 ),
121 : // lbl_6:
122 : /* load syscall argument 0 in accumulator */
123 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
124 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, AF_INET6, /* lbl_5 */ 0, /* RET_KILL_PROCESS */ 48 ),
125 : // lbl_5:
126 : /* load syscall argument 1 in accumulator */
127 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
128 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_STREAM|SOCK_CLOEXEC, /* lbl_8 */ 2, /* lbl_9 */ 0 ),
129 : // lbl_9:
130 : /* load syscall argument 1 in accumulator */
131 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
132 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, /* lbl_8 */ 0, /* lbl_7 */ 2 ),
133 : // lbl_8:
134 : /* load syscall argument 2 in accumulator */
135 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
136 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* RET_ALLOW */ 43, /* lbl_7 */ 0 ),
137 : // lbl_7:
138 : /* load syscall argument 1 in accumulator */
139 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
140 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, /* lbl_11 */ 0, /* lbl_10 */ 2 ),
141 : // lbl_11:
142 : /* load syscall argument 2 in accumulator */
143 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
144 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* RET_ALLOW */ 39, /* lbl_10 */ 0 ),
145 : // lbl_10:
146 : /* load syscall argument 1 in accumulator */
147 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
148 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_DGRAM|SOCK_CLOEXEC, /* lbl_12 */ 0, /* RET_KILL_PROCESS */ 36 ),
149 : // lbl_12:
150 : /* load syscall argument 2 in accumulator */
151 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
152 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_UDP, /* RET_ALLOW */ 35, /* RET_KILL_PROCESS */ 34 ),
153 : // check_shutdown:
154 : /* load syscall argument 1 in accumulator */
155 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
156 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SHUT_WR, /* RET_ALLOW */ 33, /* RET_KILL_PROCESS */ 32 ),
157 : // check_fcntl:
158 : /* load syscall argument 1 in accumulator */
159 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
160 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, F_SETFL, /* lbl_13 */ 0, /* RET_KILL_PROCESS */ 30 ),
161 : // lbl_13:
162 : /* load syscall argument 2 in accumulator */
163 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
164 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, O_NONBLOCK, /* RET_ALLOW */ 29, /* RET_KILL_PROCESS */ 28 ),
165 : // check_bind:
166 : /* load syscall argument 2 in accumulator */
167 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
168 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, sizeof(struct sockaddr_in), /* RET_ALLOW */ 27, /* lbl_14 */ 0 ),
169 : // lbl_14:
170 : /* load syscall argument 2 in accumulator */
171 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
172 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, sizeof(struct sockaddr_in6), /* RET_ALLOW */ 25, /* RET_KILL_PROCESS */ 24 ),
173 : // check_setsockopt:
174 : /* load syscall argument 1 in accumulator */
175 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
176 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_SOCKET, /* lbl_16 */ 0, /* lbl_15 */ 2 ),
177 : // lbl_16:
178 : /* load syscall argument 2 in accumulator */
179 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
180 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SO_RCVBUF, /* RET_ALLOW */ 21, /* lbl_15 */ 0 ),
181 : // lbl_15:
182 : /* load syscall argument 1 in accumulator */
183 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
184 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_TCP, /* lbl_18 */ 0, /* lbl_17 */ 2 ),
185 : // lbl_18:
186 : /* load syscall argument 2 in accumulator */
187 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
188 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, TCP_NODELAY, /* RET_ALLOW */ 17, /* lbl_17 */ 0 ),
189 : // lbl_17:
190 : /* load syscall argument 1 in accumulator */
191 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
192 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_TCP, /* lbl_20 */ 0, /* lbl_19 */ 2 ),
193 : // lbl_20:
194 : /* load syscall argument 2 in accumulator */
195 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
196 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, TCP_FASTOPEN_CONNECT, /* RET_ALLOW */ 13, /* lbl_19 */ 0 ),
197 : // lbl_19:
198 : /* load syscall argument 1 in accumulator */
199 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
200 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_IPV6, /* lbl_21 */ 0, /* RET_KILL_PROCESS */ 10 ),
201 : // lbl_21:
202 : /* load syscall argument 2 in accumulator */
203 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
204 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, IPV6_V6ONLY, /* RET_ALLOW */ 9, /* RET_KILL_PROCESS */ 8 ),
205 : // check_lseek:
206 : /* load syscall argument 0 in accumulator */
207 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
208 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_resolv_conf, /* lbl_22 */ 2, /* lbl_23 */ 0 ),
209 : // lbl_23:
210 : /* load syscall argument 0 in accumulator */
211 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
212 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, etc_hosts_fd, /* lbl_22 */ 0, /* RET_KILL_PROCESS */ 4 ),
213 : // lbl_22:
214 : /* load syscall argument 1 in accumulator */
215 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
216 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* lbl_24 */ 0, /* RET_KILL_PROCESS */ 2 ),
217 : // lbl_24:
218 : /* load syscall argument 2 in accumulator */
219 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
220 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SEEK_SET, /* RET_ALLOW */ 1, /* RET_KILL_PROCESS */ 0 ),
221 : // RET_KILL_PROCESS:
222 : /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
223 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
224 : // RET_ALLOW:
225 : /* ALLOW has to be reached by jumping */
226 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
227 0 : };
228 0 : fd_memcpy( out, filter, sizeof( filter ) );
229 0 : }
230 :
231 : #endif /* defined(__linux__) */
232 :
233 : #endif /* HEADER_fd_src_disco_bundle_generated_fd_bundle_tile_seccomp_h */
|