blob: 467f80e19870d288f13dcfa8f1febe05007e9b10 [file] [log] [blame]
Tri Voa5cfd3e2018-03-22 11:35:02 -07001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Bob Badour601ebb42021-02-03 23:07:40 -080015package {
16 default_applicable_licenses: ["system_sepolicy_license"],
17}
18
19// Added automatically by a large-scale-change that took the approach of
20// 'apply every license found to every target'. While this makes sure we respect
21// every license restriction, it may not be entirely correct.
22//
23// e.g. GPL in an MIT project might only apply to the contrib/ directory.
24//
25// Please consider splitting the single license below into multiple licenses,
26// taking care not to lose any license_kind information, and overriding the
27// default license using the 'licenses: [...]' property on targets as needed.
28//
29// For unused files, consider creating a 'filegroup' with "//visibility:private"
30// to attach the license to, and including a comment whether the files may be
31// used in the current project.
32// http://go/android-license-faq
33license {
34 name: "system_sepolicy_license",
35 visibility: [":__subpackages__"],
36 license_kinds: [
37 "SPDX-license-identifier-Apache-2.0",
38 "legacy_unencumbered",
39 ],
40 license_text: [
41 "NOTICE",
42 ],
43}
44
Jeff Vander Stoepecd288f2019-02-15 12:18:15 -080045cc_defaults { name: "selinux_policy_version", cflags: ["-DSEPOLICY_VERSION=30"], }
46
Inseob Kim41964032022-04-22 07:50:22 +090047se_build_files {
Jae Shin1fa96342018-07-11 18:30:44 +090048 name: "28.0.board.compat.map",
49 srcs: [
50 "compat/28.0/28.0.cil",
51 ],
52}
53
Inseob Kim41964032022-04-22 07:50:22 +090054se_build_files {
Tri Vo50aa0292019-06-01 17:04:13 -070055 name: "29.0.board.compat.map",
56 srcs: [
57 "compat/29.0/29.0.cil",
58 ],
59}
60
Inseob Kim41964032022-04-22 07:50:22 +090061se_build_files {
Inseob Kimace36ab2020-05-07 20:19:05 +090062 name: "30.0.board.compat.map",
63 srcs: [
64 "compat/30.0/30.0.cil",
65 ],
66}
67
Inseob Kim41964032022-04-22 07:50:22 +090068se_build_files {
Inseob Kim4f20ff72021-06-15 21:05:39 +090069 name: "31.0.board.compat.map",
70 srcs: [
71 "compat/31.0/31.0.cil",
72 ],
73}
74
Inseob Kim41964032022-04-22 07:50:22 +090075se_build_files {
Inseob Kimbee558e2021-11-30 14:58:10 +090076 name: "32.0.board.compat.map",
77 srcs: [
78 "compat/32.0/32.0.cil",
79 ],
80}
81
Inseob Kim41964032022-04-22 07:50:22 +090082se_build_files {
Inseob Kim4ae05112022-05-02 14:03:46 +090083 name: "33.0.board.compat.map",
84 srcs: [
85 "compat/33.0/33.0.cil",
86 ],
87}
88
89se_build_files {
Yi-Yo Chiang8be93c02021-04-13 02:49:29 +080090 name: "28.0.board.compat.cil",
91 srcs: [
92 "compat/28.0/28.0.compat.cil",
93 ],
94}
95
Inseob Kim41964032022-04-22 07:50:22 +090096se_build_files {
Yi-Yo Chiang8be93c02021-04-13 02:49:29 +080097 name: "29.0.board.compat.cil",
98 srcs: [
99 "compat/29.0/29.0.compat.cil",
100 ],
101}
102
Inseob Kim41964032022-04-22 07:50:22 +0900103se_build_files {
Yi-Yo Chiang8be93c02021-04-13 02:49:29 +0800104 name: "30.0.board.compat.cil",
105 srcs: [
106 "compat/30.0/30.0.compat.cil",
107 ],
108}
109
Inseob Kim41964032022-04-22 07:50:22 +0900110se_build_files {
Inseob Kim4f20ff72021-06-15 21:05:39 +0900111 name: "31.0.board.compat.cil",
112 srcs: [
113 "compat/31.0/31.0.compat.cil",
114 ],
115}
116
Inseob Kim41964032022-04-22 07:50:22 +0900117se_build_files {
Inseob Kimbee558e2021-11-30 14:58:10 +0900118 name: "32.0.board.compat.cil",
119 srcs: [
120 "compat/32.0/32.0.compat.cil",
121 ],
122}
123
Inseob Kim41964032022-04-22 07:50:22 +0900124se_build_files {
Inseob Kim4ae05112022-05-02 14:03:46 +0900125 name: "33.0.board.compat.cil",
126 srcs: [
127 "compat/33.0/33.0.compat.cil",
128 ],
129}
130
131se_build_files {
Jinguang Donge0125692019-03-05 17:20:54 +0800132 name: "28.0.board.ignore.map",
133 srcs: [
134 "compat/28.0/28.0.ignore.cil",
135 ],
136}
137
Inseob Kim41964032022-04-22 07:50:22 +0900138se_build_files {
Tri Vo50aa0292019-06-01 17:04:13 -0700139 name: "29.0.board.ignore.map",
140 srcs: [
141 "compat/29.0/29.0.ignore.cil",
142 ],
143}
144
Inseob Kim41964032022-04-22 07:50:22 +0900145se_build_files {
Inseob Kimace36ab2020-05-07 20:19:05 +0900146 name: "30.0.board.ignore.map",
147 srcs: [
148 "compat/30.0/30.0.ignore.cil",
149 ],
150}
151
Inseob Kim41964032022-04-22 07:50:22 +0900152se_build_files {
Inseob Kim4f20ff72021-06-15 21:05:39 +0900153 name: "31.0.board.ignore.map",
154 srcs: [
155 "compat/31.0/31.0.ignore.cil",
156 ],
157}
158
Inseob Kim41964032022-04-22 07:50:22 +0900159se_build_files {
Inseob Kimbee558e2021-11-30 14:58:10 +0900160 name: "32.0.board.ignore.map",
161 srcs: [
162 "compat/32.0/32.0.ignore.cil",
163 ],
164}
165
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900166se_build_files {
Inseob Kim4ae05112022-05-02 14:03:46 +0900167 name: "33.0.board.ignore.map",
168 srcs: [
169 "compat/33.0/33.0.ignore.cil",
170 ],
171}
172
173se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900174 name: "file_contexts_files",
175 srcs: ["file_contexts"],
176}
177
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900178se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900179 name: "file_contexts_asan_files",
180 srcs: ["file_contexts_asan"],
181}
182
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900183se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900184 name: "file_contexts_overlayfs_files",
185 srcs: ["file_contexts_overlayfs"],
186}
187
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900188se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900189 name: "hwservice_contexts_files",
190 srcs: ["hwservice_contexts"],
191}
192
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900193se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900194 name: "property_contexts_files",
195 srcs: ["property_contexts"],
196}
197
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900198se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900199 name: "service_contexts_files",
200 srcs: ["service_contexts"],
201}
202
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900203se_build_files {
Janis Danisevskisc40681f2020-07-25 13:02:29 -0700204 name: "keystore2_key_contexts_files",
205 srcs: ["keystore2_key_contexts"],
206}
207
Inseob Kim2dac2672021-12-29 17:54:57 +0900208se_build_files {
209 name: "seapp_contexts_files",
210 srcs: ["seapp_contexts"],
211}
212
Inseob Kimc7596c42022-02-25 11:45:41 +0900213se_build_files {
214 name: "vndservice_contexts_files",
215 srcs: ["vndservice_contexts"],
216}
217
yangbill3e345372020-04-15 13:55:47 +0800218// For vts_treble_sys_prop_test
219filegroup {
220 name: "private_property_contexts",
221 srcs: ["private/property_contexts"],
222 visibility: [
223 "//test/vts-testcase/security/system_property",
224 ],
225}
Inseob Kime35b49b2021-02-18 19:15:41 +0900226
Inseob Kima49e7242021-03-22 10:26:13 +0900227se_build_files {
228 name: "se_build_files",
Inseob Kime35b49b2021-02-18 19:15:41 +0900229 srcs: [
Inseob Kima49e7242021-03-22 10:26:13 +0900230 "security_classes",
231 "initial_sids",
232 "access_vectors",
233 "global_macros",
234 "neverallow_macros",
235 "mls_macros",
236 "mls_decl",
237 "mls",
238 "policy_capabilities",
239 "te_macros",
240 "attributes",
241 "ioctl_defines",
242 "ioctl_macros",
243 "*.te",
244 "roles_decl",
245 "roles",
246 "users",
247 "initial_sid_contexts",
248 "fs_use",
249 "genfs_contexts",
250 "port_contexts",
Inseob Kime35b49b2021-02-18 19:15:41 +0900251 ],
252}
253
Inseob Kim7cb20812021-12-16 16:52:14 +0900254se_build_files {
255 name: "sepolicy_technical_debt",
256 srcs: ["technical_debt.cil"],
257}
258
Inseob Kim0a707fa2021-12-09 23:35:11 +0900259reqd_mask_policy = [":se_build_files{.reqd_mask}"]
260plat_public_policy = [":se_build_files{.plat_public}"]
261plat_private_policy = [":se_build_files{.plat_private}"]
262system_ext_public_policy = [":se_build_files{.system_ext_public}"]
263system_ext_private_policy = [":se_build_files{.system_ext_private}"]
264product_public_policy = [":se_build_files{.product_public}"]
265product_private_policy = [":se_build_files{.product_private}"]
266
Inseob Kima49e7242021-03-22 10:26:13 +0900267// reqd_policy_mask - a policy.conf file which contains only the bare minimum
268// policy necessary to use checkpolicy.
269//
270// This bare-minimum policy needs to be present in all policy.conf files, but
271// should not necessarily be exported as part of the public policy.
272//
273// The rules generated by reqd_policy_mask will allow the compilation of public
274// policy and subsequent removal of CIL policy that should not be exported.
275se_policy_conf {
276 name: "reqd_policy_mask.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900277 srcs: reqd_mask_policy,
Inseob Kime35b49b2021-02-18 19:15:41 +0900278 installable: false,
279}
280
Inseob Kima49e7242021-03-22 10:26:13 +0900281se_policy_cil {
282 name: "reqd_policy_mask.cil",
283 src: ":reqd_policy_mask.conf",
284 secilc_check: false,
285 installable: false,
Inseob Kime35b49b2021-02-18 19:15:41 +0900286}
287
Inseob Kima49e7242021-03-22 10:26:13 +0900288// pub_policy - policy that will be exported to be a part of non-platform
289// policy corresponding to this platform version.
290//
291// This is a limited subset of policy that would not compile in checkpolicy on
292// its own.
293//
294// To get around this limitation, add only the required files from private
295// policy, which will generate CIL policy that will then be filtered out by the
296// reqd_policy_mask.
297//
298// There are three pub_policy.cil files below:
299// - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
300// - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
301// - plat_pub_policy.cil: exported 'system' policy.
302//
303// Those above files will in turn be used to generate the following versioned cil files:
304// - product_mapping_file: the versioned, exported 'product' policy in product partition.
305// - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
306// - plat_mapping_file: the versioned, exported 'system' policy in system partition.
307// - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
308// in vendor partition.
309//
310se_policy_conf {
311 name: "pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900312 srcs: plat_public_policy +
313 system_ext_public_policy +
314 product_public_policy +
315 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900316 installable: false,
317}
318
319se_policy_cil {
320 name: "pub_policy.cil",
321 src: ":pub_policy.conf",
322 filter_out: [":reqd_policy_mask.cil"],
323 secilc_check: false,
324 installable: false,
325}
326
327se_policy_conf {
328 name: "system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900329 srcs: plat_public_policy +
330 system_ext_public_policy +
331 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900332 installable: false,
333}
334
335se_policy_cil {
336 name: "system_ext_pub_policy.cil",
337 src: ":system_ext_pub_policy.conf",
338 filter_out: [":reqd_policy_mask.cil"],
339 secilc_check: false,
340 installable: false,
341}
342
343se_policy_conf {
344 name: "plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900345 srcs: plat_public_policy +
346 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900347 installable: false,
348}
349
350se_policy_cil {
351 name: "plat_pub_policy.cil",
352 src: ":plat_pub_policy.conf",
353 filter_out: [":reqd_policy_mask.cil"],
354 secilc_check: false,
355 installable: false,
356}
357
358// plat_policy.conf - A combination of the private and public platform policy
359// which will ship with the device.
360//
361// The platform will always reflect the most recent platform version and is not
362// currently being attributized.
363se_policy_conf {
364 name: "plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900365 srcs: plat_public_policy +
366 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900367 installable: false,
368}
369
370se_policy_cil {
371 name: "plat_sepolicy.cil",
372 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900373 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900374}
375
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100376
377se_policy_conf {
378 name: "apex_sepolicy-33.conf",
379 srcs: plat_public_policy + plat_private_policy + ["com.android.sepolicy/33/*.te"],
380 installable: false,
381}
382
383se_policy_cil {
384 name: "apex_sepolicy-33.cil",
385 src: ":apex_sepolicy-33.conf",
386 filter_out: [":plat_sepolicy.cil"],
387 installable: false,
388 stem: "apex_sepolicy.cil",
389}
390
Inseob Kim6cc75f42021-04-29 13:53:20 +0000391// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
392se_policy_conf {
393 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900394 srcs: plat_public_policy +
395 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000396 build_variant: "userdebug",
397 installable: false,
398}
399
400se_policy_cil {
401 name: "userdebug_plat_sepolicy.cil",
402 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900403 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000404 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800405 dist: {
406 targets: ["droidcore"],
407 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000408}
409
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000410// A copy of the userdebug_plat_policy in GSI.
411soong_config_module_type {
412 name: "gsi_se_policy_cil",
413 module_type: "se_policy_cil",
414 config_namespace: "ANDROID",
415 bool_variables: [
416 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
417 ],
418 properties: [
419 "enabled",
420 "installable",
421 ],
422}
423
424gsi_se_policy_cil {
425 name: "system_ext_userdebug_plat_sepolicy.cil",
426 stem: "userdebug_plat_sepolicy.cil",
427 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900428 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000429 system_ext_specific: true,
430 enabled: false,
431 installable: false,
432 soong_config_variables: {
433 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
434 enabled: true,
435 installable: true,
436 },
437 },
438}
439
Inseob Kima49e7242021-03-22 10:26:13 +0900440// system_ext_policy.conf - A combination of the private and public system_ext
441// policy which will ship with the device. System_ext policy is not attributized
442se_policy_conf {
443 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900444 srcs: plat_public_policy +
445 plat_private_policy +
446 system_ext_public_policy +
447 system_ext_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900448 installable: false,
449}
450
451se_policy_cil {
452 name: "system_ext_sepolicy.cil",
453 src: ":system_ext_sepolicy.conf",
454 system_ext_specific: true,
455 filter_out: [":plat_sepolicy.cil"],
456 remove_line_marker: true,
457}
458
459// product_policy.conf - A combination of the private and public product policy
460// which will ship with the device. Product policy is not attributized
461se_policy_conf {
462 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900463 srcs: plat_public_policy +
464 plat_private_policy +
465 system_ext_public_policy +
466 system_ext_private_policy +
467 product_public_policy +
468 product_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900469 installable: false,
470}
471
472se_policy_cil {
473 name: "product_sepolicy.cil",
474 src: ":product_sepolicy.conf",
475 product_specific: true,
476 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
477 remove_line_marker: true,
478}
479
Inseob Kim039175b2021-03-25 15:37:34 +0900480// policy mapping files
481// auto-generate the mapping file for current platform policy, since it needs to
482// track platform policy development
483se_versioned_policy {
484 name: "plat_mapping_file",
485 base: ":plat_pub_policy.cil",
486 mapping: true,
487 version: "current",
488 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
489}
490
491se_versioned_policy {
492 name: "system_ext_mapping_file",
493 base: ":system_ext_pub_policy.cil",
494 mapping: true,
495 version: "current",
496 filter_out: [":plat_mapping_file"],
497 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
498 system_ext_specific: true,
499}
500
501se_versioned_policy {
502 name: "product_mapping_file",
503 base: ":pub_policy.cil",
504 mapping: true,
505 version: "current",
506 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
507 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
508 product_specific: true,
509}
510
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900511// vendor/odm sepolicy
512//
513// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
514// policy files of platform (system, system_ext, product) can't be mixed with
515// policy files of vendor (vendor, odm). If it's the case, platform policies and
516// vendor policies are separately built. More specifically,
517//
518// - Platform policy files needed to build vendor policies, such as plat_policy,
519// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
520// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
521//
522// - sepolicy_neverallows only checks platform policies, and a new module
523// sepolicy_neverallows_vendor checks vendor policies.
524//
525// - neverallow checks are turned off while compiling precompiled_sepolicy
526// module and sepolicy module.
527//
528// - Vendor policies are not checked on the compat test (compat.mk).
529//
530// In such scenario, we can grab platform policy files from the prebuilts/api
531// directory. But we need more than that: prebuilts of system_ext, product,
532// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
533// variables are introduced to specify such prebuilts.
534//
535// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
536// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
537// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
538// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
539// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
540// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
541//
542// Vendors are responsible for copying policy files from the old version of the
543// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
544// can be used to build vendor policies.
545//
546// To support both mixed build and normal build, platform policy files are
547// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
548// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
549// Otherwise, they will be equal to the Makefile variables above.
550
551plat_public_policies_for_vendor = [
552 ":se_build_files{.plat_public_for_vendor}",
553 ":se_build_files{.system_ext_public_for_vendor}",
554 ":se_build_files{.product_public_for_vendor}",
555 ":se_build_files{.reqd_mask_for_vendor}",
556]
557
558plat_policies_for_vendor = [
559 ":se_build_files{.plat_public_for_vendor}",
560 ":se_build_files{.plat_private_for_vendor}",
561 ":se_build_files{.system_ext_public_for_vendor}",
562 ":se_build_files{.system_ext_private_for_vendor}",
563 ":se_build_files{.product_public_for_vendor}",
564 ":se_build_files{.product_private_for_vendor}",
565]
566
567se_policy_conf {
568 name: "plat_policy_for_vendor.conf",
569 srcs: plat_policies_for_vendor,
570 installable: false,
571}
572
573se_policy_cil {
574 name: "plat_policy_for_vendor.cil",
575 src: ":plat_policy_for_vendor.conf",
576 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
577 installable: false,
578}
579
580se_policy_conf {
581 name: "reqd_policy_mask_for_vendor.conf",
582 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
583 installable: false,
584}
585
586se_policy_cil {
587 name: "reqd_policy_mask_for_vendor.cil",
588 src: ":reqd_policy_mask_for_vendor.conf",
589 secilc_check: false,
590 installable: false,
591}
592
593se_policy_conf {
594 name: "pub_policy_for_vendor.conf",
595 srcs: plat_public_policies_for_vendor,
596 installable: false,
597}
598
599se_policy_cil {
600 name: "pub_policy_for_vendor.cil",
601 src: ":pub_policy_for_vendor.conf",
602 filter_out: [":reqd_policy_mask_for_vendor.cil"],
603 secilc_check: false,
604 installable: false,
605}
606
607se_versioned_policy {
608 name: "plat_mapping_file_for_vendor",
609 base: ":pub_policy_for_vendor.cil",
610 mapping: true,
611 version: "vendor",
612 installable: false,
613}
614
Inseob Kim039175b2021-03-25 15:37:34 +0900615// plat_pub_versioned.cil - the exported platform policy associated with the version
616// that non-platform policy targets.
617se_versioned_policy {
618 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900619 base: ":pub_policy_for_vendor.cil",
620 target_policy: ":pub_policy_for_vendor.cil",
621 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900622 vendor: true,
623}
624
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900625// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
626// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
627// policy and the platform public policy files in order to use checkpolicy.
628se_policy_conf {
629 name: "vendor_sepolicy.conf",
630 srcs: plat_public_policies_for_vendor + [
631 ":se_build_files{.plat_vendor_for_vendor}",
632 ":se_build_files{.vendor}",
633 ],
634 installable: false,
635}
636
637se_policy_cil {
638 name: "vendor_sepolicy.cil.raw",
639 src: ":vendor_sepolicy.conf",
640 filter_out: [":reqd_policy_mask_for_vendor.cil"],
641 secilc_check: false, // will be done in se_versioned_policy module
642 installable: false,
643}
644
645se_versioned_policy {
646 name: "vendor_sepolicy.cil",
647 base: ":pub_policy_for_vendor.cil",
648 target_policy: ":vendor_sepolicy.cil.raw",
649 version: "vendor",
650 dependent_cils: [
651 ":plat_policy_for_vendor.cil",
652 ":plat_pub_versioned.cil",
653 ":plat_mapping_file_for_vendor",
654 ],
655 filter_out: [":plat_pub_versioned.cil"],
656 vendor: true,
657}
658
659// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
660// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
661// policy and the platform public policy files in order to use checkpolicy.
662se_policy_conf {
663 name: "odm_sepolicy.conf",
664 srcs: plat_public_policies_for_vendor + [
665 ":se_build_files{.plat_vendor_for_vendor}",
666 ":se_build_files{.vendor}",
667 ":se_build_files{.odm}",
668 ],
669 installable: false,
670}
671
672se_policy_cil {
673 name: "odm_sepolicy.cil.raw",
674 src: ":odm_sepolicy.conf",
675 filter_out: [
676 ":reqd_policy_mask_for_vendor.cil",
677 ":vendor_sepolicy.cil",
678 ],
679 secilc_check: false, // will be done in se_versioned_policy module
680 installable: false,
681}
682
683se_versioned_policy {
684 name: "odm_sepolicy.cil",
685 base: ":pub_policy_for_vendor.cil",
686 target_policy: ":odm_sepolicy.cil.raw",
687 version: "vendor",
688 dependent_cils: [
689 ":plat_policy_for_vendor.cil",
690 ":plat_pub_versioned.cil",
691 ":plat_mapping_file_for_vendor",
692 ":vendor_sepolicy.cil",
693 ],
694 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
695 device_specific: true,
696}
697
Inseob Kim039175b2021-03-25 15:37:34 +0900698//////////////////////////////////
699// Precompiled sepolicy is loaded if and only if:
700// - plat_sepolicy_and_mapping.sha256 equals
701// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
702// AND
703// - system_ext_sepolicy_and_mapping.sha256 equals
704// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
705// AND
706// - product_sepolicy_and_mapping.sha256 equals
707// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100708// AND
709// - apex_sepolicy.sha256 equals
710// precompiled_sepolicy.apex_sepolicy.sha256
Inseob Kim039175b2021-03-25 15:37:34 +0900711// See system/core/init/selinux.cpp for details.
712//////////////////////////////////
713genrule {
714 name: "plat_sepolicy_and_mapping.sha256_gen",
715 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
716 out: ["plat_sepolicy_and_mapping.sha256"],
717 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
718}
719
720prebuilt_etc {
721 name: "plat_sepolicy_and_mapping.sha256",
722 filename: "plat_sepolicy_and_mapping.sha256",
723 src: ":plat_sepolicy_and_mapping.sha256_gen",
724 relative_install_path: "selinux",
725}
726
727genrule {
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100728 name: "apex_sepolicy.sha256_gen",
729 srcs: [":apex_sepolicy-33.cil"],
730 out: ["apex_sepolicy.sha256"],
731 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
732}
733
734prebuilt_etc {
735 name: "apex_sepolicy.sha256",
736 filename: "apex_sepolicy.sha256",
737 src: ":apex_sepolicy.sha256_gen",
738 installable: false,
739}
740
741genrule {
Inseob Kim039175b2021-03-25 15:37:34 +0900742 name: "system_ext_sepolicy_and_mapping.sha256_gen",
743 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
744 out: ["system_ext_sepolicy_and_mapping.sha256"],
745 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
746}
747
748prebuilt_etc {
749 name: "system_ext_sepolicy_and_mapping.sha256",
750 filename: "system_ext_sepolicy_and_mapping.sha256",
751 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
752 relative_install_path: "selinux",
753 system_ext_specific: true,
754}
755
756genrule {
757 name: "product_sepolicy_and_mapping.sha256_gen",
758 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
759 out: ["product_sepolicy_and_mapping.sha256"],
760 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
761}
762
763prebuilt_etc {
764 name: "product_sepolicy_and_mapping.sha256",
765 filename: "product_sepolicy_and_mapping.sha256",
766 src: ":product_sepolicy_and_mapping.sha256_gen",
767 relative_install_path: "selinux",
768 product_specific: true,
769}
770
Inseob Kim1c056b12021-04-30 00:11:43 +0900771sepolicy_vers {
772 name: "plat_sepolicy_vers.txt",
773 version: "vendor",
774 vendor: true,
775}
776
Inseob Kim731182a2021-05-06 11:44:37 +0000777soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900778 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000779 module_type: "prebuilt_defaults",
780 config_namespace: "ANDROID",
781 bool_variables: ["BOARD_USES_ODMIMAGE"],
782 properties: ["vendor", "device_specific"],
783}
784
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900785precompiled_sepolicy_prebuilts_defaults {
786 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000787 soong_config_variables: {
788 BOARD_USES_ODMIMAGE: {
789 device_specific: true,
790 conditions_default: {
791 vendor: true,
792 },
793 },
794 },
795}
796
797//////////////////////////////////
798// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
799// which precompiled_policy was built.
800//////////////////////////////////
801prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900802 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000803 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
804 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
805 src: ":plat_sepolicy_and_mapping.sha256_gen",
806 relative_install_path: "selinux",
807}
808
809//////////////////////////////////
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100810// SHA-256 digest of the apex_sepolicy.cil against which precompiled_policy
811// was built.
812//////////////////////////////////
813prebuilt_etc {
814 defaults: ["precompiled_sepolicy_prebuilts"],
815 name: "precompiled_sepolicy.apex_sepolicy.sha256",
816 filename: "precompiled_sepolicy.apex_sepolicy.sha256",
817 src: ":apex_sepolicy.sha256_gen",
818 relative_install_path: "selinux",
819}
820
821//////////////////////////////////
Inseob Kim731182a2021-05-06 11:44:37 +0000822// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
823// which precompiled_policy was built.
824//////////////////////////////////
825prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900826 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000827 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
828 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
829 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
830 relative_install_path: "selinux",
831}
832
833//////////////////////////////////
834// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
835// which precompiled_policy was built.
836//////////////////////////////////
837prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900838 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000839 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
840 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
841 src: ":product_sepolicy_and_mapping.sha256_gen",
842 relative_install_path: "selinux",
843}
844
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900845soong_config_module_type {
846 name: "precompiled_se_policy_binary",
847 module_type: "se_policy_binary",
848 config_namespace: "ANDROID",
849 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
850 value_variables: ["MIXED_SEPOLICY_VERSION"],
851 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
852}
853
854precompiled_se_policy_binary {
855 name: "precompiled_sepolicy",
856 srcs: [
857 ":plat_sepolicy.cil",
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100858 ":apex_sepolicy-33.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900859 ":plat_pub_versioned.cil",
860 ":system_ext_sepolicy.cil",
861 ":product_sepolicy.cil",
862 ":vendor_sepolicy.cil",
863 ":odm_sepolicy.cil",
864 ],
865 soong_config_variables: {
866 BOARD_USES_ODMIMAGE: {
867 device_specific: true,
868 conditions_default: {
869 vendor: true,
870 },
871 },
872 IS_TARGET_MIXED_SEPOLICY: {
873 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900874 },
875 MIXED_SEPOLICY_VERSION: {
876 srcs: [
877 ":plat_%s.cil",
878 ":system_ext_%s.cil",
879 ":product_%s.cil",
880 ],
881 conditions_default: {
882 srcs: [
883 ":plat_mapping_file",
884 ":system_ext_mapping_file",
885 ":product_mapping_file",
886 ],
887 },
888 },
889 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900890 required: [
891 "sepolicy_neverallows",
892 "sepolicy_neverallows_vendor",
893 ],
Inseob Kimeec39192022-01-21 11:47:54 +0900894 dist: {
895 targets: ["base-sepolicy-files-for-mapping"],
896 },
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900897}
Inseob Kim731182a2021-05-06 11:44:37 +0000898
Inseob Kim5bbcd682021-12-28 14:57:03 +0900899// policy for recovery
900se_policy_conf {
901 name: "recovery_sepolicy.conf",
902 srcs: plat_policies_for_vendor + [
903 ":se_build_files{.plat_vendor_for_vendor}",
904 ":se_build_files{.vendor}",
905 ":se_build_files{.odm}",
906 ],
907 target_recovery: true,
908 installable: false,
909}
910
911se_policy_cil {
912 name: "recovery_sepolicy.cil",
913 src: ":recovery_sepolicy.conf",
914 secilc_check: false, // will be done in se_policy_binary module
915 installable: false,
916}
917
918se_policy_binary {
919 name: "sepolicy.recovery",
920 srcs: [":recovery_sepolicy.cil"],
921 stem: "sepolicy",
922 recovery: true,
923}
924
Inseob Kima49e7242021-03-22 10:26:13 +0900925//////////////////////////////////
926// SELinux policy embedded into CTS.
927// CTS checks neverallow rules of this policy against the policy of the device under test.
928//////////////////////////////////
929se_policy_conf {
930 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900931 srcs: plat_public_policy +
932 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900933 build_variant: "user",
934 cts: true,
935 exclude_build_test: true,
936}
Inseob Kimd5816612021-09-15 03:01:05 +0000937
938//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000939// Base system policy for treble sepolicy tests.
940// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
941// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
942// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
943// See treble_sepolicy_tests_for_release.mk for more details.
944//////////////////////////////////
945se_policy_conf {
946 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900947 srcs: plat_public_policy +
948 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000949 build_variant: "user",
950 installable: false,
951}
952
953se_policy_cil {
954 name: "base_plat_sepolicy.cil",
955 src: ":base_plat_sepolicy.conf",
956 additional_cil_files: ["private/technical_debt.cil"],
957 installable: false,
958 secilc_check: false, // done by se_policy_binary
959}
960
961se_policy_binary {
962 name: "base_plat_sepolicy",
963 srcs: [":base_plat_sepolicy.cil"],
964 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900965 dist: {
966 targets: ["base-sepolicy-files-for-mapping"],
967 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000968}
969
970se_policy_conf {
971 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900972 srcs: plat_public_policy +
973 plat_private_policy +
974 system_ext_public_policy +
975 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000976 build_variant: "user",
977 installable: false,
978}
979
980se_policy_cil {
981 name: "base_system_ext_sepolicy.cil",
982 src: ":base_system_ext_sepolicy.conf",
983 additional_cil_files: ["private/technical_debt.cil"],
984 system_ext_specific: true,
985 installable: false,
986 secilc_check: false, // done by se_policy_binary
987}
988
989se_policy_binary {
990 name: "base_system_ext_sepolicy",
991 srcs: [":base_system_ext_sepolicy.cil"],
992 system_ext_specific: true,
993 installable: false,
994}
995
996se_policy_conf {
997 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900998 srcs: plat_public_policy +
999 plat_private_policy +
1000 system_ext_public_policy +
1001 system_ext_private_policy +
1002 product_public_policy +
1003 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001004 build_variant: "user",
1005 installable: false,
1006}
1007
1008se_policy_cil {
1009 name: "base_product_sepolicy.cil",
1010 src: ":base_product_sepolicy.conf",
1011 additional_cil_files: ["private/technical_debt.cil"],
1012 product_specific: true,
1013 installable: false,
1014 secilc_check: false, // done by se_policy_binary
1015}
1016
1017se_policy_binary {
1018 name: "base_product_sepolicy",
1019 srcs: [":base_product_sepolicy.cil"],
1020 product_specific: true,
1021 installable: false,
1022}
1023
1024se_policy_conf {
1025 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001026 srcs: plat_public_policy +
1027 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001028 build_variant: "user",
1029 installable: false,
1030}
1031
1032se_policy_cil {
1033 name: "base_plat_pub_policy.cil",
1034 src: ":base_plat_pub_policy.conf",
1035 filter_out: [":reqd_policy_mask.cil"],
1036 secilc_check: false,
1037 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +09001038 dist: {
1039 targets: ["base-sepolicy-files-for-mapping"],
1040 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001041}
1042
1043se_policy_conf {
1044 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001045 srcs: plat_public_policy +
1046 system_ext_public_policy +
1047 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001048 build_variant: "user",
1049 installable: false,
1050}
1051
1052se_policy_cil {
1053 name: "base_system_ext_pub_policy.cil",
1054 src: ":base_system_ext_pub_policy.conf",
1055 filter_out: [":reqd_policy_mask.cil"],
1056 secilc_check: false,
1057 installable: false,
1058}
1059
1060se_policy_conf {
1061 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001062 srcs: plat_public_policy +
1063 system_ext_public_policy +
1064 product_public_policy +
1065 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001066 build_variant: "user",
1067 installable: false,
1068}
1069
1070se_policy_cil {
1071 name: "base_product_pub_policy.cil",
1072 src: ":base_product_pub_policy.conf",
1073 filter_out: [":reqd_policy_mask.cil"],
1074 secilc_check: false,
1075 installable: false,
1076}
1077
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001078// bug_map - Bug tracking information for selinux denials loaded by auditd.
Inseob Kim41964032022-04-22 07:50:22 +09001079se_build_files {
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001080 name: "bug_map_files",
1081 srcs: ["bug_map"],
1082}
1083
1084se_bug_map {
1085 name: "plat_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +09001086 srcs: [":bug_map_files{.plat_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001087 stem: "bug_map",
1088}
1089
1090se_bug_map {
1091 name: "system_ext_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +09001092 srcs: [":bug_map_files{.system_ext_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001093 stem: "bug_map",
1094 system_ext_specific: true,
1095}
1096
1097se_bug_map {
1098 name: "vendor_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +09001099 srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor_for_vendor}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001100 // Legacy file name of the vendor partition bug_map.
1101 stem: "selinux_denial_metadata",
1102 vendor: true,
1103}
1104
Inseob Kim0de7fcc2021-12-22 23:06:53 +09001105se_neverallow_test {
1106 name: "sepolicy_neverallows",
1107 srcs: plat_public_policy +
1108 plat_private_policy +
1109 system_ext_public_policy +
1110 system_ext_private_policy +
1111 product_public_policy +
1112 product_private_policy,
1113}
1114
1115se_neverallow_test {
1116 name: "sepolicy_neverallows_vendor",
1117 srcs: plat_policies_for_vendor + [
1118 ":se_build_files{.plat_vendor_for_vendor}",
1119 ":se_build_files{.vendor}",
1120 ":se_build_files{.odm}",
1121 ],
1122}
1123
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001124//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001125// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1126// Additional directories can be specified via Makefile variables:
1127// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1128//////////////////////////////////
1129se_freeze_test {
1130 name: "sepolicy_freeze_test",
1131}
Inseob Kim61257ca2022-02-25 11:26:16 +09001132
1133//////////////////////////////////
1134// sepolicy_test checks various types of violations, which can't be easily done
1135// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
1136//////////////////////////////////
1137genrule {
1138 name: "sepolicy_test",
1139 srcs: [
1140 ":plat_file_contexts",
1141 ":vendor_file_contexts",
1142 ":system_ext_file_contexts",
1143 ":product_file_contexts",
1144 ":odm_file_contexts",
1145 ":precompiled_sepolicy",
1146 ],
1147 tools: ["sepolicy_tests"],
1148 out: ["sepolicy_test"],
1149 cmd: "$(location sepolicy_tests) " +
1150 "-f $(location :plat_file_contexts) " +
1151 "-f $(location :vendor_file_contexts) " +
1152 "-f $(location :system_ext_file_contexts) " +
1153 "-f $(location :product_file_contexts) " +
1154 "-f $(location :odm_file_contexts) " +
1155 "-p $(location :precompiled_sepolicy) && " +
1156 "touch $(out)",
1157}