Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: sandbox/linux/seccomp-bpf/syscall.h

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SYSCALL_H__ 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ 6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "sandbox/sandbox_export.h" 10 #include "sandbox/sandbox_export.h"
11 11
12 namespace sandbox { 12 namespace sandbox {
13 13
14 // We have to make sure that we have a single "magic" return address for 14 // We have to make sure that we have a single "magic" return address for
jln (very slow on Chromium) 2014/06/03 01:00:33 Could you add some explicit documentation that thi
nedeljko 2014/06/03 15:32:18 Done.
15 // our system calls, which we can check from within a BPF filter. This 15 // our system calls, which we can check from within a BPF filter. This
16 // works by writing a little bit of asm() code that a) enters the kernel, and 16 // works by writing a little bit of asm() code that a) enters the kernel, and
17 // that also b) can be invoked in a way that computes this return address. 17 // that also b) can be invoked in a way that computes this return address.
18 // Passing "nr" as "-1" computes the "magic" return address. Passing any 18 // Passing "nr" as "-1" computes the "magic" return address. Passing any
19 // other value invokes the appropriate system call. 19 // other value invokes the appropriate system call.
20 SANDBOX_EXPORT intptr_t SandboxSyscall(int nr, 20 SANDBOX_EXPORT intptr_t SandboxSyscall(int nr,
21 intptr_t p0, 21 intptr_t p0,
22 intptr_t p1, 22 intptr_t p1,
23 intptr_t p2, 23 intptr_t p2,
24 intptr_t p3, 24 intptr_t p3,
25 intptr_t p4, 25 intptr_t p4,
26 intptr_t p5); 26 intptr_t p5);
27 27
28 #if defined(__mips__)
29 // This function basically does on MIPS what SandboxSyscall() is doing on
30 // othere architectures. However, because of specificity of MIPS regarding
31 // handelling syscall errors, SandboxSyscall() is made as a wrapper for this
32 // function in order for SandboxSyscall() to behave more like on othere
33 // architectures on places where return value from SandboxSyscall() is used
34 // directly (like in the most tests).
jln (very slow on Chromium) 2014/06/03 01:00:33 "like in most tests"
nedeljko 2014/06/03 15:32:18 Done.
35 intptr_t SandboxSyscallRaw(int nr,
jln (very slow on Chromium) 2014/06/03 01:00:33 Please, document |args| and |err_stat|
nedeljko 2014/06/03 15:32:18 Done.
36 const intptr_t *args,
jln (very slow on Chromium) 2014/06/03 01:00:33 Nit: chromium style is "type* variable".
nedeljko 2014/06/03 15:32:18 I was looking at the syscall.cc when I wrote this
37 intptr_t *err_stat);
38 #endif // defined(__mips__)
39
28 // System calls can take up to six parameters. Traditionally, glibc 40 // System calls can take up to six parameters. Traditionally, glibc
29 // implements this property by using variadic argument lists. This works, but 41 // implements this property by using variadic argument lists. This works, but
30 // confuses modern tools such as valgrind, because we are nominally passing 42 // confuses modern tools such as valgrind, because we are nominally passing
31 // uninitialized data whenever we call through this function and pass less 43 // uninitialized data whenever we call through this function and pass less
32 // than the full six arguments. 44 // than the full six arguments.
33 // So, instead, we use C++'s template system to achieve a very similar 45 // So, instead, we use C++'s template system to achieve a very similar
34 // effect. C++ automatically sets the unused parameters to zero for us, and 46 // effect. C++ automatically sets the unused parameters to zero for us, and
35 // it also does the correct type expansion (e.g. from 32bit to 64bit) where 47 // it also does the correct type expansion (e.g. from 32bit to 64bit) where
36 // necessary. 48 // necessary.
37 // We have to use C-style cast operators as we want to be able to accept both 49 // We have to use C-style cast operators as we want to be able to accept both
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 __attribute__((always_inline)); 151 __attribute__((always_inline));
140 SANDBOX_EXPORT inline intptr_t SandboxSyscall(int nr) { 152 SANDBOX_EXPORT inline intptr_t SandboxSyscall(int nr) {
141 return SandboxSyscall(nr, 0, 0, 0, 0, 0, 0); 153 return SandboxSyscall(nr, 0, 0, 0, 0, 0, 0);
142 } 154 }
143 155
144 #endif // Pre-C++11 156 #endif // Pre-C++11
145 157
146 } // namespace sandbox 158 } // namespace sandbox
147 159
148 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ 160 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698