Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_discof_rpc_generated_fd_rpc_tile_seccomp_h
3 : #define HEADER_fd_src_discof_rpc_generated_fd_rpc_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_rpc_tile_instr_cnt = 93;
35 :
36 0 : static void populate_sock_filter_policy_fd_rpc_tile( ulong out_cnt, struct sock_filter out[ static 93 ], uint logfile_fd, uint rpc_socket_fd, uint accdb_ro_fd, uint epoll_inner_fd, uint epoll_outer_fd ) {
37 0 : FD_TEST( out_cnt >= 93 );
38 0 : struct sock_filter filter[93] = {
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 */ 11 ),
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 */ 11, 0 ),
46 : /* check fsync */
47 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 16, 0 ),
48 : /* check accept4 */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_accept4, /* check_accept4 */ 19, 0 ),
50 : /* check read */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 32, 0 ),
52 : /* check sendto */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 39, 0 ),
54 : /* check sendmsg */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmsg, /* check_sendmsg */ 46, 0 ),
56 : /* check close */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 55, 0 ),
58 : /* check epoll_pwait */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_pwait, /* check_epoll_pwait */ 62, 0 ),
60 : /* check epoll_ctl */
61 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_ctl, /* check_epoll_ctl */ 69, 0 ),
62 : /* check preadv2 */
63 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_preadv2, /* check_preadv2 */ 76, 0 ),
64 : // RET_KILL_PROCESS:
65 : /* default deny */
66 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
67 : // RET_ALLOW:
68 : /* allow */
69 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
70 : // check_write:
71 : /* arg 0 low 32 bits */
72 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
73 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
74 : // or_1:
75 : /* arg 0 low 32 bits */
76 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
77 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
78 : // write_KILL:
79 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
80 : // write_ALLOW:
81 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
82 : // check_fsync:
83 : /* arg 0 low 32 bits */
84 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
85 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
86 : // fsync_KILL:
87 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
88 : // fsync_ALLOW:
89 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
90 : // check_accept4:
91 : /* arg 0 low 32 bits */
92 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
93 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rpc_socket_fd)), /* and_2 */ 0, /* accept4_KILL */ 10 ),
94 : // and_2:
95 : /* arg 1 high 32 bits */
96 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(1)),
97 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_4 */ 0, /* accept4_KILL */ 8 ),
98 : // arg_hi_eq_4:
99 : /* arg 1 low 32 bits */
100 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
101 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_3 */ 0, /* accept4_KILL */ 6 ),
102 : // and_3:
103 : /* arg 2 high 32 bits */
104 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(2)),
105 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_6 */ 0, /* accept4_KILL */ 4 ),
106 : // arg_hi_eq_6:
107 : /* arg 2 low 32 bits */
108 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
109 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_5 */ 0, /* accept4_KILL */ 2 ),
110 : // and_5:
111 : /* arg 3 low 32 bits */
112 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
113 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SOCK_CLOEXEC|SOCK_NONBLOCK), /* accept4_ALLOW */ 1, /* accept4_KILL */ 0 ),
114 : // accept4_KILL:
115 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
116 : // accept4_ALLOW:
117 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
118 : // check_read:
119 : /* arg 0 low 32 bits */
120 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
121 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* read_KILL */ 4, /* or_7 */ 0 ),
122 : // or_7:
123 : /* arg 0 low 32 bits */
124 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
125 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* read_KILL */ 2, /* or_8 */ 0 ),
126 : // or_8:
127 : /* arg 0 low 32 bits */
128 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
129 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rpc_socket_fd)), /* read_KILL */ 0, /* read_ALLOW */ 1 ),
130 : // read_KILL:
131 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
132 : // read_ALLOW:
133 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
134 : // check_sendto:
135 : /* arg 0 low 32 bits */
136 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
137 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* sendto_KILL */ 4, /* or_9 */ 0 ),
138 : // or_9:
139 : /* arg 0 low 32 bits */
140 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
141 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* sendto_KILL */ 2, /* or_10 */ 0 ),
142 : // or_10:
143 : /* arg 0 low 32 bits */
144 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
145 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rpc_socket_fd)), /* sendto_KILL */ 0, /* sendto_ALLOW */ 1 ),
146 : // sendto_KILL:
147 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
148 : // sendto_ALLOW:
149 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
150 : // check_sendmsg:
151 : /* arg 0 low 32 bits */
152 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
153 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* sendmsg_KILL */ 6, /* or_12 */ 0 ),
154 : // or_12:
155 : /* arg 0 low 32 bits */
156 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
157 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* sendmsg_KILL */ 4, /* or_13 */ 0 ),
158 : // or_13:
159 : /* arg 0 low 32 bits */
160 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
161 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rpc_socket_fd)), /* sendmsg_KILL */ 2, /* and_11 */ 0 ),
162 : // and_11:
163 : /* arg 2 low 32 bits */
164 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
165 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_NOSIGNAL), /* sendmsg_ALLOW */ 1, /* sendmsg_KILL */ 0 ),
166 : // sendmsg_KILL:
167 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
168 : // sendmsg_ALLOW:
169 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
170 : // check_close:
171 : /* arg 0 low 32 bits */
172 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
173 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* close_KILL */ 4, /* or_14 */ 0 ),
174 : // or_14:
175 : /* arg 0 low 32 bits */
176 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
177 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* close_KILL */ 2, /* or_15 */ 0 ),
178 : // or_15:
179 : /* arg 0 low 32 bits */
180 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
181 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rpc_socket_fd)), /* close_KILL */ 0, /* close_ALLOW */ 1 ),
182 : // close_KILL:
183 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
184 : // close_ALLOW:
185 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
186 : // check_epoll_pwait:
187 : /* arg 0 low 32 bits */
188 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
189 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* and_16 */ 0, /* epoll_pwait_KILL */ 4 ),
190 : // and_16:
191 : /* arg 4 high 32 bits */
192 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
193 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_17 */ 0, /* epoll_pwait_KILL */ 2 ),
194 : // arg_hi_eq_17:
195 : /* arg 4 low 32 bits */
196 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
197 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* epoll_pwait_ALLOW */ 1, /* epoll_pwait_KILL */ 0 ),
198 : // epoll_pwait_KILL:
199 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
200 : // epoll_pwait_ALLOW:
201 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
202 : // check_epoll_ctl:
203 : /* arg 0 low 32 bits */
204 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
205 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* epoll_ctl_ALLOW */ 5, /* or_18 */ 0 ),
206 : // or_18:
207 : /* arg 0 low 32 bits */
208 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
209 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_outer_fd)), /* and_19 */ 0, /* epoll_ctl_KILL */ 2 ),
210 : // and_19:
211 : /* arg 2 low 32 bits */
212 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
213 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* epoll_ctl_ALLOW */ 1, /* epoll_ctl_KILL */ 0 ),
214 : // epoll_ctl_KILL:
215 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
216 : // epoll_ctl_ALLOW:
217 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
218 : // check_preadv2:
219 : /* arg 0 low 32 bits */
220 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
221 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(accdb_ro_fd)), /* preadv2_ALLOW */ 1, /* preadv2_KILL */ 0 ),
222 : // preadv2_KILL:
223 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
224 : // preadv2_ALLOW:
225 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
226 0 : };
227 0 : fd_memcpy( out, filter, sizeof( filter ) );
228 0 : }
229 :
230 : #endif /* defined(__linux__) */
231 :
232 : #endif /* HEADER_fd_src_discof_rpc_generated_fd_rpc_tile_seccomp_h */
|