diff options
author | nedeljko.babic@imgtec.com <nedeljko.babic@imgtec.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 21:00:12 +0000 |
---|---|---|
committer | nedeljko.babic@imgtec.com <nedeljko.babic@imgtec.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 21:00:12 +0000 |
commit | 33447b3cc4995b6bd2086a30d61bfebe60053b8f (patch) | |
tree | 816b2e67231785aabb8f7381b13d473070aa93ba /sandbox | |
parent | b856433e86b51eeb230c727095af5108dad61e86 (diff) | |
download | chromium_src-33447b3cc4995b6bd2086a30d61bfebe60053b8f.zip chromium_src-33447b3cc4995b6bd2086a30d61bfebe60053b8f.tar.gz chromium_src-33447b3cc4995b6bd2086a30d61bfebe60053b8f.tar.bz2 |
Linux sandbox: add space for 8 parameters to the Syscall() class
On some architectures (Mips for example) syscalls can take more
than six parameters.
Add support for 8 native-size parameters in Syscall::Call()
BUG=369594
TEST= sandbox_linux_unittests
Review URL: https://codereview.chromium.org/357323003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281823 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/linux/seccomp-bpf/syscall.cc | 11 | ||||
-rw-r--r-- | sandbox/linux/seccomp-bpf/syscall.h | 92 |
2 files changed, 80 insertions, 23 deletions
diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc index 64c0b8e..0a028b72 100644 --- a/sandbox/linux/seccomp-bpf/syscall.cc +++ b/sandbox/linux/seccomp-bpf/syscall.cc @@ -8,6 +8,7 @@ #include <errno.h> #include "base/basictypes.h" +#include "base/logging.h" namespace sandbox { @@ -181,7 +182,9 @@ intptr_t Syscall::Call(int nr, intptr_t p2, intptr_t p3, intptr_t p4, - intptr_t p5) { + intptr_t p5, + intptr_t p6, + intptr_t p7) { // We rely on "intptr_t" to be the exact size as a "void *". This is // typically true, but just in case, we add a check. The language // specification allows platforms some leeway in cases, where @@ -192,6 +195,12 @@ intptr_t Syscall::Call(int nr, COMPILE_ASSERT(sizeof(void*) == sizeof(intptr_t), pointer_types_and_intptr_must_be_exactly_the_same_size); + // TODO(nedeljko): Enable use of more than six parameters on architectures + // where that makes sense. + DCHECK_EQ(p6, 0) << " Support for syscalls with more than six arguments not " + "added for this architecture"; + DCHECK_EQ(p7, 0) << " Support for syscalls with more than six arguments not " + "added for this architecture"; const intptr_t args[6] = {p0, p1, p2, p3, p4, p5}; // Invoke our file-scope assembly code. The constraints have been picked diff --git a/sandbox/linux/seccomp-bpf/syscall.h b/sandbox/linux/seccomp-bpf/syscall.h index 57970a3..10a1253 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); }; |