blob: 1d06d7d97c05d1ce2ca925cf9eb90e510bf5317c [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
yangbill3e345372020-04-15 13:55:47 +080047// For vts_treble_sys_prop_test
48filegroup {
49 name: "private_property_contexts",
50 srcs: ["private/property_contexts"],
51 visibility: [
52 "//test/vts-testcase/security/system_property",
53 ],
54}
Inseob Kime35b49b2021-02-18 19:15:41 +090055
Inseob Kima49e7242021-03-22 10:26:13 +090056se_build_files {
57 name: "se_build_files",
Inseob Kime35b49b2021-02-18 19:15:41 +090058 srcs: [
Inseob Kima49e7242021-03-22 10:26:13 +090059 "security_classes",
60 "initial_sids",
61 "access_vectors",
62 "global_macros",
63 "neverallow_macros",
64 "mls_macros",
65 "mls_decl",
66 "mls",
67 "policy_capabilities",
68 "te_macros",
69 "attributes",
70 "ioctl_defines",
71 "ioctl_macros",
72 "*.te",
73 "roles_decl",
74 "roles",
75 "users",
76 "initial_sid_contexts",
77 "fs_use",
78 "genfs_contexts",
79 "port_contexts",
Inseob Kime35b49b2021-02-18 19:15:41 +090080 ],
81}
82
Inseob Kim7cb20812021-12-16 16:52:14 +090083se_build_files {
84 name: "sepolicy_technical_debt",
85 srcs: ["technical_debt.cil"],
86}
87
Inseob Kim0a707fa2021-12-09 23:35:11 +090088reqd_mask_policy = [":se_build_files{.reqd_mask}"]
89plat_public_policy = [":se_build_files{.plat_public}"]
90plat_private_policy = [":se_build_files{.plat_private}"]
91system_ext_public_policy = [":se_build_files{.system_ext_public}"]
92system_ext_private_policy = [":se_build_files{.system_ext_private}"]
93product_public_policy = [":se_build_files{.product_public}"]
94product_private_policy = [":se_build_files{.product_private}"]
95
Inseob Kima49e7242021-03-22 10:26:13 +090096// reqd_policy_mask - a policy.conf file which contains only the bare minimum
97// policy necessary to use checkpolicy.
98//
99// This bare-minimum policy needs to be present in all policy.conf files, but
100// should not necessarily be exported as part of the public policy.
101//
102// The rules generated by reqd_policy_mask will allow the compilation of public
103// policy and subsequent removal of CIL policy that should not be exported.
104se_policy_conf {
105 name: "reqd_policy_mask.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900106 srcs: reqd_mask_policy,
Inseob Kime35b49b2021-02-18 19:15:41 +0900107 installable: false,
108}
109
Inseob Kima49e7242021-03-22 10:26:13 +0900110se_policy_cil {
111 name: "reqd_policy_mask.cil",
112 src: ":reqd_policy_mask.conf",
113 secilc_check: false,
114 installable: false,
Inseob Kime35b49b2021-02-18 19:15:41 +0900115}
116
Inseob Kima49e7242021-03-22 10:26:13 +0900117// pub_policy - policy that will be exported to be a part of non-platform
118// policy corresponding to this platform version.
119//
120// This is a limited subset of policy that would not compile in checkpolicy on
121// its own.
122//
123// To get around this limitation, add only the required files from private
124// policy, which will generate CIL policy that will then be filtered out by the
125// reqd_policy_mask.
126//
127// There are three pub_policy.cil files below:
128// - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
129// - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
130// - plat_pub_policy.cil: exported 'system' policy.
131//
132// Those above files will in turn be used to generate the following versioned cil files:
133// - product_mapping_file: the versioned, exported 'product' policy in product partition.
134// - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
135// - plat_mapping_file: the versioned, exported 'system' policy in system partition.
136// - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
137// in vendor partition.
138//
139se_policy_conf {
140 name: "pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900141 srcs: plat_public_policy +
142 system_ext_public_policy +
143 product_public_policy +
144 reqd_mask_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900145 vendor: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900146 installable: false,
147}
148
149se_policy_cil {
150 name: "pub_policy.cil",
151 src: ":pub_policy.conf",
152 filter_out: [":reqd_policy_mask.cil"],
153 secilc_check: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900154 vendor: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900155 installable: false,
156}
157
158se_policy_conf {
159 name: "system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900160 srcs: plat_public_policy +
161 system_ext_public_policy +
162 reqd_mask_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900163 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900164 installable: false,
165}
166
167se_policy_cil {
168 name: "system_ext_pub_policy.cil",
169 src: ":system_ext_pub_policy.conf",
170 filter_out: [":reqd_policy_mask.cil"],
171 secilc_check: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900172 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900173 installable: false,
174}
175
176se_policy_conf {
177 name: "plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900178 srcs: plat_public_policy +
179 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900180 installable: false,
181}
182
183se_policy_cil {
184 name: "plat_pub_policy.cil",
185 src: ":plat_pub_policy.conf",
186 filter_out: [":reqd_policy_mask.cil"],
187 secilc_check: false,
188 installable: false,
189}
190
191// plat_policy.conf - A combination of the private and public platform policy
192// which will ship with the device.
193//
194// The platform will always reflect the most recent platform version and is not
195// currently being attributized.
196se_policy_conf {
197 name: "plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900198 srcs: plat_public_policy +
199 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900200 installable: false,
201}
202
203se_policy_cil {
204 name: "plat_sepolicy.cil",
205 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900206 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900207}
208
Lokesh Gidra1269a172022-08-01 17:20:38 +0000209
Inseob Kim6cc75f42021-04-29 13:53:20 +0000210// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
211se_policy_conf {
212 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900213 srcs: plat_public_policy +
214 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000215 build_variant: "userdebug",
216 installable: false,
217}
218
219se_policy_cil {
220 name: "userdebug_plat_sepolicy.cil",
221 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900222 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000223 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800224 dist: {
225 targets: ["droidcore"],
226 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000227}
228
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000229// A copy of the userdebug_plat_policy in GSI.
230soong_config_module_type {
231 name: "gsi_se_policy_cil",
232 module_type: "se_policy_cil",
233 config_namespace: "ANDROID",
234 bool_variables: [
235 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
236 ],
237 properties: [
238 "enabled",
239 "installable",
240 ],
241}
242
243gsi_se_policy_cil {
244 name: "system_ext_userdebug_plat_sepolicy.cil",
245 stem: "userdebug_plat_sepolicy.cil",
246 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900247 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000248 system_ext_specific: true,
249 enabled: false,
250 installable: false,
251 soong_config_variables: {
252 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
253 enabled: true,
254 installable: true,
255 },
256 },
257}
258
Inseob Kima49e7242021-03-22 10:26:13 +0900259// system_ext_policy.conf - A combination of the private and public system_ext
260// policy which will ship with the device. System_ext policy is not attributized
261se_policy_conf {
262 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900263 srcs: plat_public_policy +
264 plat_private_policy +
265 system_ext_public_policy +
266 system_ext_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900267 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900268 installable: false,
269}
270
271se_policy_cil {
272 name: "system_ext_sepolicy.cil",
273 src: ":system_ext_sepolicy.conf",
274 system_ext_specific: true,
275 filter_out: [":plat_sepolicy.cil"],
276 remove_line_marker: true,
277}
278
279// product_policy.conf - A combination of the private and public product policy
280// which will ship with the device. Product policy is not attributized
281se_policy_conf {
282 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900283 srcs: plat_public_policy +
284 plat_private_policy +
285 system_ext_public_policy +
286 system_ext_private_policy +
287 product_public_policy +
288 product_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900289 product_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900290 installable: false,
291}
292
293se_policy_cil {
294 name: "product_sepolicy.cil",
295 src: ":product_sepolicy.conf",
296 product_specific: true,
297 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
298 remove_line_marker: true,
299}
300
Inseob Kim039175b2021-03-25 15:37:34 +0900301// policy mapping files
302// auto-generate the mapping file for current platform policy, since it needs to
303// track platform policy development
304se_versioned_policy {
305 name: "plat_mapping_file",
306 base: ":plat_pub_policy.cil",
307 mapping: true,
308 version: "current",
309 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
310}
311
312se_versioned_policy {
313 name: "system_ext_mapping_file",
314 base: ":system_ext_pub_policy.cil",
315 mapping: true,
316 version: "current",
317 filter_out: [":plat_mapping_file"],
318 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
319 system_ext_specific: true,
320}
321
322se_versioned_policy {
323 name: "product_mapping_file",
324 base: ":pub_policy.cil",
325 mapping: true,
326 version: "current",
327 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
328 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
329 product_specific: true,
330}
331
Inseob Kim6c6aa012023-08-31 16:47:38 +0900332//////////////////////////////////
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900333// vendor/odm sepolicy
Inseob Kim6c6aa012023-08-31 16:47:38 +0900334//////////////////////////////////
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900335
Inseob Kim039175b2021-03-25 15:37:34 +0900336// plat_pub_versioned.cil - the exported platform policy associated with the version
337// that non-platform policy targets.
338se_versioned_policy {
339 name: "plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900340 base: ":pub_policy.cil",
341 target_policy: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900342 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900343 vendor: true,
344}
345
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900346// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
347// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
348// policy and the platform public policy files in order to use checkpolicy.
349se_policy_conf {
350 name: "vendor_sepolicy.conf",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900351 srcs: plat_public_policy +
352 system_ext_public_policy +
353 product_public_policy +
354 reqd_mask_policy + [
355 ":se_build_files{.plat_vendor}",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900356 ":se_build_files{.vendor}",
357 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900358 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900359 installable: false,
360}
361
362se_policy_cil {
363 name: "vendor_sepolicy.cil.raw",
364 src: ":vendor_sepolicy.conf",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900365 filter_out: [":reqd_policy_mask.cil"],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900366 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900367 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900368 installable: false,
369}
370
371se_versioned_policy {
372 name: "vendor_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900373 base: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900374 target_policy: ":vendor_sepolicy.cil.raw",
375 version: "vendor",
376 dependent_cils: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900377 ":plat_sepolicy.cil",
378 ":system_ext_sepolicy.cil",
379 ":product_sepolicy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900380 ":plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900381 ":plat_mapping_file",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900382 ],
383 filter_out: [":plat_pub_versioned.cil"],
384 vendor: true,
385}
386
387// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
388// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
389// policy and the platform public policy files in order to use checkpolicy.
390se_policy_conf {
391 name: "odm_sepolicy.conf",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900392 srcs: plat_public_policy +
393 system_ext_public_policy +
394 product_public_policy +
395 reqd_mask_policy + [
396 ":se_build_files{.plat_vendor}",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900397 ":se_build_files{.vendor}",
398 ":se_build_files{.odm}",
399 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900400 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900401 installable: false,
402}
403
404se_policy_cil {
405 name: "odm_sepolicy.cil.raw",
406 src: ":odm_sepolicy.conf",
407 filter_out: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900408 ":reqd_policy_mask.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900409 ":vendor_sepolicy.cil",
410 ],
411 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900412 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900413 installable: false,
414}
415
416se_versioned_policy {
417 name: "odm_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900418 base: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900419 target_policy: ":odm_sepolicy.cil.raw",
420 version: "vendor",
421 dependent_cils: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900422 ":plat_sepolicy.cil",
423 ":system_ext_sepolicy.cil",
424 ":product_sepolicy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900425 ":plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900426 ":plat_mapping_file",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900427 ":vendor_sepolicy.cil",
428 ],
429 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
430 device_specific: true,
431}
432
Inseob Kim039175b2021-03-25 15:37:34 +0900433//////////////////////////////////
434// Precompiled sepolicy is loaded if and only if:
435// - plat_sepolicy_and_mapping.sha256 equals
436// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
437// AND
438// - system_ext_sepolicy_and_mapping.sha256 equals
439// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
440// AND
441// - product_sepolicy_and_mapping.sha256 equals
442// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
443// See system/core/init/selinux.cpp for details.
444//////////////////////////////////
445genrule {
446 name: "plat_sepolicy_and_mapping.sha256_gen",
447 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
448 out: ["plat_sepolicy_and_mapping.sha256"],
449 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
450}
451
452prebuilt_etc {
453 name: "plat_sepolicy_and_mapping.sha256",
454 filename: "plat_sepolicy_and_mapping.sha256",
455 src: ":plat_sepolicy_and_mapping.sha256_gen",
456 relative_install_path: "selinux",
457}
458
459genrule {
460 name: "system_ext_sepolicy_and_mapping.sha256_gen",
461 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
462 out: ["system_ext_sepolicy_and_mapping.sha256"],
463 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
464}
465
466prebuilt_etc {
467 name: "system_ext_sepolicy_and_mapping.sha256",
468 filename: "system_ext_sepolicy_and_mapping.sha256",
469 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
470 relative_install_path: "selinux",
471 system_ext_specific: true,
472}
473
474genrule {
475 name: "product_sepolicy_and_mapping.sha256_gen",
476 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
477 out: ["product_sepolicy_and_mapping.sha256"],
478 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
479}
480
481prebuilt_etc {
482 name: "product_sepolicy_and_mapping.sha256",
483 filename: "product_sepolicy_and_mapping.sha256",
484 src: ":product_sepolicy_and_mapping.sha256_gen",
485 relative_install_path: "selinux",
486 product_specific: true,
487}
488
Inseob Kim1c056b12021-04-30 00:11:43 +0900489sepolicy_vers {
490 name: "plat_sepolicy_vers.txt",
491 version: "vendor",
492 vendor: true,
493}
494
Inseob Kim731182a2021-05-06 11:44:37 +0000495soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900496 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000497 module_type: "prebuilt_defaults",
498 config_namespace: "ANDROID",
499 bool_variables: ["BOARD_USES_ODMIMAGE"],
500 properties: ["vendor", "device_specific"],
501}
502
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900503precompiled_sepolicy_prebuilts_defaults {
504 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000505 soong_config_variables: {
506 BOARD_USES_ODMIMAGE: {
507 device_specific: true,
508 conditions_default: {
509 vendor: true,
510 },
511 },
512 },
513}
514
515//////////////////////////////////
516// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
517// which precompiled_policy was built.
518//////////////////////////////////
519prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900520 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000521 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
522 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
523 src: ":plat_sepolicy_and_mapping.sha256_gen",
524 relative_install_path: "selinux",
525}
526
527//////////////////////////////////
528// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
529// which precompiled_policy was built.
530//////////////////////////////////
531prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900532 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000533 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
534 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
535 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
536 relative_install_path: "selinux",
537}
538
539//////////////////////////////////
540// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
541// which precompiled_policy was built.
542//////////////////////////////////
543prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900544 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000545 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
546 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
547 src: ":product_sepolicy_and_mapping.sha256_gen",
548 relative_install_path: "selinux",
549}
550
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900551soong_config_module_type {
552 name: "precompiled_se_policy_binary",
553 module_type: "se_policy_binary",
554 config_namespace: "ANDROID",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900555 bool_variables: ["BOARD_USES_ODMIMAGE"],
556 properties: ["vendor", "device_specific"],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900557}
558
559precompiled_se_policy_binary {
560 name: "precompiled_sepolicy",
561 srcs: [
562 ":plat_sepolicy.cil",
Sandro143988d2022-08-05 11:38:56 +0000563 ":plat_pub_versioned.cil",
564 ":system_ext_sepolicy.cil",
565 ":product_sepolicy.cil",
566 ":vendor_sepolicy.cil",
567 ":odm_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900568 ":plat_mapping_file",
569 ":system_ext_mapping_file",
570 ":product_mapping_file",
Sandro143988d2022-08-05 11:38:56 +0000571 ],
572 soong_config_variables: {
573 BOARD_USES_ODMIMAGE: {
574 device_specific: true,
575 conditions_default: {
576 vendor: true,
577 },
578 },
Sandro143988d2022-08-05 11:38:56 +0000579 },
580 required: [
581 "sepolicy_neverallows",
Sandro143988d2022-08-05 11:38:56 +0000582 ],
583 dist: {
584 targets: ["base-sepolicy-files-for-mapping"],
585 },
586}
587
Inseob Kim5bbcd682021-12-28 14:57:03 +0900588// policy for recovery
589se_policy_conf {
590 name: "recovery_sepolicy.conf",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900591 srcs: plat_public_policy +
592 plat_private_policy +
593 system_ext_public_policy +
594 system_ext_private_policy +
595 product_public_policy +
596 product_private_policy + [
597 ":se_build_files{.plat_vendor}",
Inseob Kim5bbcd682021-12-28 14:57:03 +0900598 ":se_build_files{.vendor}",
599 ":se_build_files{.odm}",
600 ],
601 target_recovery: true,
602 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900603 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900604}
605
606se_policy_cil {
607 name: "recovery_sepolicy.cil",
608 src: ":recovery_sepolicy.conf",
609 secilc_check: false, // will be done in se_policy_binary module
610 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900611 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900612}
613
614se_policy_binary {
615 name: "sepolicy.recovery",
616 srcs: [":recovery_sepolicy.cil"],
617 stem: "sepolicy",
618 recovery: true,
619}
620
Inseob Kima49e7242021-03-22 10:26:13 +0900621//////////////////////////////////
622// SELinux policy embedded into CTS.
623// CTS checks neverallow rules of this policy against the policy of the device under test.
624//////////////////////////////////
625se_policy_conf {
626 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900627 srcs: plat_public_policy +
628 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900629 build_variant: "user",
630 cts: true,
631 exclude_build_test: true,
632}
Inseob Kimd5816612021-09-15 03:01:05 +0000633
634//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000635// Base system policy for treble sepolicy tests.
636// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
637// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
638// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
639// See treble_sepolicy_tests_for_release.mk for more details.
640//////////////////////////////////
641se_policy_conf {
642 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900643 srcs: plat_public_policy +
644 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000645 build_variant: "user",
646 installable: false,
647}
648
649se_policy_cil {
650 name: "base_plat_sepolicy.cil",
651 src: ":base_plat_sepolicy.conf",
652 additional_cil_files: ["private/technical_debt.cil"],
653 installable: false,
654 secilc_check: false, // done by se_policy_binary
655}
656
657se_policy_binary {
658 name: "base_plat_sepolicy",
659 srcs: [":base_plat_sepolicy.cil"],
660 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900661 dist: {
662 targets: ["base-sepolicy-files-for-mapping"],
663 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000664}
665
666se_policy_conf {
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000667 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900668 srcs: plat_public_policy +
669 plat_private_policy +
670 system_ext_public_policy +
671 system_ext_private_policy +
672 product_public_policy +
673 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000674 build_variant: "user",
675 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900676 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000677}
678
679se_policy_cil {
680 name: "base_product_sepolicy.cil",
681 src: ":base_product_sepolicy.conf",
682 additional_cil_files: ["private/technical_debt.cil"],
683 product_specific: true,
684 installable: false,
685 secilc_check: false, // done by se_policy_binary
686}
687
688se_policy_binary {
689 name: "base_product_sepolicy",
690 srcs: [":base_product_sepolicy.cil"],
691 product_specific: true,
692 installable: false,
693}
694
695se_policy_conf {
696 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900697 srcs: plat_public_policy +
698 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000699 build_variant: "user",
700 installable: false,
701}
702
703se_policy_cil {
704 name: "base_plat_pub_policy.cil",
705 src: ":base_plat_pub_policy.conf",
706 filter_out: [":reqd_policy_mask.cil"],
707 secilc_check: false,
708 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900709 dist: {
710 targets: ["base-sepolicy-files-for-mapping"],
711 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000712}
713
714se_policy_conf {
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000715 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900716 srcs: plat_public_policy +
717 system_ext_public_policy +
718 product_public_policy +
719 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000720 build_variant: "user",
721 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900722 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000723}
724
725se_policy_cil {
726 name: "base_product_pub_policy.cil",
727 src: ":base_product_pub_policy.conf",
728 filter_out: [":reqd_policy_mask.cil"],
729 secilc_check: false,
730 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900731 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000732}
733
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800734// bug_map - Bug tracking information for selinux denials loaded by auditd.
Inseob Kim41964032022-04-22 07:50:22 +0900735se_build_files {
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800736 name: "bug_map_files",
737 srcs: ["bug_map"],
738}
739
740se_bug_map {
741 name: "plat_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900742 srcs: [":bug_map_files{.plat_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800743 stem: "bug_map",
744}
745
746se_bug_map {
747 name: "system_ext_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900748 srcs: [":bug_map_files{.system_ext_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800749 stem: "bug_map",
750 system_ext_specific: true,
751}
752
753se_bug_map {
754 name: "vendor_bug_map",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900755 srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800756 // Legacy file name of the vendor partition bug_map.
757 stem: "selinux_denial_metadata",
758 vendor: true,
759}
760
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900761se_neverallow_test {
762 name: "sepolicy_neverallows",
763 srcs: plat_public_policy +
764 plat_private_policy +
765 system_ext_public_policy +
766 system_ext_private_policy +
767 product_public_policy +
Inseob Kim6c6aa012023-08-31 16:47:38 +0900768 product_private_policy + [
769 ":se_build_files{.plat_vendor}",
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900770 ":se_build_files{.vendor}",
771 ":se_build_files{.odm}",
772 ],
773}
774
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000775//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +0000776// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
777// Additional directories can be specified via Makefile variables:
778// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
779//////////////////////////////////
780se_freeze_test {
Inseob Kim36d9d392023-09-04 17:40:03 +0900781 name: "se_freeze_test",
Inseob Kimd5816612021-09-15 03:01:05 +0000782}
Inseob Kim61257ca2022-02-25 11:26:16 +0900783
784//////////////////////////////////
785// sepolicy_test checks various types of violations, which can't be easily done
786// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
787//////////////////////////////////
788genrule {
789 name: "sepolicy_test",
790 srcs: [
791 ":plat_file_contexts",
792 ":vendor_file_contexts",
793 ":system_ext_file_contexts",
794 ":product_file_contexts",
795 ":odm_file_contexts",
796 ":precompiled_sepolicy",
797 ],
798 tools: ["sepolicy_tests"],
799 out: ["sepolicy_test"],
800 cmd: "$(location sepolicy_tests) " +
801 "-f $(location :plat_file_contexts) " +
802 "-f $(location :vendor_file_contexts) " +
803 "-f $(location :system_ext_file_contexts) " +
804 "-f $(location :product_file_contexts) " +
805 "-f $(location :odm_file_contexts) " +
806 "-p $(location :precompiled_sepolicy) && " +
807 "touch $(out)",
808}