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 = 55;
37 :
38 0 : static void populate_sock_filter_policy_fd_mlx5_tile( ulong out_cnt, struct sock_filter out[ static 55 ], uint logfile_fd, uint async_fd, uint lo_tx_fd, uint rx_comp_channel_fd, uint epoll_fd ) {
39 0 : FD_TEST( out_cnt >= 55 );
40 0 : struct sock_filter filter[55] = {
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 */ 7 ),
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 */ 7, 0 ),
48 : /* check write */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 14, 0 ),
50 : /* check fsync */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 19, 0 ),
52 : /* check read */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 22, 0 ),
54 : /* check clock_nanosleep */
55 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_clock_nanosleep, /* check_clock_nanosleep */ 27, 0 ),
56 : /* check epoll_pwait */
57 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_pwait, /* check_epoll_pwait */ 36, 0 ),
58 : // RET_KILL_PROCESS:
59 : /* default deny */
60 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
61 : // RET_ALLOW:
62 : /* allow */
63 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
64 : // check_sendmmsg:
65 : /* arg 0 low 32 bits */
66 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
67 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(lo_tx_fd)), /* and_1 */ 0, /* sendmmsg_KILL */ 4 ),
68 : // and_1:
69 : /* arg 2 low 32 bits */
70 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
71 0 : BPF_JUMP( BPF_JMP | BPF_JGT | BPF_K, 0x00000040U, /* sendmmsg_KILL */ 2, /* and_2 */ 0 ),
72 : // and_2:
73 : /* arg 3 low 32 bits */
74 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
75 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* sendmmsg_ALLOW */ 1, /* sendmmsg_KILL */ 0 ),
76 : // sendmmsg_KILL:
77 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
78 : // sendmmsg_ALLOW:
79 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
80 : // check_write:
81 : /* arg 0 low 32 bits */
82 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
83 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_3 */ 0 ),
84 : // or_3:
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)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
88 : // write_KILL:
89 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
90 : // write_ALLOW:
91 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
92 : // check_fsync:
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, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
96 : // fsync_KILL:
97 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
98 : // fsync_ALLOW:
99 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
100 : // check_read:
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)(async_fd)), /* read_ALLOW */ 3, /* or_4 */ 0 ),
104 : // or_4:
105 : /* arg 0 low 32 bits */
106 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
107 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(rx_comp_channel_fd)), /* read_ALLOW */ 1, /* read_KILL */ 0 ),
108 : // read_KILL:
109 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
110 : // read_ALLOW:
111 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
112 : // check_clock_nanosleep:
113 : /* arg 0 low 32 bits */
114 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
115 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(CLOCK_MONOTONIC), /* and_5 */ 0, /* clock_nanosleep_KILL */ 6 ),
116 : // and_5:
117 : /* arg 1 low 32 bits */
118 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
119 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(TIMER_ABSTIME), /* and_6 */ 0, /* clock_nanosleep_KILL */ 4 ),
120 : // and_6:
121 : /* arg 3 high 32 bits */
122 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(3)),
123 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_7 */ 0, /* clock_nanosleep_KILL */ 2 ),
124 : // arg_hi_eq_7:
125 : /* arg 3 low 32 bits */
126 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
127 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* clock_nanosleep_ALLOW */ 1, /* clock_nanosleep_KILL */ 0 ),
128 : // clock_nanosleep_KILL:
129 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
130 : // clock_nanosleep_ALLOW:
131 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
132 : // check_epoll_pwait:
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)(epoll_fd)), /* and_8 */ 0, /* epoll_pwait_KILL */ 6 ),
136 : // and_8:
137 : /* arg 2 low 32 bits */
138 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
139 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000003U, /* and_9 */ 0, /* epoll_pwait_KILL */ 4 ),
140 : // and_9:
141 : /* arg 4 high 32 bits */
142 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
143 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_10 */ 0, /* epoll_pwait_KILL */ 2 ),
144 : // arg_hi_eq_10:
145 : /* arg 4 low 32 bits */
146 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
147 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* epoll_pwait_ALLOW */ 1, /* epoll_pwait_KILL */ 0 ),
148 : // epoll_pwait_KILL:
149 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
150 : // epoll_pwait_ALLOW:
151 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
152 0 : };
153 0 : fd_memcpy( out, filter, sizeof( filter ) );
154 0 : }
155 :
156 : #endif /* defined(__linux__) */
157 :
158 : #endif /* HEADER_fd_src_disco_net_mlx5_generated_fd_mlx5_tile_seccomp_h */
|