[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 | ] |
| 40 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 41 | if (compile_suid_client || is_nacl_nonsfi) { |
brettw | 00709df | 2015-12-02 01:40:50 | [diff] [blame] | 42 | public_deps += [ ":suid_sandbox_client" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 43 | } |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 44 | if (use_seccomp_bpf || is_nacl_nonsfi) { |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 45 | public_deps += [ ":seccomp_bpf" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 46 | } |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 47 | if (is_android) { |
| 48 | public_deps += [ ":seccomp_starter_android" ] |
| 49 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | source_set("sandbox_linux_test_utils") { |
Brett Wilson | 0c8745a | 2014-09-08 22:59:49 | [diff] [blame] | 53 | testonly = true |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 54 | sources = [ |
| 55 | "tests/sandbox_test_runner.cc", |
| 56 | "tests/sandbox_test_runner.h", |
| 57 | "tests/sandbox_test_runner_function_pointer.cc", |
| 58 | "tests/sandbox_test_runner_function_pointer.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 59 | "tests/unit_tests.cc", |
| 60 | "tests/unit_tests.h", |
| 61 | ] |
| 62 | |
| 63 | deps = [ |
| 64 | "//testing/gtest", |
| 65 | ] |
| 66 | |
phosek | ca8571a9 | 2015-12-17 16:35:42 | [diff] [blame] | 67 | if (!is_nacl_nonsfi) { |
| 68 | sources += [ |
| 69 | "tests/test_utils.cc", |
| 70 | "tests/test_utils.h", |
| 71 | ] |
| 72 | } |
| 73 | |
| 74 | if (use_seccomp_bpf || is_nacl_nonsfi) { |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 75 | sources += [ |
| 76 | "seccomp-bpf/bpf_tester_compatibility_delegate.h", |
| 77 | "seccomp-bpf/bpf_tests.h", |
| 78 | "seccomp-bpf/sandbox_bpf_test_runner.cc", |
| 79 | "seccomp-bpf/sandbox_bpf_test_runner.h", |
| 80 | ] |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 81 | deps += [ ":seccomp_bpf" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 82 | } |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 83 | |
| 84 | if (use_base_test_suite) { |
| 85 | deps += [ "//base/test:test_support" ] |
| 86 | defines = [ "SANDBOX_USES_BASE_TEST_SUITE" ] |
| 87 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 88 | } |
| 89 | |
pkotwicz | 41889e3 | 2015-10-28 22:17:48 | [diff] [blame] | 90 | # Sources for sandbox_linux_unittests. |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 91 | source_set("sandbox_linux_unittests_sources") { |
| 92 | testonly = true |
| 93 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 94 | sources = [ |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 95 | "services/proc_util_unittest.cc", |
jln | 97718598 | 2015-02-13 20:58:41 | [diff] [blame] | 96 | "services/resource_limits_unittests.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 97 | "services/scoped_process_unittest.cc", |
jln | c420f0d | 2014-11-22 01:12:09 | [diff] [blame] | 98 | "services/syscall_wrappers_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 99 | "services/thread_helpers_unittests.cc", |
| 100 | "services/yama_unittests.cc", |
leecam | ad78f42 | 2014-11-26 22:08:45 | [diff] [blame] | 101 | "syscall_broker/broker_file_permission_unittest.cc", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 102 | "syscall_broker/broker_process_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" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 153 | } |
| 154 | if (compile_credentials) { |
| 155 | sources += [ |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 156 | "integration_tests/namespace_unix_domain_socket_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 157 | "services/credentials_unittest.cc", |
rickyz | 41fb145 | 2015-01-27 03:57:58 | [diff] [blame] | 158 | "services/namespace_utils_unittest.cc", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 159 | ] |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 160 | |
jln | 01954fd | 2015-05-15 06:19:33 | [diff] [blame] | 161 | if (use_base_test_suite) { |
| 162 | # Tests that use advanced features not available in stock GTest. |
| 163 | sources += [ "services/namespace_sandbox_unittest.cc" ] |
| 164 | } |
| 165 | |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 166 | # For credentials_unittest.cc |
| 167 | configs += [ "//build/config/linux:libcap" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
mdempsky | a3fd0ec | 2015-08-26 00:45:52 | [diff] [blame] | 171 | action("bpf_dsl_golden") { |
| 172 | script = "bpf_dsl/golden/generate.py" |
| 173 | inputs = [ |
| 174 | "bpf_dsl/golden/i386/ArgSizePolicy.txt", |
| 175 | "bpf_dsl/golden/i386/BasicPolicy.txt", |
| 176 | "bpf_dsl/golden/i386/ElseIfPolicy.txt", |
| 177 | "bpf_dsl/golden/i386/MaskingPolicy.txt", |
| 178 | "bpf_dsl/golden/i386/MoreBooleanLogicPolicy.txt", |
| 179 | "bpf_dsl/golden/i386/NegativeConstantsPolicy.txt", |
| 180 | "bpf_dsl/golden/i386/SwitchPolicy.txt", |
| 181 | "bpf_dsl/golden/x86-64/ArgSizePolicy.txt", |
| 182 | "bpf_dsl/golden/x86-64/BasicPolicy.txt", |
| 183 | "bpf_dsl/golden/x86-64/BooleanLogicPolicy.txt", |
| 184 | "bpf_dsl/golden/x86-64/ElseIfPolicy.txt", |
| 185 | "bpf_dsl/golden/x86-64/MaskingPolicy.txt", |
| 186 | "bpf_dsl/golden/x86-64/MoreBooleanLogicPolicy.txt", |
| 187 | "bpf_dsl/golden/x86-64/NegativeConstantsPolicy.txt", |
| 188 | "bpf_dsl/golden/x86-64/SwitchPolicy.txt", |
| 189 | ] |
| 190 | outputs = [ |
| 191 | "$target_gen_dir/bpf_dsl/golden/golden_files.h", |
| 192 | ] |
| 193 | args = |
| 194 | rebase_path(outputs, root_build_dir) + rebase_path(inputs, root_build_dir) |
| 195 | } |
| 196 | |
agrieve | 62ab0028 | 2016-04-05 02:03:45 | [diff] [blame] | 197 | test("sandbox_linux_unittests") { |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 198 | deps = [ |
| 199 | ":sandbox_linux_unittests_sources", |
thomasanderson | 84fa8b0 | 2017-05-18 23:38:47 | [diff] [blame] | 200 | "//build/config:exe_and_shlib_deps", |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 201 | ] |
agrieve | 62ab0028 | 2016-04-05 02:03:45 | [diff] [blame] | 202 | if (is_android) { |
| 203 | use_raw_android_executable = true |
| 204 | } |
rockot | 86da06c7f | 2015-02-21 00:40:58 | [diff] [blame] | 205 | } |
| 206 | |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 207 | component("seccomp_bpf") { |
| 208 | sources = [ |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 209 | "bpf_dsl/bpf_dsl.cc", |
| 210 | "bpf_dsl/bpf_dsl.h", |
mdempsky | c60a1c5 | 2014-10-24 23:07:10 | [diff] [blame] | 211 | "bpf_dsl/bpf_dsl_forward.h", |
mdempsky | fb10cce | 2014-10-14 17:56:44 | [diff] [blame] | 212 | "bpf_dsl/bpf_dsl_impl.h", |
mdempsky | b80b1f5 | 2015-02-05 00:54:35 | [diff] [blame] | 213 | "bpf_dsl/codegen.cc", |
| 214 | "bpf_dsl/codegen.h", |
[email protected] | fb75e2a | 2014-07-17 07:24:58 | [diff] [blame] | 215 | "bpf_dsl/cons.h", |
mdempsky | 3909ebf | 2015-08-20 23:18:18 | [diff] [blame] | 216 | "bpf_dsl/errorcode.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 217 | "bpf_dsl/linux_syscall_ranges.h", |
mdempsky | c60a1c5 | 2014-10-24 23:07:10 | [diff] [blame] | 218 | "bpf_dsl/policy.cc", |
| 219 | "bpf_dsl/policy.h", |
mdempsky | 27e78ad7 | 2014-10-16 16:49:54 | [diff] [blame] | 220 | "bpf_dsl/policy_compiler.cc", |
| 221 | "bpf_dsl/policy_compiler.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 222 | "bpf_dsl/seccomp_macros.h", |
mdempsky | ce4c9f1 | 2015-02-05 06:23:05 | [diff] [blame] | 223 | "bpf_dsl/syscall_set.cc", |
| 224 | "bpf_dsl/syscall_set.h", |
mdempsky | 27e78ad7 | 2014-10-16 16:49:54 | [diff] [blame] | 225 | "bpf_dsl/trap_registry.h", |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 226 | "seccomp-bpf-helpers/baseline_policy.cc", |
| 227 | "seccomp-bpf-helpers/baseline_policy.h", |
Robert Sesek | f2255a2 | 2017-07-07 16:02:39 | [diff] [blame] | 228 | "seccomp-bpf-helpers/baseline_policy_android.cc", |
| 229 | "seccomp-bpf-helpers/baseline_policy_android.h", |
ejcaruso | b786580 | 2016-08-30 06:14:30 | [diff] [blame] | 230 | "seccomp-bpf-helpers/sigsys_handlers.cc", |
| 231 | "seccomp-bpf-helpers/sigsys_handlers.h", |
| 232 | "seccomp-bpf-helpers/syscall_parameters_restrictions.cc", |
| 233 | "seccomp-bpf-helpers/syscall_parameters_restrictions.h", |
| 234 | "seccomp-bpf-helpers/syscall_sets.cc", |
| 235 | "seccomp-bpf-helpers/syscall_sets.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 236 | "seccomp-bpf/die.cc", |
| 237 | "seccomp-bpf/die.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 238 | "seccomp-bpf/sandbox_bpf.cc", |
| 239 | "seccomp-bpf/sandbox_bpf.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 240 | "seccomp-bpf/syscall.cc", |
| 241 | "seccomp-bpf/syscall.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 242 | "seccomp-bpf/trap.cc", |
| 243 | "seccomp-bpf/trap.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 244 | ] |
| 245 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 246 | |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 247 | public_deps = [ |
| 248 | ":sandbox_services_headers", |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 249 | "//sandbox:sandbox_export", |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 250 | ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 251 | deps = [ |
jln | bd4df41c | 2014-11-25 02:32:30 | [diff] [blame] | 252 | ":sandbox_services", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 253 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 254 | "//base/third_party/dynamic_annotations", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 255 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 256 | |
| 257 | if (is_nacl_nonsfi) { |
| 258 | cflags = [ "-fgnu-inline-asm" ] |
| 259 | sources -= [ |
| 260 | "bpf_dsl/bpf_dsl_forward.h", |
| 261 | "bpf_dsl/bpf_dsl_impl.h", |
| 262 | "bpf_dsl/cons.h", |
| 263 | "bpf_dsl/errorcode.h", |
| 264 | "bpf_dsl/linux_syscall_ranges.h", |
| 265 | "bpf_dsl/seccomp_macros.h", |
| 266 | "bpf_dsl/trap_registry.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 267 | "seccomp-bpf-helpers/baseline_policy.cc", |
| 268 | "seccomp-bpf-helpers/baseline_policy.h", |
| 269 | "seccomp-bpf-helpers/syscall_sets.cc", |
| 270 | "seccomp-bpf-helpers/syscall_sets.h", |
| 271 | ] |
| 272 | configs += [ ":nacl_nonsfi_warnings" ] |
| 273 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 274 | } |
| 275 | |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 276 | if (is_android) { |
| 277 | # This target is available even if use_seccomp_bpf is disabled, but it also |
| 278 | # works when it is enabled. |
| 279 | component("seccomp_starter_android") { |
| 280 | sources = [ |
| 281 | "seccomp-bpf-helpers/seccomp_starter_android.cc", |
| 282 | "seccomp-bpf-helpers/seccomp_starter_android.h", |
| 283 | ] |
| 284 | |
| 285 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 286 | |
| 287 | deps = [ |
| 288 | "//base", |
Robert Sesek | d4b1c13 | 2017-07-13 21:22:05 | [diff] [blame] | 289 | "//sandbox:sandbox_features", |
Robert Sesek | 5fb3197 | 2017-07-12 00:21:40 | [diff] [blame] | 290 | ] |
| 291 | |
| 292 | if (use_seccomp_bpf) { |
| 293 | deps += [ ":seccomp_bpf" ] |
| 294 | } |
| 295 | |
| 296 | visibility = [ ":*" ] |
| 297 | } |
| 298 | } |
| 299 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 300 | if (is_linux) { |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 301 | # The setuid sandbox for Linux. |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 302 | executable("chrome_sandbox") { |
| 303 | sources = [ |
| 304 | "suid/common/sandbox.h", |
| 305 | "suid/common/suid_unsafe_environment_variables.h", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 306 | "suid/process_util.h", |
| 307 | "suid/process_util_linux.c", |
| 308 | "suid/sandbox.c", |
| 309 | ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 310 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 311 | cflags = [ |
| 312 | # For ULLONG_MAX |
| 313 | "-std=gnu99", |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 314 | |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 315 | # These files have a suspicious comparison. |
| 316 | # TODO fix this and re-enable this warning. |
| 317 | "-Wno-sign-compare", |
| 318 | ] |
brettw | ba7a73d | 2015-08-31 22:17:39 | [diff] [blame] | 319 | |
dpranke | 3ea22b3a | 2016-06-09 23:39:50 | [diff] [blame] | 320 | import("//build/config/compiler/compiler.gni") |
| 321 | import("//build/config/sanitizers/sanitizers.gni") |
dpranke | 651705f | 2016-07-15 03:58:47 | [diff] [blame] | 322 | if (is_component_build || using_sanitizer) { |
dpranke | 3ea22b3a | 2016-06-09 23:39:50 | [diff] [blame] | 323 | # WARNING! We remove this config so that we don't accidentally |
| 324 | # pick up the //build/config:rpath_for_built_shared_libraries |
| 325 | # sub-config. However, this means that we need to duplicate any |
| 326 | # other flags that executable_config might have. |
| 327 | configs -= [ "//build/config:executable_config" ] |
| 328 | if (!use_gold) { |
dpranke | 41d05be | 2016-06-13 18:59:31 | [diff] [blame] | 329 | ldflags = [ "-Wl,--disable-new-dtags" ] |
dpranke | 3ea22b3a | 2016-06-09 23:39:50 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
dpranke | 651705f | 2016-07-15 03:58:47 | [diff] [blame] | 333 | # We also do not want to pick up any of the other sanitizer |
| 334 | # flags (i.e. we do not want to build w/ the sanitizers at all). |
| 335 | # This is safe to delete unconditionally, because it is part of the |
| 336 | # default configs and empty when not using the sanitizers. |
| 337 | configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 338 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | component("sandbox_services") { |
| 342 | sources = [ |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 343 | "services/init_process_reaper.cc", |
| 344 | "services/init_process_reaper.h", |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 345 | "services/proc_util.cc", |
| 346 | "services/proc_util.h", |
jln | 97718598 | 2015-02-13 20:58:41 | [diff] [blame] | 347 | "services/resource_limits.cc", |
| 348 | "services/resource_limits.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 349 | "services/scoped_process.cc", |
| 350 | "services/scoped_process.h", |
jln | 610a4a61 | 2014-11-20 18:58:21 | [diff] [blame] | 351 | "services/syscall_wrappers.cc", |
| 352 | "services/syscall_wrappers.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 353 | "services/thread_helpers.cc", |
| 354 | "services/thread_helpers.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 355 | "services/yama.cc", |
jln | b14fc80 | 2015-02-12 05:32:11 | [diff] [blame] | 356 | "services/yama.h", |
jln | 878dca3 | 2014-11-11 07:43:57 | [diff] [blame] | 357 | "syscall_broker/broker_channel.cc", |
| 358 | "syscall_broker/broker_channel.h", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 359 | "syscall_broker/broker_client.cc", |
| 360 | "syscall_broker/broker_client.h", |
Tom Sepez | a788b14 | 2017-12-05 01:17:08 | [diff] [blame^] | 361 | "syscall_broker/broker_command.cc", |
| 362 | "syscall_broker/broker_command.h", |
leecam | ad78f42 | 2014-11-26 22:08:45 | [diff] [blame] | 363 | "syscall_broker/broker_file_permission.cc", |
| 364 | "syscall_broker/broker_file_permission.h", |
jln | 70c42c20 | 2014-11-01 00:59:57 | [diff] [blame] | 365 | "syscall_broker/broker_host.cc", |
| 366 | "syscall_broker/broker_host.h", |
| 367 | "syscall_broker/broker_policy.cc", |
| 368 | "syscall_broker/broker_policy.h", |
| 369 | "syscall_broker/broker_process.cc", |
| 370 | "syscall_broker/broker_process.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 371 | ] |
| 372 | |
| 373 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
| 374 | |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 375 | public_deps = [ |
| 376 | "//sandbox:sandbox_export", |
| 377 | ] |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 378 | deps = [ |
| 379 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 380 | "//base/third_party/dynamic_annotations", |
rickyz | 966f039d | 2015-03-17 07:23:43 | [diff] [blame] | 381 | ] |
| 382 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 383 | if (compile_credentials || is_nacl_nonsfi) { |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 384 | sources += [ |
| 385 | "services/credentials.cc", |
| 386 | "services/credentials.h", |
rickyz | 8f235da | 2015-02-03 07:26:19 | [diff] [blame] | 387 | "services/namespace_sandbox.cc", |
| 388 | "services/namespace_sandbox.h", |
rickyz | 41fb145 | 2015-01-27 03:57:58 | [diff] [blame] | 389 | "services/namespace_utils.cc", |
| 390 | "services/namespace_utils.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 391 | ] |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 392 | |
brettw | 6334088 | 2016-03-22 17:09:49 | [diff] [blame] | 393 | public_deps += [ ":sandbox_services_headers" ] |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 394 | } |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 395 | |
| 396 | if (is_nacl_nonsfi) { |
mcgrathr | 87cb1c07 | 2015-11-20 21:47:40 | [diff] [blame] | 397 | cflags = [ "-fgnu-inline-asm" ] |
| 398 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 399 | sources -= [ |
| 400 | "services/init_process_reaper.cc", |
| 401 | "services/init_process_reaper.h", |
| 402 | "services/scoped_process.cc", |
| 403 | "services/scoped_process.h", |
| 404 | "services/yama.cc", |
| 405 | "services/yama.h", |
| 406 | "syscall_broker/broker_channel.cc", |
| 407 | "syscall_broker/broker_channel.h", |
| 408 | "syscall_broker/broker_client.cc", |
| 409 | "syscall_broker/broker_client.h", |
Tom Sepez | a788b14 | 2017-12-05 01:17:08 | [diff] [blame^] | 410 | "syscall_broker/broker_command.cc", |
| 411 | "syscall_broker/broker_command.h", |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 412 | "syscall_broker/broker_file_permission.cc", |
| 413 | "syscall_broker/broker_file_permission.h", |
| 414 | "syscall_broker/broker_host.cc", |
| 415 | "syscall_broker/broker_host.h", |
| 416 | "syscall_broker/broker_policy.cc", |
| 417 | "syscall_broker/broker_policy.h", |
| 418 | "syscall_broker/broker_process.cc", |
| 419 | "syscall_broker/broker_process.h", |
| 420 | ] |
| 421 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | source_set("sandbox_services_headers") { |
| 425 | sources = [ |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 426 | "system_headers/arm64_linux_syscalls.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 427 | "system_headers/arm64_linux_ucontext.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 428 | "system_headers/arm_linux_syscalls.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 429 | "system_headers/arm_linux_ucontext.h", |
| 430 | "system_headers/i386_linux_ucontext.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 431 | "system_headers/linux_filter.h", |
dnicoara | 9717805 | 2015-04-15 17:44:04 | [diff] [blame] | 432 | "system_headers/linux_futex.h", |
jln | a65ffca | 2015-02-13 04:12:43 | [diff] [blame] | 433 | "system_headers/linux_seccomp.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 434 | "system_headers/linux_signal.h", |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 435 | "system_headers/linux_syscalls.h", |
ben | 7598f46 | 2015-05-22 23:19:51 | [diff] [blame] | 436 | "system_headers/linux_time.h", |
hidehiko | a926d0b | 2015-04-24 21:55:21 | [diff] [blame] | 437 | "system_headers/linux_ucontext.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 438 | "system_headers/mips64_linux_syscalls.h", |
Wang Qing | 534d7ce | 2017-09-18 23:35:59 | [diff] [blame] | 439 | "system_headers/mips64_linux_ucontext.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 440 | "system_headers/mips_linux_syscalls.h", |
| 441 | "system_headers/mips_linux_ucontext.h", |
jln | aedcc3e | 2015-02-12 03:18:10 | [diff] [blame] | 442 | "system_headers/x86_32_linux_syscalls.h", |
| 443 | "system_headers/x86_64_linux_syscalls.h", |
tfarina | 1d7984c | 2017-03-27 23:00:22 | [diff] [blame] | 444 | "system_headers/x86_64_linux_ucontext.h", |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 445 | ] |
| 446 | } |
| 447 | |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 448 | if (compile_suid_client || is_nacl_nonsfi) { |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 449 | component("suid_sandbox_client") { |
| 450 | sources = [ |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 451 | "suid/client/setuid_sandbox_client.cc", |
| 452 | "suid/client/setuid_sandbox_client.h", |
mdempsky | 3cc942a | 2015-02-05 03:29:25 | [diff] [blame] | 453 | "suid/client/setuid_sandbox_host.cc", |
| 454 | "suid/client/setuid_sandbox_host.h", |
scottmg | 7c7296f4 | 2015-02-28 02:23:09 | [diff] [blame] | 455 | "suid/common/sandbox.h", |
| 456 | "suid/common/suid_unsafe_environment_variables.h", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 457 | ] |
| 458 | defines = [ "SANDBOX_IMPLEMENTATION" ] |
Thiago Farina | 10ec8a6 | 2017-05-15 20:38:09 | [diff] [blame] | 459 | public_deps = [ |
| 460 | "//sandbox:sandbox_export", |
| 461 | ] |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 462 | deps = [ |
| 463 | ":sandbox_services", |
| 464 | "//base", |
Mostyn Bramley-Moore | 452bf63 | 2017-11-28 21:51:42 | [diff] [blame] | 465 | "//base/third_party/dynamic_annotations", |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 466 | ] |
phosek | 636bceb3 | 2015-10-27 03:36:48 | [diff] [blame] | 467 | |
| 468 | if (is_nacl_nonsfi) { |
| 469 | sources -= [ |
| 470 | "suid/client/setuid_sandbox_host.cc", |
| 471 | "suid/client/setuid_sandbox_host.h", |
| 472 | "suid/common/sandbox.h", |
| 473 | "suid/common/suid_unsafe_environment_variables.h", |
| 474 | ] |
| 475 | } |
James Robinson | 060f2e3 | 2014-09-10 22:31:37 | [diff] [blame] | 476 | } |
[email protected] | 75cd8f0 | 2014-05-29 20:56:02 | [diff] [blame] | 477 | } |