OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ |
7 | 7 |
8 // The Seccomp2 kernel ABI is not part of older versions of glibc. | 8 // The Seccomp2 kernel ABI is not part of older versions of glibc. |
9 // As we can't break compilation with these versions of the library, | 9 // As we can't break compilation with these versions of the library, |
10 // we explicitly define all missing symbols. | 10 // we explicitly define all missing symbols. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) | 117 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) |
118 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ | 118 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ |
119 instruction_pointer) + 4) | 119 instruction_pointer) + 4) |
120 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ | 120 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ |
121 instruction_pointer) + 0) | 121 instruction_pointer) + 0) |
122 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 122 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
123 8*(nr) + 4) | 123 8*(nr) + 4) |
124 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 124 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
125 8*(nr) + 0) | 125 8*(nr) + 0) |
126 | 126 |
| 127 struct pt_regs { |
| 128 long int ebx; |
| 129 long int ecx; |
| 130 long int edx; |
| 131 long int esi; |
| 132 long int edi; |
| 133 long int ebp; |
| 134 long int eax; |
| 135 long int ds; |
| 136 long int es; |
| 137 long int fs; |
| 138 long int gs; |
| 139 long int orig_eax; |
| 140 long int eip; |
| 141 long int cs; |
| 142 long int eflags; |
| 143 long int esp; |
| 144 long int ss; |
| 145 }; |
| 146 #define SECCOMP_PT_RESULT(_pt_regs) (_pt_regs).eax |
| 147 #define SECCOMP_PT_SYSCALL(_pt_regs) (_pt_regs).orig_eax |
| 148 #define SECCOMP_PT_IP(_pt_regs) (_pt_regs).eip |
| 149 #define SECCOMP_PT_PARM1(_pt_regs) (_pt_regs).ebx |
| 150 #define SECCOMP_PT_PARM2(_pt_regs) (_pt_regs).ecx |
| 151 #define SECCOMP_PT_PARM3(_pt_regs) (_pt_regs).edx |
| 152 #define SECCOMP_PT_PARM4(_pt_regs) (_pt_regs).esi |
| 153 #define SECCOMP_PT_PARM5(_pt_regs) (_pt_regs).edi |
| 154 #define SECCOMP_PT_PARM6(_pt_regs) (_pt_regs).ebp |
| 155 |
127 #elif defined(__x86_64__) | 156 #elif defined(__x86_64__) |
128 #define MIN_SYSCALL 0u | 157 #define MIN_SYSCALL 0u |
129 #define MAX_PUBLIC_SYSCALL 1024u | 158 #define MAX_PUBLIC_SYSCALL 1024u |
130 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL | 159 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL |
131 #define SECCOMP_ARCH AUDIT_ARCH_X86_64 | 160 #define SECCOMP_ARCH AUDIT_ARCH_X86_64 |
132 | 161 |
133 #define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.gregs[(_reg)]) | 162 #define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.gregs[(_reg)]) |
134 #define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_RAX) | 163 #define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_RAX) |
135 #define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_RAX) | 164 #define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_RAX) |
136 #define SECCOMP_IP(_ctx) SECCOMP_REG(_ctx, REG_RIP) | 165 #define SECCOMP_IP(_ctx) SECCOMP_REG(_ctx, REG_RIP) |
137 #define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_RDI) | 166 #define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_RDI) |
138 #define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_RSI) | 167 #define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_RSI) |
139 #define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_RDX) | 168 #define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_RDX) |
140 #define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_R10) | 169 #define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_R10) |
141 #define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_R8) | 170 #define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_R8) |
142 #define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_R9) | 171 #define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_R9) |
143 #define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) | 172 #define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) |
144 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) | 173 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) |
145 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ | 174 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ |
146 instruction_pointer) + 4) | 175 instruction_pointer) + 4) |
147 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ | 176 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ |
148 instruction_pointer) + 0) | 177 instruction_pointer) + 0) |
149 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 178 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
150 8*(nr) + 4) | 179 8*(nr) + 4) |
151 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 180 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
152 8*(nr) + 0) | 181 8*(nr) + 0) |
153 | 182 |
| 183 struct pt_regs { |
| 184 unsigned long int r15; |
| 185 unsigned long int r14; |
| 186 unsigned long int r13; |
| 187 unsigned long int r12; |
| 188 unsigned long int rbp; |
| 189 unsigned long int rbx; |
| 190 unsigned long int r11; |
| 191 unsigned long int r10; |
| 192 unsigned long int r9; |
| 193 unsigned long int r8; |
| 194 unsigned long int rax; |
| 195 unsigned long int rcx; |
| 196 unsigned long int rdx; |
| 197 unsigned long int rsi; |
| 198 unsigned long int rdi; |
| 199 unsigned long int orig_rax; |
| 200 unsigned long int rip; |
| 201 unsigned long int cs; |
| 202 unsigned long int eflags; |
| 203 unsigned long int rsp; |
| 204 unsigned long int ss; |
| 205 unsigned long int fs_base; |
| 206 unsigned long int gs_base; |
| 207 unsigned long int ds; |
| 208 unsigned long int es; |
| 209 unsigned long int fs; |
| 210 unsigned long int gs; |
| 211 }; |
| 212 #define SECCOMP_PT_RESULT(_pt_regs) (_pt_regs).rax |
| 213 #define SECCOMP_PT_SYSCALL(_pt_regs) (_pt_regs).orig_rax |
| 214 #define SECCOMP_PT_IP(_pt_regs) (_pt_regs).rip |
| 215 #define SECCOMP_PT_PARM1(_pt_regs) (_pt_regs).rdi |
| 216 #define SECCOMP_PT_PARM2(_pt_regs) (_pt_regs).rsi |
| 217 #define SECCOMP_PT_PARM3(_pt_regs) (_pt_regs).rdx |
| 218 #define SECCOMP_PT_PARM4(_pt_regs) (_pt_regs).r10 |
| 219 #define SECCOMP_PT_PARM5(_pt_regs) (_pt_regs).r8 |
| 220 #define SECCOMP_PT_PARM6(_pt_regs) (_pt_regs).r9 |
| 221 |
154 #elif defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__)) | 222 #elif defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__)) |
155 // ARM EABI includes "ARM private" system calls starting at |__ARM_NR_BASE|, | 223 // ARM EABI includes "ARM private" system calls starting at |__ARM_NR_BASE|, |
156 // and a "ghost syscall private to the kernel", cmpxchg, | 224 // and a "ghost syscall private to the kernel", cmpxchg, |
157 // at |__ARM_NR_BASE+0x00fff0|. | 225 // at |__ARM_NR_BASE+0x00fff0|. |
158 // See </arch/arm/include/asm/unistd.h> in the Linux kernel. | 226 // See </arch/arm/include/asm/unistd.h> in the Linux kernel. |
159 #define MIN_SYSCALL ((unsigned int)__NR_SYSCALL_BASE) | 227 #define MIN_SYSCALL ((unsigned int)__NR_SYSCALL_BASE) |
160 #define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + 1024u) | 228 #define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + 1024u) |
161 #define MIN_PRIVATE_SYSCALL ((unsigned int)__ARM_NR_BASE) | 229 #define MIN_PRIVATE_SYSCALL ((unsigned int)__ARM_NR_BASE) |
162 #define MAX_PRIVATE_SYSCALL (MIN_PRIVATE_SYSCALL + 16u) | 230 #define MAX_PRIVATE_SYSCALL (MIN_PRIVATE_SYSCALL + 16u) |
163 #define MIN_GHOST_SYSCALL ((unsigned int)__ARM_NR_BASE + 0xfff0u) | 231 #define MIN_GHOST_SYSCALL ((unsigned int)__ARM_NR_BASE + 0xfff0u) |
(...skipping 18 matching lines...) Expand all Loading... |
182 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) | 250 #define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) |
183 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ | 251 #define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ |
184 instruction_pointer) + 4) | 252 instruction_pointer) + 4) |
185 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ | 253 #define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ |
186 instruction_pointer) + 0) | 254 instruction_pointer) + 0) |
187 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 255 #define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
188 8*(nr) + 4) | 256 8*(nr) + 4) |
189 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ | 257 #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
190 8*(nr) + 0) | 258 8*(nr) + 0) |
191 | 259 |
| 260 struct pt_regs { |
| 261 unsigned long r0; |
| 262 unsigned long r1; |
| 263 unsigned long r2; |
| 264 unsigned long r3; |
| 265 unsigned long r4; |
| 266 unsigned long r5; |
| 267 unsigned long r6; |
| 268 unsigned long r7; |
| 269 unsigned long r8; |
| 270 unsigned long r9; |
| 271 unsigned long r10; |
| 272 unsigned long fp; |
| 273 unsigned long ip; |
| 274 unsigned long sp; |
| 275 unsigned long lr; |
| 276 unsigned long pc; |
| 277 unsigned long cpsr; |
| 278 unsigned long orig_r0; |
| 279 } |
| 280 #define SECCOMP_PT_RESULT(_pt_regs) (_pt_regs).r0 |
| 281 #define SECCOMP_PT_SYSCALL(_pt_regs) (_pt_regs).r7 |
| 282 #define SECCOMP_PT_IP(_pt_regs) (_pt_regs).pc |
| 283 #define SECCOMP_PT_PARM1(_pt_regs) (_pt_regs).r0 |
| 284 #define SECCOMP_PT_PARM2(_pt_regs) (_pt_regs).r1 |
| 285 #define SECCOMP_PT_PARM3(_pt_regs) (_pt_regs).r2 |
| 286 #define SECCOMP_PT_PARM4(_pt_regs) (_pt_regs).r3 |
| 287 #define SECCOMP_PT_PARM5(_pt_regs) (_pt_regs).r4 |
| 288 #define SECCOMP_PT_PARM6(_pt_regs) (_pt_regs).r5 |
| 289 |
| 290 |
192 #else | 291 #else |
193 #error Unsupported target platform | 292 #error Unsupported target platform |
194 | 293 |
195 #endif | 294 #endif |
196 | 295 |
197 #endif // SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ | 296 #endif // SANDBOX_LINUX_SECCOMP_BPF_LINUX_SECCOMP_H__ |
OLD | NEW |