Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_discof_execle_generated_fd_execle_tile_seccomp_h
3 : #define HEADER_fd_src_discof_execle_generated_fd_execle_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_execle_tile_instr_cnt = 61;
37 :
38 0 : static void populate_sock_filter_policy_fd_execle_tile( ulong out_cnt, struct sock_filter out[ static 61 ], uint logfile_fd, uint accounts_fd, uint stake_spill_fd, uint vote_stakes_fd ) {
39 0 : FD_TEST( out_cnt >= 61 );
40 0 : struct sock_filter filter[61] = {
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 */ 11 ),
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 */ 11, 0 ),
48 : /* check fsync */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 16, 0 ),
50 : /* check clock_nanosleep */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_clock_nanosleep, /* check_clock_nanosleep */ 19, 0 ),
52 : /* check pwritev2 */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_pwritev2, /* check_pwritev2 */ 22, 0 ),
54 : /* check preadv2 */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_preadv2, /* check_preadv2 */ 25, 0 ),
56 : /* check fallocate */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fallocate, /* check_fallocate */ 28, 0 ),
58 : /* check pread64 */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_pread64, /* check_pread64 */ 33, 0 ),
60 : /* check pwrite64 */
61 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_pwrite64, /* check_pwrite64 */ 38, 0 ),
62 : /* check futex */
63 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_futex, /* check_futex */ 43, 0 ),
64 : /* allow restart_syscall */
65 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_restart_syscall, /* RET_ALLOW */ 1, 0 ),
66 : // RET_KILL_PROCESS:
67 : /* default deny */
68 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
69 : // RET_ALLOW:
70 : /* allow */
71 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
72 : // check_write:
73 : /* arg 0 low 32 bits */
74 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
75 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
76 : // or_1:
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, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
80 : // write_KILL:
81 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
82 : // write_ALLOW:
83 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
84 : // check_fsync:
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)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
88 : // fsync_KILL:
89 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
90 : // fsync_ALLOW:
91 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
92 : // check_clock_nanosleep:
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, FD_SECCOMP_ARG_LO(CLOCK_REALTIME), /* clock_nanosleep_ALLOW */ 1, /* clock_nanosleep_KILL */ 0 ),
96 : // clock_nanosleep_KILL:
97 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
98 : // clock_nanosleep_ALLOW:
99 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
100 : // check_pwritev2:
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)(accounts_fd)), /* pwritev2_ALLOW */ 1, /* pwritev2_KILL */ 0 ),
104 : // pwritev2_KILL:
105 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
106 : // pwritev2_ALLOW:
107 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
108 : // check_preadv2:
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)(accounts_fd)), /* preadv2_ALLOW */ 1, /* preadv2_KILL */ 0 ),
112 : // preadv2_KILL:
113 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
114 : // preadv2_ALLOW:
115 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
116 : // check_fallocate:
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)(accounts_fd)), /* and_2 */ 0, /* fallocate_KILL */ 2 ),
120 : // and_2:
121 : /* arg 1 low 32 bits */
122 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
123 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* fallocate_ALLOW */ 1, /* fallocate_KILL */ 0 ),
124 : // fallocate_KILL:
125 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
126 : // fallocate_ALLOW:
127 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
128 : // check_pread64:
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)(stake_spill_fd)), /* pread64_ALLOW */ 3, /* or_3 */ 0 ),
132 : // or_3:
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)(vote_stakes_fd)), /* pread64_ALLOW */ 1, /* pread64_KILL */ 0 ),
136 : // pread64_KILL:
137 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
138 : // pread64_ALLOW:
139 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
140 : // check_pwrite64:
141 : /* arg 0 low 32 bits */
142 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
143 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(stake_spill_fd)), /* pwrite64_ALLOW */ 3, /* or_4 */ 0 ),
144 : // or_4:
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)(vote_stakes_fd)), /* pwrite64_ALLOW */ 1, /* pwrite64_KILL */ 0 ),
148 : // pwrite64_KILL:
149 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
150 : // pwrite64_ALLOW:
151 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
152 : // check_futex:
153 : /* arg 1 low 32 bits */
154 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
155 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FUTEX_WAIT_BITSET), /* and_5 */ 0, /* futex_KILL */ 2 ),
156 : // and_5:
157 : /* arg 2 low 32 bits */
158 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
159 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* futex_ALLOW */ 1, /* futex_KILL */ 0 ),
160 : // futex_KILL:
161 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
162 : // futex_ALLOW:
163 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
164 0 : };
165 0 : fd_memcpy( out, filter, sizeof( filter ) );
166 0 : }
167 :
168 : #endif /* defined(__linux__) */
169 :
170 : #endif /* HEADER_fd_src_discof_execle_generated_fd_execle_tile_seccomp_h */
|