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_fd" should be a file descriptor for "/proc", or -1 if not provided | 75 // "proc_fd" should be a file descriptor for "/proc", or -1 if not provided |
76 // by the caller. | 76 // by the caller. |
77 static int supportsSeccompSandbox(int proc_fd) | 77 static int supportsSeccompSandbox(int proc_fd) |
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 "setProcSelfMaps()". | 82 // provide an already opened file descriptor by calling "setProcSelf()". |
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. | 84 // eventually close it when "startSandbox()" executes. |
85 static void setProcSelfMaps(int proc_self_maps) | 85 static void setProcSelf(int proc_self) asm("SeccompSandboxSetProcSelf"); |
86 asm("SeccompSandboxSetProcSelfMaps"); | |
87 | 86 |
88 // This is the main public entry point. It finds all system calls that | 87 // This is the main public entry point. It finds all system calls that |
89 // need rewriting, sets up the resources needed by the sandbox, and | 88 // need rewriting, sets up the resources needed by the sandbox, and |
90 // enters Seccomp mode. | 89 // enters Seccomp mode. |
91 static void startSandbox() asm("StartSeccompSandbox"); | 90 static void startSandbox() asm("StartSeccompSandbox"); |
92 | 91 |
93 // TODO(mseaborn): Consider re-instating this declaration. | 92 // TODO(mseaborn): Consider re-instating this declaration. |
94 // private: | 93 // private: |
95 | 94 |
96 struct RequestHeader { | 95 struct RequestHeader { |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 __attribute__((noreturn)); | 634 __attribute__((noreturn)); |
636 | 635 |
637 // Fork()s of the trusted process. | 636 // Fork()s of the trusted process. |
638 static SecureMem::Args* createTrustedProcess(int processFdPub, int sandboxFd, | 637 static SecureMem::Args* createTrustedProcess(int processFdPub, int sandboxFd, |
639 int cloneFdPub, int cloneFd); | 638 int cloneFdPub, int cloneFd); |
640 | 639 |
641 // Creates the trusted thread for the initial thread, then enables | 640 // Creates the trusted thread for the initial thread, then enables |
642 // Seccomp mode. | 641 // Seccomp mode. |
643 static void createTrustedThread(SecureMem::Args* secureMem); | 642 static void createTrustedThread(SecureMem::Args* secureMem); |
644 | 643 |
| 644 static int proc_self_; |
645 static int proc_self_maps_; | 645 static int proc_self_maps_; |
646 static enum SandboxStatus { | 646 static enum SandboxStatus { |
647 STATUS_UNKNOWN, STATUS_UNSUPPORTED, STATUS_AVAILABLE, STATUS_ENABLED | 647 STATUS_UNKNOWN, STATUS_UNSUPPORTED, STATUS_AVAILABLE, STATUS_ENABLED |
648 } status_; | 648 } status_; |
649 static int pid_; | 649 static int pid_; |
650 static int processFdPub_; | 650 static int processFdPub_; |
651 static int cloneFdPub_ asm("playground$cloneFdPub") INTERNAL; | 651 static int cloneFdPub_ asm("playground$cloneFdPub") INTERNAL; |
652 | 652 |
653 #ifdef __i386__ | 653 #ifdef __i386__ |
654 struct SocketCallArgInfo; | 654 struct SocketCallArgInfo; |
(...skipping 25 matching lines...) Expand all Loading... |
680 extern struct SandboxPolicy g_policy; | 680 extern struct SandboxPolicy g_policy; |
681 | 681 |
682 typedef void (*CreateTrustedThreadFunc)(SecureMem::Args* secureMem); | 682 typedef void (*CreateTrustedThreadFunc)(SecureMem::Args* secureMem); |
683 extern CreateTrustedThreadFunc g_create_trusted_thread; | 683 extern CreateTrustedThreadFunc g_create_trusted_thread; |
684 | 684 |
685 } // namespace | 685 } // namespace |
686 | 686 |
687 using playground::Sandbox; | 687 using playground::Sandbox; |
688 | 688 |
689 #endif // SANDBOX_IMPL_H__ | 689 #endif // SANDBOX_IMPL_H__ |
OLD | NEW |