Line data Source code
1 : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
2 : #ifndef HEADER_fd_src_disco_gui_generated_fd_gui_tile_seccomp_h
3 : #define HEADER_fd_src_disco_gui_generated_fd_gui_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 : static const unsigned int sock_filter_policy_fd_gui_tile_instr_cnt = 56;
28 :
29 0 : static void populate_sock_filter_policy_fd_gui_tile( ulong out_cnt, struct sock_filter * out, unsigned int logfile_fd, unsigned int gui_socket_fd ) {
30 0 : FD_TEST( out_cnt >= 56 );
31 0 : struct sock_filter filter[56] = {
32 : /* Check: Jump to RET_KILL_PROCESS if the script's arch != the runtime arch */
33 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) ) ),
34 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 52 ),
35 : /* loading syscall number in accumulator */
36 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
37 : /* allow write based on expression */
38 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 8, 0 ),
39 : /* allow fsync based on expression */
40 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 11, 0 ),
41 : /* allow accept4 based on expression */
42 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_accept4, /* check_accept4 */ 12, 0 ),
43 : /* allow read based on expression */
44 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 19, 0 ),
45 : /* allow sendto based on expression */
46 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 24, 0 ),
47 : /* allow sendmmsg based on expression */
48 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendmmsg, /* check_sendmmsg */ 29, 0 ),
49 : /* allow close based on expression */
50 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 38, 0 ),
51 : /* simply allow ppoll */
52 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ppoll, /* RET_ALLOW */ 44, 0 ),
53 : /* none of the syscalls matched */
54 0 : { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 42 },
55 : // check_write:
56 : /* load syscall argument 0 in accumulator */
57 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
58 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_ALLOW */ 41, /* lbl_1 */ 0 ),
59 : // lbl_1:
60 : /* load syscall argument 0 in accumulator */
61 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
62 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 39, /* RET_KILL_PROCESS */ 38 ),
63 : // check_fsync:
64 : /* load syscall argument 0 in accumulator */
65 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
66 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 37, /* RET_KILL_PROCESS */ 36 ),
67 : // check_accept4:
68 : /* load syscall argument 0 in accumulator */
69 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
70 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, gui_socket_fd, /* lbl_2 */ 0, /* RET_KILL_PROCESS */ 34 ),
71 : // lbl_2:
72 : /* load syscall argument 1 in accumulator */
73 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
74 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* lbl_3 */ 0, /* RET_KILL_PROCESS */ 32 ),
75 : // lbl_3:
76 : /* load syscall argument 2 in accumulator */
77 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
78 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0, /* lbl_4 */ 0, /* RET_KILL_PROCESS */ 30 ),
79 : // lbl_4:
80 : /* load syscall argument 3 in accumulator */
81 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[3])),
82 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_CLOEXEC|SOCK_NONBLOCK, /* RET_ALLOW */ 29, /* RET_KILL_PROCESS */ 28 ),
83 : // check_read:
84 : /* load syscall argument 0 in accumulator */
85 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
86 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 26, /* lbl_5 */ 0 ),
87 : // lbl_5:
88 : /* load syscall argument 0 in accumulator */
89 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
90 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 24, /* lbl_6 */ 0 ),
91 : // lbl_6:
92 : /* load syscall argument 0 in accumulator */
93 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
94 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, gui_socket_fd, /* RET_KILL_PROCESS */ 22, /* RET_ALLOW */ 23 ),
95 : // check_sendto:
96 : /* load syscall argument 0 in accumulator */
97 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
98 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 20, /* lbl_7 */ 0 ),
99 : // lbl_7:
100 : /* load syscall argument 0 in accumulator */
101 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
102 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 18, /* lbl_8 */ 0 ),
103 : // lbl_8:
104 : /* load syscall argument 0 in accumulator */
105 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
106 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, gui_socket_fd, /* RET_KILL_PROCESS */ 16, /* RET_ALLOW */ 17 ),
107 : // check_sendmmsg:
108 : /* load syscall argument 0 in accumulator */
109 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
110 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 14, /* lbl_10 */ 0 ),
111 : // lbl_10:
112 : /* load syscall argument 0 in accumulator */
113 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
114 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 12, /* lbl_11 */ 0 ),
115 : // lbl_11:
116 : /* load syscall argument 0 in accumulator */
117 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
118 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, gui_socket_fd, /* RET_KILL_PROCESS */ 10, /* lbl_9 */ 0 ),
119 : // lbl_9:
120 : /* load syscall argument 2 in accumulator */
121 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
122 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 1, /* lbl_12 */ 0, /* RET_KILL_PROCESS */ 8 ),
123 : // lbl_12:
124 : /* load syscall argument 3 in accumulator */
125 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[3])),
126 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, MSG_NOSIGNAL, /* RET_ALLOW */ 7, /* RET_KILL_PROCESS */ 6 ),
127 : // check_close:
128 : /* load syscall argument 0 in accumulator */
129 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
130 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_KILL_PROCESS */ 4, /* lbl_13 */ 0 ),
131 : // lbl_13:
132 : /* load syscall argument 0 in accumulator */
133 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
134 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_KILL_PROCESS */ 2, /* lbl_14 */ 0 ),
135 : // lbl_14:
136 : /* load syscall argument 0 in accumulator */
137 0 : BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
138 0 : BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, gui_socket_fd, /* RET_KILL_PROCESS */ 0, /* RET_ALLOW */ 1 ),
139 : // RET_KILL_PROCESS:
140 : /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
141 0 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
142 : // RET_ALLOW:
143 : /* ALLOW has to be reached by jumping */
144 : BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
145 0 : };
146 0 : fd_memcpy( out, filter, sizeof( filter ) );
147 0 : }
148 :
149 : #endif /* defined(__linux__) */
150 :
151 : #endif /* HEADER_fd_src_disco_gui_generated_fd_gui_tile_seccomp_h */
|