| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // Note: any code in this file MUST be async-signal safe. | 5 // Note: any code in this file MUST be async-signal safe. |
| 6 | 6 |
| 7 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 7 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 8 | 8 |
| 9 #include <sys/syscall.h> | 9 #include <sys/syscall.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 16 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 17 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 17 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 18 #include "sandbox/linux/seccomp-bpf/syscall.h" | 18 #include "sandbox/linux/seccomp-bpf/syscall.h" |
| 19 #include "sandbox/linux/services/linux_syscalls.h" | 19 #include "sandbox/linux/services/linux_syscalls.h" |
| 20 #include "sandbox/linux/services/syscall_wrappers.h" |
| 20 | 21 |
| 21 #if defined(__mips__) | 22 #if defined(__mips__) |
| 22 // __NR_Linux, is defined in <asm/unistd.h>. | 23 // __NR_Linux, is defined in <asm/unistd.h>. |
| 23 #include <asm/unistd.h> | 24 #include <asm/unistd.h> |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 #define SECCOMP_MESSAGE_COMMON_CONTENT "seccomp-bpf failure" | 27 #define SECCOMP_MESSAGE_COMMON_CONTENT "seccomp-bpf failure" |
| 27 #define SECCOMP_MESSAGE_CLONE_CONTENT "clone() failure" | 28 #define SECCOMP_MESSAGE_CLONE_CONTENT "clone() failure" |
| 28 #define SECCOMP_MESSAGE_PRCTL_CONTENT "prctl() failure" | 29 #define SECCOMP_MESSAGE_PRCTL_CONTENT "prctl() failure" |
| 29 #define SECCOMP_MESSAGE_IOCTL_CONTENT "ioctl() failure" | 30 #define SECCOMP_MESSAGE_IOCTL_CONTENT "ioctl() failure" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 switch (args.nr) { | 217 switch (args.nr) { |
| 217 case __NR_sched_getaffinity: | 218 case __NR_sched_getaffinity: |
| 218 case __NR_sched_getattr: | 219 case __NR_sched_getattr: |
| 219 case __NR_sched_getparam: | 220 case __NR_sched_getparam: |
| 220 case __NR_sched_getscheduler: | 221 case __NR_sched_getscheduler: |
| 221 case __NR_sched_rr_get_interval: | 222 case __NR_sched_rr_get_interval: |
| 222 case __NR_sched_setaffinity: | 223 case __NR_sched_setaffinity: |
| 223 case __NR_sched_setattr: | 224 case __NR_sched_setattr: |
| 224 case __NR_sched_setparam: | 225 case __NR_sched_setparam: |
| 225 case __NR_sched_setscheduler: | 226 case __NR_sched_setscheduler: |
| 226 const pid_t tid = syscall(__NR_gettid); | 227 const pid_t tid = sys_gettid(); |
| 227 // The first argument is the pid. If is our thread id, then replace it | 228 // The first argument is the pid. If is our thread id, then replace it |
| 228 // with 0, which is equivalent and allowed by the policy. | 229 // with 0, which is equivalent and allowed by the policy. |
| 229 if (args.args[0] == static_cast<uint64_t>(tid)) { | 230 if (args.args[0] == static_cast<uint64_t>(tid)) { |
| 230 return Syscall::Call(args.nr, | 231 return Syscall::Call(args.nr, |
| 231 0, | 232 0, |
| 232 static_cast<intptr_t>(args.args[1]), | 233 static_cast<intptr_t>(args.args[1]), |
| 233 static_cast<intptr_t>(args.args[2]), | 234 static_cast<intptr_t>(args.args[2]), |
| 234 static_cast<intptr_t>(args.args[3]), | 235 static_cast<intptr_t>(args.args[3]), |
| 235 static_cast<intptr_t>(args.args[4]), | 236 static_cast<intptr_t>(args.args[4]), |
| 236 static_cast<intptr_t>(args.args[5])); | 237 static_cast<intptr_t>(args.args[5])); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 292 |
| 292 const char* GetKillErrorMessageContentForTests() { | 293 const char* GetKillErrorMessageContentForTests() { |
| 293 return SECCOMP_MESSAGE_KILL_CONTENT; | 294 return SECCOMP_MESSAGE_KILL_CONTENT; |
| 294 } | 295 } |
| 295 | 296 |
| 296 const char* GetFutexErrorMessageContentForTests() { | 297 const char* GetFutexErrorMessageContentForTests() { |
| 297 return SECCOMP_MESSAGE_FUTEX_CONTENT; | 298 return SECCOMP_MESSAGE_FUTEX_CONTENT; |
| 298 } | 299 } |
| 299 | 300 |
| 300 } // namespace sandbox. | 301 } // namespace sandbox. |
| OLD | NEW |