| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "services/shell/runner/host/linux_sandbox.h" | 5 #include "services/shell/runner/host/linux_sandbox.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <sys/syscall.h> | 8 #include <sys/syscall.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace shell { | 31 namespace shell { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 intptr_t SandboxSIGSYSHandler(const struct sandbox::arch_seccomp_data& args, | 35 intptr_t SandboxSIGSYSHandler(const struct sandbox::arch_seccomp_data& args, |
| 36 void* aux) { | 36 void* aux) { |
| 37 RAW_CHECK(aux); | 37 RAW_CHECK(aux); |
| 38 const sandbox::syscall_broker::BrokerProcess* broker_process = | 38 const sandbox::syscall_broker::BrokerProcess* broker_process = |
| 39 static_cast<const sandbox::syscall_broker::BrokerProcess*>(aux); | 39 static_cast<const sandbox::syscall_broker::BrokerProcess*>(aux); |
| 40 switch (args.nr) { | 40 switch (args.nr) { |
| 41 #if defined(__NR_access) |
| 41 case __NR_access: | 42 case __NR_access: |
| 42 return broker_process->Access(reinterpret_cast<const char*>(args.args[0]), | 43 return broker_process->Access(reinterpret_cast<const char*>(args.args[0]), |
| 43 static_cast<int>(args.args[1])); | 44 static_cast<int>(args.args[1])); |
| 45 #endif |
| 46 #if defined(__NR_open) |
| 44 case __NR_open: | 47 case __NR_open: |
| 45 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]), | 48 return broker_process->Open(reinterpret_cast<const char*>(args.args[0]), |
| 46 static_cast<int>(args.args[1])); | 49 static_cast<int>(args.args[1])); |
| 50 #endif |
| 47 case __NR_faccessat: | 51 case __NR_faccessat: |
| 48 if (static_cast<int>(args.args[0]) == AT_FDCWD) { | 52 if (static_cast<int>(args.args[0]) == AT_FDCWD) { |
| 49 return broker_process->Access( | 53 return broker_process->Access( |
| 50 reinterpret_cast<const char*>(args.args[1]), | 54 reinterpret_cast<const char*>(args.args[1]), |
| 51 static_cast<int>(args.args[2])); | 55 static_cast<int>(args.args[2])); |
| 52 } else { | 56 } else { |
| 53 return -EPERM; | 57 return -EPERM; |
| 54 } | 58 } |
| 55 case __NR_openat: | 59 case __NR_openat: |
| 56 // Allow using openat() as open(). | 60 // Allow using openat() as open(). |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 sandbox::syscall_broker::BrokerProcess* leaked_broker = broker_.release(); | 162 sandbox::syscall_broker::BrokerProcess* leaked_broker = broker_.release(); |
| 159 ALLOW_UNUSED_LOCAL(leaked_broker); | 163 ALLOW_UNUSED_LOCAL(leaked_broker); |
| 160 ANNOTATE_LEAKING_OBJECT_PTR(leaked_broker); | 164 ANNOTATE_LEAKING_OBJECT_PTR(leaked_broker); |
| 161 } | 165 } |
| 162 | 166 |
| 163 void LinuxSandbox::Seal() { | 167 void LinuxSandbox::Seal() { |
| 164 proc_fd_.reset(); | 168 proc_fd_.reset(); |
| 165 } | 169 } |
| 166 | 170 |
| 167 } // namespace shell | 171 } // namespace shell |
| OLD | NEW |