OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_IMPL_H__ | 5 #ifndef SANDBOX_IMPL_H__ |
6 #define SANDBOX_IMPL_H__ | 6 #define SANDBOX_IMPL_H__ |
7 | 7 |
8 #include <asm/ldt.h> | 8 #include <asm/ldt.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // This could be because the kernel does not support Seccomp mode, or it | 72 // This could be because the kernel does not support Seccomp mode, or it |
73 // could be because we fail to successfully rewrite all system call entry | 73 // could be because we fail to successfully rewrite all system call entry |
74 // points. | 74 // points. |
75 // "proc" should be a file descriptor for "/proc", or -1 if not provided by | 75 // "proc" should be a file descriptor for "/proc", or -1 if not provided by |
76 // the caller. | 76 // the caller. |
77 static int supportsSeccompSandbox(int proc) | 77 static int supportsSeccompSandbox(int proc) |
78 asm("SupportsSeccompSandbox"); | 78 asm("SupportsSeccompSandbox"); |
79 | 79 |
80 // The sandbox needs to be able to access "/proc/self/maps". If this file | 80 // The sandbox needs to be able to access "/proc/self/maps". If this file |
81 // is not accessible when "startSandbox()" gets called, the caller can | 81 // is not accessible when "startSandbox()" gets called, the caller can |
82 // provide an already opened file descriptor by calling "setProcSelf()". | 82 // provide an already opened file descriptor by calling "setProcFd()". |
83 // The sandbox becomes the newer owner of this file descriptor and will | 83 // The sandbox becomes the newer owner of this file descriptor and will |
84 // eventually close it when "startSandbox()" executes. But if the caller | 84 // eventually close it. After calling setProcFd(), the caller MUST eventually |
85 // never ends up calling startSandbox(), then the caller must close the | 85 // call startSandbox(), or resources could be leaked. |
86 // file descriptor. | |
87 static void setProcFd(int proc) asm("SeccompSandboxSetProcFd"); | 86 static void setProcFd(int proc) asm("SeccompSandboxSetProcFd"); |
88 | 87 |
89 // This is the main public entry point. It finds all system calls that | 88 // This is the main public entry point. It finds all system calls that |
90 // need rewriting, sets up the resources needed by the sandbox, and | 89 // need rewriting, sets up the resources needed by the sandbox, and |
91 // enters Seccomp mode. | 90 // enters Seccomp mode. |
92 static void startSandbox() asm("StartSeccompSandbox"); | 91 static void startSandbox() asm("StartSeccompSandbox"); |
93 | 92 |
94 // TODO(mseaborn): Consider re-instating this declaration. | 93 // TODO(mseaborn): Consider re-instating this declaration. |
95 // private: | 94 // private: |
96 | 95 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 extern struct SandboxPolicy g_policy; | 681 extern struct SandboxPolicy g_policy; |
683 | 682 |
684 typedef void (*CreateTrustedThreadFunc)(SecureMem::Args* secureMem); | 683 typedef void (*CreateTrustedThreadFunc)(SecureMem::Args* secureMem); |
685 extern CreateTrustedThreadFunc g_create_trusted_thread; | 684 extern CreateTrustedThreadFunc g_create_trusted_thread; |
686 | 685 |
687 } // namespace | 686 } // namespace |
688 | 687 |
689 using playground::Sandbox; | 688 using playground::Sandbox; |
690 | 689 |
691 #endif // SANDBOX_IMPL_H__ | 690 #endif // SANDBOX_IMPL_H__ |
OLD | NEW |