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_iavf_generated_fd_iavf_tile_seccomp_h
3 : #define HEADER_fd_src_disco_net_iavf_generated_fd_iavf_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_iavf_tile_instr_cnt = 35;
37 :
38 0 : static void populate_sock_filter_policy_fd_iavf_tile( ulong out_cnt, struct sock_filter out[ static 35 ], uint logfile_fd, uint lo_tx_fd, uint net_sock_fd ) {
39 0 : FD_TEST( out_cnt >= 35 );
40 0 : struct sock_filter filter[35] = {
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 */ 5 ),
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 */ 5, 0 ),
48 : /* check fsync */
49 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 10, 0 ),
50 : /* check sendmmsg */
51 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmmsg, /* check_sendmmsg */ 13, 0 ),
52 : /* check sendto */
53 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 20, 0 ),
54 : // RET_KILL_PROCESS:
55 : /* default deny */
56 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
57 : // RET_ALLOW:
58 : /* allow */
59 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
60 : // check_write:
61 : /* arg 0 low 32 bits */
62 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
63 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
64 : // or_1:
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)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
68 : // write_KILL:
69 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
70 : // write_ALLOW:
71 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
72 : // check_fsync:
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, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
76 : // fsync_KILL:
77 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
78 : // fsync_ALLOW:
79 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
80 : // check_sendmmsg:
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, ((uint)(lo_tx_fd)), /* and_2 */ 0, /* sendmmsg_KILL */ 4 ),
84 : // and_2:
85 : /* arg 2 low 32 bits */
86 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
87 0 : BPF_JUMP( BPF_JMP | BPF_JGT | BPF_K, 0x00000040U, /* sendmmsg_KILL */ 2, /* and_3 */ 0 ),
88 : // and_3:
89 : /* arg 3 low 32 bits */
90 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
91 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* sendmmsg_ALLOW */ 1, /* sendmmsg_KILL */ 0 ),
92 : // sendmmsg_KILL:
93 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
94 : // sendmmsg_ALLOW:
95 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
96 : // check_sendto:
97 : /* arg 0 low 32 bits */
98 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
99 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(net_sock_fd)), /* and_4 */ 0, /* sendto_KILL */ 4 ),
100 : // and_4:
101 : /* arg 3 low 32 bits */
102 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
103 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* and_5 */ 0, /* sendto_KILL */ 2 ),
104 : // and_5:
105 : /* arg 5 low 32 bits */
106 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
107 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FD_SOCKADDR_IN_SZ), /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
108 : // sendto_KILL:
109 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
110 : // sendto_ALLOW:
111 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
112 0 : };
113 0 : fd_memcpy( out, filter, sizeof( filter ) );
114 0 : }
115 :
116 : #endif /* defined(__linux__) */
117 :
118 : #endif /* HEADER_fd_src_disco_net_iavf_generated_fd_iavf_tile_seccomp_h */
|