Chromium Code Reviews| 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1870 #endif | 1870 #endif |
| 1871 | 1871 |
| 1872 #if defined(__arm__) | 1872 #if defined(__arm__) |
| 1873 #ifndef PTRACE_SET_SYSCALL | 1873 #ifndef PTRACE_SET_SYSCALL |
| 1874 #define PTRACE_SET_SYSCALL 23 | 1874 #define PTRACE_SET_SYSCALL 23 |
| 1875 #endif | 1875 #endif |
| 1876 #endif | 1876 #endif |
| 1877 | 1877 |
| 1878 #if defined(__aarch64__) | 1878 #if defined(__aarch64__) |
| 1879 #ifndef PTRACE_GETREGS | 1879 #ifndef PTRACE_GETREGS |
| 1880 #ifdef __GLIBC__ | |
|
Jorge Lucangeli Obes
2016/11/22 16:56:49
Please use #if defined(...) here.
| |
| 1881 #define PTRACE_GETREGS static_cast<enum __ptrace_request>(12) | |
| 1882 #else | |
| 1880 #define PTRACE_GETREGS 12 | 1883 #define PTRACE_GETREGS 12 |
| 1881 #endif | 1884 #endif |
|
Jorge Lucangeli Obes
2016/11/22 16:56:49
We have too many endifs. Let's comment what they d
| |
| 1882 #endif | 1885 #endif |
| 1886 #endif | |
| 1883 | 1887 |
| 1884 #if defined(__aarch64__) | 1888 #if defined(__aarch64__) |
| 1885 #ifndef PTRACE_SETREGS | 1889 #ifndef PTRACE_SETREGS |
| 1890 #ifdef __GLIBC__ | |
|
Jorge Lucangeli Obes
2016/11/22 16:56:49
Same.
| |
| 1891 #define PTRACE_SETREGS static_cast<enum __ptrace_request>(13) | |
| 1892 #else | |
| 1886 #define PTRACE_SETREGS 13 | 1893 #define PTRACE_SETREGS 13 |
| 1887 #endif | 1894 #endif |
|
Jorge Lucangeli Obes
2016/11/22 16:56:49
Same:
#endif // defined(__GLIBC__)
#endif // !d
| |
| 1888 #endif | 1895 #endif |
| 1896 #endif | |
| 1889 | 1897 |
| 1890 // Changes the syscall to run for a child being sandboxed using seccomp-bpf with | 1898 // Changes the syscall to run for a child being sandboxed using seccomp-bpf with |
| 1891 // PTRACE_O_TRACESECCOMP. Should only be called when the child is stopped on | 1899 // PTRACE_O_TRACESECCOMP. Should only be called when the child is stopped on |
| 1892 // PTRACE_EVENT_SECCOMP. | 1900 // PTRACE_EVENT_SECCOMP. |
| 1893 // | 1901 // |
| 1894 // regs should contain the current set of registers of the child, obtained using | 1902 // regs should contain the current set of registers of the child, obtained using |
| 1895 // PTRACE_GETREGS. | 1903 // PTRACE_GETREGS. |
| 1896 // | 1904 // |
| 1897 // Depending on the architecture, this may modify regs, so the caller is | 1905 // Depending on the architecture, this may modify regs, so the caller is |
| 1898 // responsible for committing these changes using PTRACE_SETREGS. | 1906 // responsible for committing these changes using PTRACE_SETREGS. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2256 BPF_ASSERT_EQ(ENOSYS, errno); | 2264 BPF_ASSERT_EQ(ENOSYS, errno); |
| 2257 | 2265 |
| 2258 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300)); | 2266 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300)); |
| 2259 BPF_ASSERT_EQ(EPERM, errno); | 2267 BPF_ASSERT_EQ(EPERM, errno); |
| 2260 } | 2268 } |
| 2261 | 2269 |
| 2262 } // namespace | 2270 } // namespace |
| 2263 | 2271 |
| 2264 } // namespace bpf_dsl | 2272 } // namespace bpf_dsl |
| 2265 } // namespace sandbox | 2273 } // namespace sandbox |
| OLD | NEW |