| Index: sandbox/linux/seccomp-bpf/syscall.h
|
| diff --git a/sandbox/linux/seccomp-bpf/syscall.h b/sandbox/linux/seccomp-bpf/syscall.h
|
| index 57970a35b040641069969b4874bf369a0aca990a..10a1253e8c2be65a265665dfc0e7fa2a86208f0f 100644
|
| --- a/sandbox/linux/seccomp-bpf/syscall.h
|
| +++ b/sandbox/linux/seccomp-bpf/syscall.h
|
| @@ -16,21 +16,8 @@ namespace sandbox {
|
| // low-level control.
|
| class SANDBOX_EXPORT Syscall {
|
| public:
|
| - // This performs system call |nr| with the arguments p0 to p5 from a constant
|
| - // userland address, which is for instance observable by seccomp-bpf filters.
|
| - // The constant userland address from which these system calls are made will
|
| - // be returned if |nr| is passed as -1.
|
| - // On error, this function will return a value between -1 and -4095 which
|
| - // should be interpreted as -errno.
|
| - static intptr_t Call(int nr,
|
| - intptr_t p0,
|
| - intptr_t p1,
|
| - intptr_t p2,
|
| - intptr_t p3,
|
| - intptr_t p4,
|
| - intptr_t p5);
|
| -
|
| - // System calls can take up to six parameters. Traditionally, glibc
|
| + // System calls can take up to six parameters (up to eight on some
|
| + // architectures). Traditionally, glibc
|
| // implements this property by using variadic argument lists. This works, but
|
| // confuses modern tools such as valgrind, because we are nominally passing
|
| // uninitialized data whenever we call through this function and pass less
|
| @@ -41,6 +28,47 @@ class SANDBOX_EXPORT Syscall {
|
| // necessary.
|
| // We have to use C-style cast operators as we want to be able to accept both
|
| // integer and pointer types.
|
| + template <class T0,
|
| + class T1,
|
| + class T2,
|
| + class T3,
|
| + class T4,
|
| + class T5,
|
| + class T6,
|
| + class T7>
|
| + static inline intptr_t
|
| + Call(int nr, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7) {
|
| + return Call(nr,
|
| + (intptr_t)p0,
|
| + (intptr_t)p1,
|
| + (intptr_t)p2,
|
| + (intptr_t)p3,
|
| + (intptr_t)p4,
|
| + (intptr_t)p5,
|
| + (intptr_t)p6,
|
| + (intptr_t)p7);
|
| + }
|
| +
|
| + template <class T0,
|
| + class T1,
|
| + class T2,
|
| + class T3,
|
| + class T4,
|
| + class T5,
|
| + class T6>
|
| + static inline intptr_t
|
| + Call(int nr, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6) {
|
| + return Call(nr,
|
| + (intptr_t)p0,
|
| + (intptr_t)p1,
|
| + (intptr_t)p2,
|
| + (intptr_t)p3,
|
| + (intptr_t)p4,
|
| + (intptr_t)p5,
|
| + (intptr_t)p6,
|
| + 0);
|
| + }
|
| +
|
| template <class T0, class T1, class T2, class T3, class T4, class T5>
|
| static inline intptr_t
|
| Call(int nr, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) {
|
| @@ -50,37 +78,57 @@ class SANDBOX_EXPORT Syscall {
|
| (intptr_t)p2,
|
| (intptr_t)p3,
|
| (intptr_t)p4,
|
| - (intptr_t)p5);
|
| + (intptr_t)p5,
|
| + 0,
|
| + 0);
|
| }
|
|
|
| template <class T0, class T1, class T2, class T3, class T4>
|
| static inline intptr_t Call(int nr, T0 p0, T1 p1, T2 p2, T3 p3, T4 p4) {
|
| - return Call(nr, p0, p1, p2, p3, p4, 0);
|
| + return Call(nr, p0, p1, p2, p3, p4, 0, 0, 0);
|
| }
|
|
|
| template <class T0, class T1, class T2, class T3>
|
| static inline intptr_t Call(int nr, T0 p0, T1 p1, T2 p2, T3 p3) {
|
| - return Call(nr, p0, p1, p2, p3, 0, 0);
|
| + return Call(nr, p0, p1, p2, p3, 0, 0, 0, 0);
|
| }
|
|
|
| template <class T0, class T1, class T2>
|
| static inline intptr_t Call(int nr, T0 p0, T1 p1, T2 p2) {
|
| - return Call(nr, p0, p1, p2, 0, 0, 0);
|
| + return Call(nr, p0, p1, p2, 0, 0, 0, 0, 0);
|
| }
|
|
|
| template <class T0, class T1>
|
| static inline intptr_t Call(int nr, T0 p0, T1 p1) {
|
| - return Call(nr, p0, p1, 0, 0, 0, 0);
|
| + return Call(nr, p0, p1, 0, 0, 0, 0, 0, 0);
|
| }
|
|
|
| template <class T0>
|
| static inline intptr_t Call(int nr, T0 p0) {
|
| - return Call(nr, p0, 0, 0, 0, 0, 0);
|
| + return Call(nr, p0, 0, 0, 0, 0, 0, 0, 0);
|
| }
|
|
|
| - static inline intptr_t Call(int nr) { return Call(nr, 0, 0, 0, 0, 0, 0); }
|
| + static inline intptr_t Call(int nr) {
|
| + return Call(nr, 0, 0, 0, 0, 0, 0, 0, 0);
|
| + }
|
|
|
| private:
|
| + // This performs system call |nr| with the arguments p0 to p7 from a constant
|
| + // userland address, which is for instance observable by seccomp-bpf filters.
|
| + // The constant userland address from which these system calls are made will
|
| + // be returned if |nr| is passed as -1.
|
| + // On error, this function will return a value between -1 and -4095 which
|
| + // should be interpreted as -errno.
|
| + static intptr_t Call(int nr,
|
| + intptr_t p0,
|
| + intptr_t p1,
|
| + intptr_t p2,
|
| + intptr_t p3,
|
| + intptr_t p4,
|
| + intptr_t p5,
|
| + intptr_t p6,
|
| + intptr_t p7);
|
| +
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(Syscall);
|
| };
|
|
|
|
|