[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 1 | # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/features.gni") |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 6 | import("//build/config/nacl/config.gni") |
rsesek | 7b1273af0 | 2016-12-06 20:55:47 | [diff] [blame] | 7 | import("//sandbox/features.gni") |
qsr | fb5251d1 | 2015-01-21 15:57:22 | [diff] [blame] | 8 | import("//testing/test.gni") |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 9 | |
pkotwicz | bbe8d90 | 2015-10-29 17:10:07 | [diff] [blame] | 10 | if (is_android) { |
| 11 | import("//build/config/android/rules.gni") |
| 12 | } |
| 13 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 14 | declare_args() { |
| 15 | compile_suid_client = is_linux |
| 16 | |
| 17 | compile_credentials = is_linux |
| 18 | |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 19 | # On Android, use plain GTest. |
| 20 | use_base_test_suite = is_linux |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 21 | } |
| 22 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 23 | if (is_nacl_nonsfi) { |
| 24 | config("nacl_nonsfi_warnings") { |
| 25 | # There are number of platform specific functions in |
| 26 | # seccomp-bpf syscall helpers, which are not being used. |
| 27 | cflags = [ "-Wno-unused-function" ] |
| 28 | } |
| 29 | } |
| 30 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 31 | # We have two principal targets: sandbox and sandbox_linux_unittests |
| 32 | # All other targets are listed as dependencies. |
| 33 | # There is one notable exception: for historical reasons, chrome_sandbox is |
| 34 | # the setuid sandbox and is its own target. |
| 35 | |
| 36 | group("sandbox") { |
brettw | 00709df | 2015-12-02 01:40:50 | [diff] [blame] | 37 | public_deps = [ |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 38 | ":sandbox_services", |
| 39 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 40 | if (compile_suid_client || is_nacl_nonsfi) { |
brettw | 00709df | 2015-12-02 01:40:50 | [diff] [blame] | 41 | public_deps += [ ":suid_sandbox_client" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 42 | } |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 43 | if (use_seccomp_bpf || is_nacl_nonsfi) { |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 44 | public_deps += [ ":seccomp_bpf" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 45 | } |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 46 | if (is_android) { |
| 47 | public_deps += [ ":seccomp_starter_android" ] |
| 48 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | source_set("sandbox_linux_test_utils") { |
Brett Wilson | 0c8745a | 2014-09-08 22:59:49 | [diff] [blame] | 52 | testonly = true |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 53 | sources = [ |
| 54 | "tests/sandbox_test_runner.cc", |
| 55 | "tests/sandbox_test_runner.h", |
| 56 | "tests/sandbox_test_runner_function_pointer.cc", |
| 57 | "tests/sandbox_test_runner_function_pointer.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 58 | "tests/unit_tests.cc", |
| 59 | "tests/unit_tests.h", |
| 60 | ] |
| 61 | |
| 62 | deps = [ |
| 63 | "//testing/gtest", |
| 64 | ] |
| 65 | |
phosek | ca8571a9 | 2015-12-17 16:35:42 | [diff] [blame] | 66 | if (!is_nacl_nonsfi) { |
| 67 | sources += [ |
| 68 | "tests/test_utils.cc", |
| 69 | "tests/test_utils.h", |
| 70 | ] |
| 71 | } |
| 72 | |
| 73 | if (use_seccomp_bpf || is_nacl_nonsfi) { |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 74 | sources += [ |
| 75 | "seccomp-bpf/bpf_tester_compatibility_delegate.h", |
| 76 | "seccomp-bpf/bpf_tests.h", |
| 77 | "seccomp-bpf/sandbox_bpf_test_runner.cc", |
| 78 | "seccomp-bpf/sandbox_bpf_test_runner.h", |
| 79 | ] |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 80 | deps += [ ":seccomp_bpf" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 81 | } |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 82 | |
| 83 | if (use_base_test_suite) { |
| 84 | deps += [ "//base/test:test_support" ] |
| 85 | defines = [ "SANDBOX_USES_BASE_TEST_SUITE" ] |
| 86 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 87 | } |
| 88 | |
pkotwicz | 41889e3 | 2015-10-28 22:17:48 | [diff] [blame] | 89 | # Sources for sandbox_linux_unittests. |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 90 | source_set("sandbox_linux_unittests_sources") { |
| 91 | testonly = true |
| 92 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 93 | sources = [ |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 94 | "services/proc_util_unittest.cc", |
jln | 97718598 | 2015-02-13 20:58:41 | [diff] [blame] | 95 | "services/resource_limits_unittests.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 96 | "services/scoped_process_unittest.cc", |
jln | c420f0d | 2014-11-22 01:12:09 | [diff] [blame] | 97 | "services/syscall_wrappers_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 98 | "services/thread_helpers_unittests.cc", |
| 99 | "services/yama_unittests.cc", |
leecam | ad78f42 | 2014-11-26 22:08:45 | [diff] [blame] | 100 | "syscall_broker/broker_file_permission_unittest.cc", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 101 | "syscall_broker/broker_process_unittest.cc", |
Greg Kerr | a722110 | 2018-05-14 19:31:31 | [diff] [blame] | 102 | "syscall_broker/broker_simple_message_unittest.cc", |
[email protected] | 232f6e11 | 2014-06-27 07:51:38 | [diff] [blame] | 103 | "tests/main.cc", |
| 104 | "tests/scoped_temporary_file.cc", |
| 105 | "tests/scoped_temporary_file.h", |
| 106 | "tests/scoped_temporary_file_unittest.cc", |
jln | c420f0d | 2014-11-22 01:12:09 | [diff] [blame] | 107 | "tests/test_utils_unittest.cc", |
[email protected] | 232f6e11 | 2014-06-27 07:51:38 | [diff] [blame] | 108 | "tests/unit_tests_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 109 | ] |
| 110 | |
| 111 | deps = [ |
| 112 | ":sandbox", |
| 113 | ":sandbox_linux_test_utils", |
| 114 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 115 | "//base/third_party/dynamic_annotations", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 116 | "//testing/gtest", |
| 117 | ] |
| 118 | |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 119 | if (use_base_test_suite) { |
| 120 | deps += [ "//base/test:test_support" ] |
| 121 | defines = [ "SANDBOX_USES_BASE_TEST_SUITE" ] |
| 122 | } |
| 123 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 124 | if (compile_suid_client) { |
mdempsky | 3cc942a | 2015-02-05 03:29:25 | [diff] [blame] | 125 | sources += [ |
| 126 | "suid/client/setuid_sandbox_client_unittest.cc", |
| 127 | "suid/client/setuid_sandbox_host_unittest.cc", |
| 128 | ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 129 | } |
| 130 | if (use_seccomp_bpf) { |
| 131 | sources += [ |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 132 | "bpf_dsl/bpf_dsl_unittest.cc", |
mdempsky | b80b1f5 | 2015-02-05 00:54:35 | [diff] [blame] | 133 | "bpf_dsl/codegen_unittest.cc", |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 134 | "bpf_dsl/cons_unittest.cc", |
mdempsky | 937389d | 2015-08-31 22:27:23 | [diff] [blame] | 135 | "bpf_dsl/dump_bpf.cc", |
| 136 | "bpf_dsl/dump_bpf.h", |
mdempsky | ce4c9f1 | 2015-02-05 06:23:05 | [diff] [blame] | 137 | "bpf_dsl/syscall_set_unittest.cc", |
mdempsky | 3909ebf | 2015-08-20 23:18:18 | [diff] [blame] | 138 | "bpf_dsl/test_trap_registry.cc", |
| 139 | "bpf_dsl/test_trap_registry.h", |
| 140 | "bpf_dsl/test_trap_registry_unittest.cc", |
mdempsky | 937389d | 2015-08-31 22:27:23 | [diff] [blame] | 141 | "bpf_dsl/verifier.cc", |
| 142 | "bpf_dsl/verifier.h", |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 143 | "integration_tests/bpf_dsl_seccomp_unittest.cc", |
| 144 | "integration_tests/seccomp_broker_process_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 145 | "seccomp-bpf-helpers/baseline_policy_unittest.cc", |
jln | fcdfb10 | 2014-09-12 02:47:44 | [diff] [blame] | 146 | "seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 147 | "seccomp-bpf/bpf_tests_unittest.cc", |
jln | a29d0a3 | 2014-11-26 22:38:35 | [diff] [blame] | 148 | "seccomp-bpf/sandbox_bpf_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 149 | "seccomp-bpf/syscall_unittest.cc", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 150 | "seccomp-bpf/trap_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 151 | ] |
mdempsky | a3fd0ec | 2015-08-26 00:45:52 | [diff] [blame] | 152 | deps += [ ":bpf_dsl_golden" ] |
Robert Sesek | a64d573 | 2018-03-29 13:55:37 | [diff] [blame] | 153 | |
| 154 | if (is_android) { |
| 155 | sources += [ "seccomp-bpf-helpers/baseline_policy_android_unittest.cc" ] |
| 156 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 157 | } |
| 158 | if (compile_credentials) { |
| 159 | sources += [ |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 160 | "integration_tests/namespace_unix_domain_socket_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 161 | "services/credentials_unittest.cc", |
rickyz | 41fb145 | 2015-01-27 03:57:58 | [diff] [blame] | 162 | "services/namespace_utils_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 163 | ] |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 164 | |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 165 | if (use_base_test_suite) { |
| 166 | # Tests that use advanced features not available in stock GTest. |
| 167 | sources += [ "services/namespace_sandbox_unittest.cc" ] |
| 168 | } |
| 169 | |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 170 | # For credentials_unittest.cc |
| 171 | configs += [ "//build/config/linux:libcap" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
mdempsky | a3fd0ec | 2015-08-26 00:45:52 | [diff] [blame] | 175 | action("bpf_dsl_golden") { |
| 176 | script = "bpf_dsl/golden/generate.py" |
| 177 | inputs = [ |
| 178 | "bpf_dsl/golden/i386/ArgSizePolicy.txt", |
| 179 | "bpf_dsl/golden/i386/BasicPolicy.txt", |
| 180 | "bpf_dsl/golden/i386/ElseIfPolicy.txt", |
| 181 | "bpf_dsl/golden/i386/MaskingPolicy.txt", |
| 182 | "bpf_dsl/golden/i386/MoreBooleanLogicPolicy.txt", |
| 183 | "bpf_dsl/golden/i386/NegativeConstantsPolicy.txt", |
| 184 | "bpf_dsl/golden/i386/SwitchPolicy.txt", |
| 185 | "bpf_dsl/golden/x86-64/ArgSizePolicy.txt", |
| 186 | "bpf_dsl/golden/x86-64/BasicPolicy.txt", |
| 187 | "bpf_dsl/golden/x86-64/BooleanLogicPolicy.txt", |
| 188 | "bpf_dsl/golden/x86-64/ElseIfPolicy.txt", |
| 189 | "bpf_dsl/golden/x86-64/MaskingPolicy.txt", |
| 190 | "bpf_dsl/golden/x86-64/MoreBooleanLogicPolicy.txt", |
| 191 | "bpf_dsl/golden/x86-64/NegativeConstantsPolicy.txt", |
| 192 | "bpf_dsl/golden/x86-64/SwitchPolicy.txt", |
| 193 | ] |
| 194 | outputs = [ |
| 195 | "$target_gen_dir/bpf_dsl/golden/golden_files.h", |
| 196 | ] |
| 197 | args = |
| 198 | rebase_path(outputs, root_build_dir) + rebase_path(inputs, root_build_dir) |
| 199 | } |
| 200 | |
agrieve | 62ab0028 | 2016-04-05 02:03:45 | [diff] [blame] | 201 | test("sandbox_linux_unittests") { |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 202 | deps = [ |
| 203 | ":sandbox_linux_unittests_sources", |
| 204 | ] |
agrieve | 62ab0028 | 2016-04-05 02:03:45 | [diff] [blame] | 205 | if (is_android) { |
| 206 | use_raw_android_executable = true |
| 207 | } |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 208 | } |
| 209 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 210 | component("seccomp_bpf") { |
| 211 | sources = [ |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 212 | "bpf_dsl/bpf_dsl.cc", |
| 213 | "bpf_dsl/bpf_dsl.h", |
mdempsky | c60a1c5 | 2014-10-24 23:07:10 | [diff] [blame] | 214 | "bpf_dsl/bpf_dsl_forward.h", |
mdempsky | fb10cce | 2014-10-14 17:56:44 | [diff] [blame] | 215 | "bpf_dsl/bpf_dsl_impl.h", |
mdempsky | b80b1f5 | 2015-02-05 00:54:35 | [diff] [blame] | 216 | "bpf_dsl/codegen.cc", |
| 217 | "bpf_dsl/codegen.h", |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 218 | "bpf_dsl/cons.h", |
mdempsky | 3909ebf | 2015-08-20 23:18:18 | [diff] [blame] | 219 | "bpf_dsl/errorcode.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 220 | "bpf_dsl/linux_syscall_ranges.h", |
mdempsky | c60a1c5 | 2014-10-24 23:07:10 | [diff] [blame] | 221 | "bpf_dsl/policy.cc", |
| 222 | "bpf_dsl/policy.h", |
mdempsky | 27e78ad7 | 2014-10-16 16:49:54 | [diff] [blame] | 223 | "bpf_dsl/policy_compiler.cc", |
| 224 | "bpf_dsl/policy_compiler.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 225 | "bpf_dsl/seccomp_macros.h", |
mdempsky | ce4c9f1 | 2015-02-05 06:23:05 | [diff] [blame] | 226 | "bpf_dsl/syscall_set.cc", |
| 227 | "bpf_dsl/syscall_set.h", |
mdempsky | 27e78ad7 | 2014-10-16 16:49:54 | [diff] [blame] | 228 | "bpf_dsl/trap_registry.h", |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 229 | "seccomp-bpf-helpers/baseline_policy.cc", |
| 230 | "seccomp-bpf-helpers/baseline_policy.h", |
Robert Sesek | f2255a2 | 2017-07-07 16:02:39 | [diff] [blame] | 231 | "seccomp-bpf-helpers/baseline_policy_android.cc", |
| 232 | "seccomp-bpf-helpers/baseline_policy_android.h", |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 233 | "seccomp-bpf-helpers/sigsys_handlers.cc", |
| 234 | "seccomp-bpf-helpers/sigsys_handlers.h", |
| 235 | "seccomp-bpf-helpers/syscall_parameters_restrictions.cc", |
| 236 | "seccomp-bpf-helpers/syscall_parameters_restrictions.h", |
| 237 | "seccomp-bpf-helpers/syscall_sets.cc", |
| 238 | "seccomp-bpf-helpers/syscall_sets.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 239 | "seccomp-bpf/die.cc", |
| 240 | "seccomp-bpf/die.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 241 | "seccomp-bpf/sandbox_bpf.cc", |
| 242 | "seccomp-bpf/sandbox_bpf.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 243 | "seccomp-bpf/syscall.cc", |
| 244 | "seccomp-bpf/syscall.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 245 | "seccomp-bpf/trap.cc", |
| 246 | "seccomp-bpf/trap.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 247 | ] |
| 248 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 249 | |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 250 | public_deps = [ |
| 251 | ":sandbox_services_headers", |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 252 | "//sandbox:sandbox_export", |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 253 | ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 254 | deps = [ |
jln | bd4df41c | 2014-11-25 02:32:30 | [diff] [blame] | 255 | ":sandbox_services", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 256 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 257 | "//base/third_party/dynamic_annotations", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 258 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 259 | |
| 260 | if (is_nacl_nonsfi) { |
| 261 | cflags = [ "-fgnu-inline-asm" ] |
| 262 | sources -= [ |
| 263 | "bpf_dsl/bpf_dsl_forward.h", |
| 264 | "bpf_dsl/bpf_dsl_impl.h", |
| 265 | "bpf_dsl/cons.h", |
| 266 | "bpf_dsl/errorcode.h", |
| 267 | "bpf_dsl/linux_syscall_ranges.h", |
| 268 | "bpf_dsl/seccomp_macros.h", |
| 269 | "bpf_dsl/trap_registry.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 270 | "seccomp-bpf-helpers/baseline_policy.cc", |
| 271 | "seccomp-bpf-helpers/baseline_policy.h", |
| 272 | "seccomp-bpf-helpers/syscall_sets.cc", |
| 273 | "seccomp-bpf-helpers/syscall_sets.h", |
| 274 | ] |
| 275 | configs += [ ":nacl_nonsfi_warnings" ] |
| 276 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 277 | } |
| 278 | |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 279 | if (is_android) { |
| 280 | # This target is available even if use_seccomp_bpf is disabled, but it also |
| 281 | # works when it is enabled. |
| 282 | component("seccomp_starter_android") { |
| 283 | sources = [ |
| 284 | "seccomp-bpf-helpers/seccomp_starter_android.cc", |
| 285 | "seccomp-bpf-helpers/seccomp_starter_android.h", |
| 286 | ] |
| 287 | |
| 288 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 289 | |
| 290 | deps = [ |
| 291 | "//base", |
Scott Violet | 73634e32 | 2018-04-04 21:05:02 | [diff] [blame] | 292 | "//sandbox:sandbox_buildflags", |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 293 | ] |
| 294 | |
| 295 | if (use_seccomp_bpf) { |
| 296 | deps += [ ":seccomp_bpf" ] |
| 297 | } |
| 298 | |
| 299 | visibility = [ ":*" ] |
| 300 | } |
| 301 | } |
| 302 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 303 | if (is_linux) { |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 304 | # The setuid sandbox for Linux. |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 305 | executable("chrome_sandbox") { |
| 306 | sources = [ |
| 307 | "suid/common/sandbox.h", |
| 308 | "suid/common/suid_unsafe_environment_variables.h", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 309 | "suid/process_util.h", |
| 310 | "suid/process_util_linux.c", |
| 311 | "suid/sandbox.c", |
| 312 | ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 313 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 314 | cflags = [ |
| 315 | # For ULLONG_MAX |
| 316 | "-std=gnu99", |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 317 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 318 | # These files have a suspicious comparison. |
| 319 | # TODO fix this and re-enable this warning. |
| 320 | "-Wno-sign-compare", |
| 321 | ] |
| 322 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | component("sandbox_services") { |
| 326 | sources = [ |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 327 | "services/init_process_reaper.cc", |
| 328 | "services/init_process_reaper.h", |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 329 | "services/proc_util.cc", |
| 330 | "services/proc_util.h", |
jln | 97718598 | 2015-02-13 20:58:41 | [diff] [blame] | 331 | "services/resource_limits.cc", |
| 332 | "services/resource_limits.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 333 | "services/scoped_process.cc", |
| 334 | "services/scoped_process.h", |
jln | 610a4a61 | 2014-11-20 18:58:21 | [diff] [blame] | 335 | "services/syscall_wrappers.cc", |
| 336 | "services/syscall_wrappers.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 337 | "services/thread_helpers.cc", |
| 338 | "services/thread_helpers.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 339 | "services/yama.cc", |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 340 | "services/yama.h", |
jln | 878dca3 | 2014-11-11 07:43:57 | [diff] [blame] | 341 | "syscall_broker/broker_channel.cc", |
| 342 | "syscall_broker/broker_channel.h", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 343 | "syscall_broker/broker_client.cc", |
| 344 | "syscall_broker/broker_client.h", |
Tom Sepez | a788b14 | 2017-12-05 01:17:08 | [diff] [blame] | 345 | "syscall_broker/broker_command.cc", |
| 346 | "syscall_broker/broker_command.h", |
leecam | ad78f42 | 2014-11-26 22:08:45 | [diff] [blame] | 347 | "syscall_broker/broker_file_permission.cc", |
| 348 | "syscall_broker/broker_file_permission.h", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 349 | "syscall_broker/broker_host.cc", |
| 350 | "syscall_broker/broker_host.h", |
Tom Sepez | 18f5754 | 2017-12-07 22:46:30 | [diff] [blame] | 351 | "syscall_broker/broker_permission_list.cc", |
| 352 | "syscall_broker/broker_permission_list.h", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 353 | "syscall_broker/broker_process.cc", |
| 354 | "syscall_broker/broker_process.h", |
Greg Kerr | a722110 | 2018-05-14 19:31:31 | [diff] [blame] | 355 | "syscall_broker/broker_simple_message.cc", |
| 356 | "syscall_broker/broker_simple_message.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 357 | ] |
| 358 | |
| 359 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 360 | |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 361 | public_deps = [ |
| 362 | "//sandbox:sandbox_export", |
| 363 | ] |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 364 | deps = [ |
| 365 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 366 | "//base/third_party/dynamic_annotations", |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 367 | ] |
| 368 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 369 | if (compile_credentials || is_nacl_nonsfi) { |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 370 | sources += [ |
| 371 | "services/credentials.cc", |
| 372 | "services/credentials.h", |
rickyz | 8f235da | 2015-02-03 07:26:19 | [diff] [blame] | 373 | "services/namespace_sandbox.cc", |
| 374 | "services/namespace_sandbox.h", |
rickyz | 41fb145 | 2015-01-27 03:57:58 | [diff] [blame] | 375 | "services/namespace_utils.cc", |
| 376 | "services/namespace_utils.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 377 | ] |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 378 | |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 379 | public_deps += [ ":sandbox_services_headers" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 380 | } |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 381 | |
| 382 | if (is_nacl_nonsfi) { |
mcgrathr | 87cb1c07 | 2015-11-20 21:47:40 | [diff] [blame] | 383 | cflags = [ "-fgnu-inline-asm" ] |
| 384 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 385 | sources -= [ |
| 386 | "services/init_process_reaper.cc", |
| 387 | "services/init_process_reaper.h", |
| 388 | "services/scoped_process.cc", |
| 389 | "services/scoped_process.h", |
| 390 | "services/yama.cc", |
| 391 | "services/yama.h", |
| 392 | "syscall_broker/broker_channel.cc", |
| 393 | "syscall_broker/broker_channel.h", |
| 394 | "syscall_broker/broker_client.cc", |
| 395 | "syscall_broker/broker_client.h", |
Tom Sepez | a788b14 | 2017-12-05 01:17:08 | [diff] [blame] | 396 | "syscall_broker/broker_command.cc", |
| 397 | "syscall_broker/broker_command.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 398 | "syscall_broker/broker_file_permission.cc", |
| 399 | "syscall_broker/broker_file_permission.h", |
| 400 | "syscall_broker/broker_host.cc", |
| 401 | "syscall_broker/broker_host.h", |
Tom Sepez | 18f5754 | 2017-12-07 22:46:30 | [diff] [blame] | 402 | "syscall_broker/broker_permission_list.cc", |
| 403 | "syscall_broker/broker_permission_list.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 404 | "syscall_broker/broker_process.cc", |
| 405 | "syscall_broker/broker_process.h", |
Greg Kerr | a722110 | 2018-05-14 19:31:31 | [diff] [blame] | 406 | "syscall_broker/broker_simple_message.cc", |
| 407 | "syscall_broker/broker_simple_message.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 408 | ] |
Tom Sepez | b081ec3 | 2018-01-25 03:18:22 | [diff] [blame] | 409 | } else if (!is_android) { |
| 410 | sources += [ |
| 411 | "services/libc_interceptor.cc", |
| 412 | "services/libc_interceptor.h", |
| 413 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 414 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | source_set("sandbox_services_headers") { |
| 418 | sources = [ |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 419 | "system_headers/arm64_linux_syscalls.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 420 | "system_headers/arm_linux_syscalls.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 421 | "system_headers/arm_linux_ucontext.h", |
| 422 | "system_headers/i386_linux_ucontext.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 423 | "system_headers/linux_filter.h", |
dnicoara | 9717805 | 2015-04-15 17:44:04 | [diff] [blame] | 424 | "system_headers/linux_futex.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 425 | "system_headers/linux_seccomp.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 426 | "system_headers/linux_signal.h", |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 427 | "system_headers/linux_syscalls.h", |
ben | 7598f46 | 2015-05-22 23:19:51 | [diff] [blame] | 428 | "system_headers/linux_time.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 429 | "system_headers/linux_ucontext.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 430 | "system_headers/mips64_linux_syscalls.h", |
| 431 | "system_headers/mips_linux_syscalls.h", |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 432 | "system_headers/x86_32_linux_syscalls.h", |
| 433 | "system_headers/x86_64_linux_syscalls.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 434 | ] |
| 435 | } |
| 436 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 437 | if (compile_suid_client || is_nacl_nonsfi) { |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 438 | component("suid_sandbox_client") { |
| 439 | sources = [ |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 440 | "suid/client/setuid_sandbox_client.cc", |
| 441 | "suid/client/setuid_sandbox_client.h", |
mdempsky | 3cc942a | 2015-02-05 03:29:25 | [diff] [blame] | 442 | "suid/client/setuid_sandbox_host.cc", |
| 443 | "suid/client/setuid_sandbox_host.h", |
scottmg | 7c7296f4 | 2015-02-28 02:23:09 | [diff] [blame] | 444 | "suid/common/sandbox.h", |
| 445 | "suid/common/suid_unsafe_environment_variables.h", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 446 | ] |
| 447 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 448 | public_deps = [ |
| 449 | "//sandbox:sandbox_export", |
| 450 | ] |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 451 | deps = [ |
| 452 | ":sandbox_services", |
| 453 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 454 | "//base/third_party/dynamic_annotations", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 455 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 456 | |
| 457 | if (is_nacl_nonsfi) { |
| 458 | sources -= [ |
| 459 | "suid/client/setuid_sandbox_host.cc", |
| 460 | "suid/client/setuid_sandbox_host.h", |
| 461 | "suid/common/sandbox.h", |
| 462 | "suid/common/suid_unsafe_environment_variables.h", |
| 463 | ] |
| 464 | } |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 465 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 466 | } |