Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_discof_ipecho_generated_fd_ipecho_tile_seccomp_h
3 : #define HEADER_fd_src_discof_ipecho_generated_fd_ipecho_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_ipecho_tile_instr_cnt = 73;
35 :
36 0 : static void populate_sock_filter_policy_fd_ipecho_tile( ulong out_cnt, struct sock_filter out[ static 73 ], uint logfile_fd ) {
37 0 : FD_TEST( out_cnt >= 73 );
38 0 : struct sock_filter filter[73] = {
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 */ 9 ),
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 */ 9, 0 ),
46 : /* check close */
47 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 14, 0 ),
48 : /* check read */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 19, 0 ),
50 : /* check accept4 */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_accept4, /* check_accept4 */ 24, 0 ),
52 : /* allow ppoll */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ppoll, /* RET_ALLOW */ 4, 0 ),
54 : /* check sendto */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 30, 0 ),
56 : /* check recvfrom */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* check_recvfrom */ 43, 0 ),
58 : /* check fsync */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 58, 0 ),
60 : // RET_KILL_PROCESS:
61 : /* default deny */
62 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
63 : // RET_ALLOW:
64 : /* allow */
65 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
66 : // check_write:
67 : /* arg 0 low 32 bits */
68 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
69 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
70 : // or_1:
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, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
74 : // write_KILL:
75 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
76 : // write_ALLOW:
77 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
78 : // check_close:
79 : /* arg 0 low 32 bits */
80 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
81 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* close_KILL */ 2, /* or_2 */ 0 ),
82 : // or_2:
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, 0x00000002U, /* close_KILL */ 0, /* close_ALLOW */ 1 ),
86 : // close_KILL:
87 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
88 : // close_ALLOW:
89 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
90 : // check_read:
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)(logfile_fd)), /* read_KILL */ 2, /* or_3 */ 0 ),
94 : // or_3:
95 : /* arg 0 low 32 bits */
96 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
97 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* read_KILL */ 0, /* read_ALLOW */ 1 ),
98 : // read_KILL:
99 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
100 : // read_ALLOW:
101 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
102 : // check_accept4:
103 : /* arg 0 low 32 bits */
104 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
105 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* accept4_KILL */ 4, /* or_5 */ 0 ),
106 : // or_5:
107 : /* arg 0 low 32 bits */
108 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
109 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* accept4_KILL */ 2, /* and_4 */ 0 ),
110 : // and_4:
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_NONBLOCK|SOCK_CLOEXEC), /* 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_sendto:
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, ((uint)(logfile_fd)), /* sendto_KILL */ 10, /* 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, 0x00000002U, /* sendto_KILL */ 8, /* and_6 */ 0 ),
126 : // and_6:
127 : /* arg 3 low 32 bits */
128 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
129 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_NOSIGNAL), /* and_8 */ 0, /* sendto_KILL */ 6 ),
130 : // and_8:
131 : /* arg 4 high 32 bits */
132 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
133 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_10 */ 0, /* sendto_KILL */ 4 ),
134 : // arg_hi_eq_10:
135 : /* arg 4 low 32 bits */
136 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
137 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_9 */ 0, /* sendto_KILL */ 2 ),
138 : // and_9:
139 : /* arg 5 low 32 bits */
140 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
141 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
142 : // sendto_KILL:
143 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
144 : // sendto_ALLOW:
145 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
146 : // check_recvfrom:
147 : /* arg 0 low 32 bits */
148 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
149 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* recvfrom_KILL */ 12, /* or_12 */ 0 ),
150 : // or_12:
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, /* recvfrom_KILL */ 10, /* and_11 */ 0 ),
154 : // and_11:
155 : /* arg 3 low 32 bits */
156 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
157 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_13 */ 0, /* recvfrom_KILL */ 8 ),
158 : // and_13:
159 : /* arg 4 high 32 bits */
160 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
161 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_15 */ 0, /* recvfrom_KILL */ 6 ),
162 : // arg_hi_eq_15:
163 : /* arg 4 low 32 bits */
164 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
165 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_14 */ 0, /* recvfrom_KILL */ 4 ),
166 : // and_14:
167 : /* arg 5 high 32 bits */
168 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(5)),
169 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_16 */ 0, /* recvfrom_KILL */ 2 ),
170 : // arg_hi_eq_16:
171 : /* arg 5 low 32 bits */
172 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
173 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* recvfrom_ALLOW */ 1, /* recvfrom_KILL */ 0 ),
174 : // recvfrom_KILL:
175 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
176 : // recvfrom_ALLOW:
177 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
178 : // check_fsync:
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)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
182 : // fsync_KILL:
183 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
184 : // fsync_ALLOW:
185 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
186 0 : };
187 0 : fd_memcpy( out, filter, sizeof( filter ) );
188 0 : }
189 :
190 : #endif /* defined(__linux__) */
191 :
192 : #endif /* HEADER_fd_src_discof_ipecho_generated_fd_ipecho_tile_seccomp_h */
|