Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_disco_net_mlx5_generated_fd_mlx5_tile_seccomp_h
3 : #define HEADER_fd_src_disco_net_mlx5_generated_fd_mlx5_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_mlx5_tile_instr_cnt = 64;
37 :
38 0 : static void populate_sock_filter_policy_fd_mlx5_tile( ulong out_cnt, struct sock_filter out[ static 64 ], uint logfile_fd, uint async_fd, uint lo_tx_fd, uint net_sock_fd, uint rx_comp_channel_fd, uint epoll_fd ) {
39 0 : FD_TEST( out_cnt >= 64 );
40 0 : struct sock_filter filter[64] = {
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 */ 8 ),
44 : /* load syscall number */
45 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) )),
46 : /* check sendmmsg */
47 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmmsg, /* check_sendmmsg */ 8, 0 ),
48 : /* check sendto */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 15, 0 ),
50 : /* check write */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 22, 0 ),
52 : /* check fsync */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 27, 0 ),
54 : /* check read */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 30, 0 ),
56 : /* check clock_nanosleep */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_clock_nanosleep, /* check_clock_nanosleep */ 35, 0 ),
58 : /* check epoll_pwait */
59 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_pwait, /* check_epoll_pwait */ 44, 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_sendmmsg:
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, ((uint)(lo_tx_fd)), /* and_1 */ 0, /* sendmmsg_KILL */ 4 ),
70 : // and_1:
71 : /* arg 2 low 32 bits */
72 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
73 0 : BPF_JUMP( BPF_JMP | BPF_JGT | BPF_K, 0x00000040U, /* sendmmsg_KILL */ 2, /* and_2 */ 0 ),
74 : // and_2:
75 : /* arg 3 low 32 bits */
76 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
77 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* sendmmsg_ALLOW */ 1, /* sendmmsg_KILL */ 0 ),
78 : // sendmmsg_KILL:
79 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
80 : // sendmmsg_ALLOW:
81 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
82 : // check_sendto:
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)(net_sock_fd)), /* and_3 */ 0, /* sendto_KILL */ 4 ),
86 : // and_3:
87 : /* arg 3 low 32 bits */
88 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
89 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* and_4 */ 0, /* sendto_KILL */ 2 ),
90 : // and_4:
91 : /* arg 5 low 32 bits */
92 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
93 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FD_SOCKADDR_IN_SZ), /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
94 : // sendto_KILL:
95 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
96 : // sendto_ALLOW:
97 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
98 : // check_write:
99 : /* arg 0 low 32 bits */
100 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
101 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_5 */ 0 ),
102 : // or_5:
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)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
106 : // write_KILL:
107 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
108 : // write_ALLOW:
109 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
110 : // check_fsync:
111 : /* arg 0 low 32 bits */
112 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
113 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
114 : // fsync_KILL:
115 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
116 : // fsync_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, ((uint)(async_fd)), /* read_ALLOW */ 3, /* or_6 */ 0 ),
122 : // or_6:
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)(rx_comp_channel_fd)), /* read_ALLOW */ 1, /* read_KILL */ 0 ),
126 : // read_KILL:
127 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
128 : // read_ALLOW:
129 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
130 : // check_clock_nanosleep:
131 : /* arg 0 low 32 bits */
132 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
133 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(CLOCK_MONOTONIC), /* and_7 */ 0, /* clock_nanosleep_KILL */ 6 ),
134 : // and_7:
135 : /* arg 1 low 32 bits */
136 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
137 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(TIMER_ABSTIME), /* and_8 */ 0, /* clock_nanosleep_KILL */ 4 ),
138 : // and_8:
139 : /* arg 3 high 32 bits */
140 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(3)),
141 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_9 */ 0, /* clock_nanosleep_KILL */ 2 ),
142 : // arg_hi_eq_9:
143 : /* arg 3 low 32 bits */
144 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
145 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* clock_nanosleep_ALLOW */ 1, /* clock_nanosleep_KILL */ 0 ),
146 : // clock_nanosleep_KILL:
147 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
148 : // clock_nanosleep_ALLOW:
149 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
150 : // check_epoll_pwait:
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, ((uint)(epoll_fd)), /* and_10 */ 0, /* epoll_pwait_KILL */ 6 ),
154 : // and_10:
155 : /* arg 2 low 32 bits */
156 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
157 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000003U, /* and_11 */ 0, /* epoll_pwait_KILL */ 4 ),
158 : // and_11:
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_12 */ 0, /* epoll_pwait_KILL */ 2 ),
162 : // arg_hi_eq_12:
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, /* epoll_pwait_ALLOW */ 1, /* epoll_pwait_KILL */ 0 ),
166 : // epoll_pwait_KILL:
167 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
168 : // epoll_pwait_ALLOW:
169 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
170 0 : };
171 0 : fd_memcpy( out, filter, sizeof( filter ) );
172 0 : }
173 :
174 : #endif /* defined(__linux__) */
175 :
176 : #endif /* HEADER_fd_src_disco_net_mlx5_generated_fd_mlx5_tile_seccomp_h */
|