blob: 038d92f60b6ba833b282704a49c7a6e33ba74a19 [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 Kim085f22f2023-11-09 11:13:01 +0900106 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900107 srcs: reqd_mask_policy,
Inseob Kime35b49b2021-02-18 19:15:41 +0900108 installable: false,
109}
110
Inseob Kima49e7242021-03-22 10:26:13 +0900111se_policy_cil {
112 name: "reqd_policy_mask.cil",
113 src: ":reqd_policy_mask.conf",
114 secilc_check: false,
115 installable: false,
Inseob Kime35b49b2021-02-18 19:15:41 +0900116}
117
Inseob Kima49e7242021-03-22 10:26:13 +0900118// pub_policy - policy that will be exported to be a part of non-platform
119// policy corresponding to this platform version.
120//
121// This is a limited subset of policy that would not compile in checkpolicy on
122// its own.
123//
124// To get around this limitation, add only the required files from private
125// policy, which will generate CIL policy that will then be filtered out by the
126// reqd_policy_mask.
127//
128// There are three pub_policy.cil files below:
129// - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
130// - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
131// - plat_pub_policy.cil: exported 'system' policy.
132//
133// Those above files will in turn be used to generate the following versioned cil files:
134// - product_mapping_file: the versioned, exported 'product' policy in product partition.
135// - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
136// - plat_mapping_file: the versioned, exported 'system' policy in system partition.
137// - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
138// in vendor partition.
139//
140se_policy_conf {
141 name: "pub_policy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900142 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900143 srcs: plat_public_policy +
144 system_ext_public_policy +
145 product_public_policy +
146 reqd_mask_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900147 vendor: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900148 installable: false,
149}
150
151se_policy_cil {
152 name: "pub_policy.cil",
153 src: ":pub_policy.conf",
154 filter_out: [":reqd_policy_mask.cil"],
155 secilc_check: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900156 vendor: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900157 installable: false,
158}
159
160se_policy_conf {
161 name: "system_ext_pub_policy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900162 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900163 srcs: plat_public_policy +
164 system_ext_public_policy +
165 reqd_mask_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900166 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900167 installable: false,
168}
169
170se_policy_cil {
171 name: "system_ext_pub_policy.cil",
172 src: ":system_ext_pub_policy.conf",
173 filter_out: [":reqd_policy_mask.cil"],
174 secilc_check: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900175 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900176 installable: false,
177}
178
179se_policy_conf {
180 name: "plat_pub_policy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900181 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900182 srcs: plat_public_policy +
183 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900184 installable: false,
185}
186
187se_policy_cil {
188 name: "plat_pub_policy.cil",
189 src: ":plat_pub_policy.conf",
190 filter_out: [":reqd_policy_mask.cil"],
191 secilc_check: false,
192 installable: false,
193}
194
195// plat_policy.conf - A combination of the private and public platform policy
196// which will ship with the device.
197//
198// The platform will always reflect the most recent platform version and is not
199// currently being attributized.
200se_policy_conf {
201 name: "plat_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900202 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900203 srcs: plat_public_policy +
204 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900205 installable: false,
206}
207
208se_policy_cil {
209 name: "plat_sepolicy.cil",
210 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900211 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900212}
213
Lokesh Gidra1269a172022-08-01 17:20:38 +0000214
Inseob Kim6cc75f42021-04-29 13:53:20 +0000215// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
216se_policy_conf {
217 name: "userdebug_plat_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900218 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900219 srcs: plat_public_policy +
220 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000221 build_variant: "userdebug",
222 installable: false,
223}
224
225se_policy_cil {
226 name: "userdebug_plat_sepolicy.cil",
227 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900228 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000229 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800230 dist: {
231 targets: ["droidcore"],
232 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000233}
234
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000235// A copy of the userdebug_plat_policy in GSI.
236soong_config_module_type {
237 name: "gsi_se_policy_cil",
238 module_type: "se_policy_cil",
239 config_namespace: "ANDROID",
240 bool_variables: [
241 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
242 ],
243 properties: [
244 "enabled",
245 "installable",
246 ],
247}
248
249gsi_se_policy_cil {
250 name: "system_ext_userdebug_plat_sepolicy.cil",
251 stem: "userdebug_plat_sepolicy.cil",
252 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900253 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000254 system_ext_specific: true,
255 enabled: false,
256 installable: false,
257 soong_config_variables: {
258 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
259 enabled: true,
260 installable: true,
261 },
262 },
263}
264
Inseob Kima49e7242021-03-22 10:26:13 +0900265// system_ext_policy.conf - A combination of the private and public system_ext
266// policy which will ship with the device. System_ext policy is not attributized
267se_policy_conf {
268 name: "system_ext_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900269 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900270 srcs: plat_public_policy +
271 plat_private_policy +
272 system_ext_public_policy +
273 system_ext_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900274 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900275 installable: false,
276}
277
278se_policy_cil {
279 name: "system_ext_sepolicy.cil",
280 src: ":system_ext_sepolicy.conf",
281 system_ext_specific: true,
282 filter_out: [":plat_sepolicy.cil"],
283 remove_line_marker: true,
284}
285
286// product_policy.conf - A combination of the private and public product policy
287// which will ship with the device. Product policy is not attributized
288se_policy_conf {
289 name: "product_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900290 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900291 srcs: plat_public_policy +
292 plat_private_policy +
293 system_ext_public_policy +
294 system_ext_private_policy +
295 product_public_policy +
296 product_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900297 product_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900298 installable: false,
299}
300
301se_policy_cil {
302 name: "product_sepolicy.cil",
303 src: ":product_sepolicy.conf",
304 product_specific: true,
305 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
306 remove_line_marker: true,
307}
308
Inseob Kim039175b2021-03-25 15:37:34 +0900309// policy mapping files
310// auto-generate the mapping file for current platform policy, since it needs to
311// track platform policy development
312se_versioned_policy {
313 name: "plat_mapping_file",
314 base: ":plat_pub_policy.cil",
315 mapping: true,
316 version: "current",
317 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
318}
319
320se_versioned_policy {
321 name: "system_ext_mapping_file",
322 base: ":system_ext_pub_policy.cil",
323 mapping: true,
324 version: "current",
325 filter_out: [":plat_mapping_file"],
326 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
327 system_ext_specific: true,
328}
329
330se_versioned_policy {
331 name: "product_mapping_file",
332 base: ":pub_policy.cil",
333 mapping: true,
334 version: "current",
335 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
336 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
337 product_specific: true,
338}
339
Inseob Kim6c6aa012023-08-31 16:47:38 +0900340//////////////////////////////////
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900341// vendor/odm sepolicy
Inseob Kim6c6aa012023-08-31 16:47:38 +0900342//////////////////////////////////
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900343
Inseob Kim039175b2021-03-25 15:37:34 +0900344// plat_pub_versioned.cil - the exported platform policy associated with the version
345// that non-platform policy targets.
346se_versioned_policy {
347 name: "plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900348 base: ":pub_policy.cil",
349 target_policy: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900350 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900351 vendor: true,
352}
353
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900354// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
355// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
356// policy and the platform public policy files in order to use checkpolicy.
357se_policy_conf {
358 name: "vendor_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900359 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim6c6aa012023-08-31 16:47:38 +0900360 srcs: plat_public_policy +
361 system_ext_public_policy +
362 product_public_policy +
363 reqd_mask_policy + [
364 ":se_build_files{.plat_vendor}",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900365 ":se_build_files{.vendor}",
366 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900367 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900368 installable: false,
369}
370
371se_policy_cil {
372 name: "vendor_sepolicy.cil.raw",
373 src: ":vendor_sepolicy.conf",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900374 filter_out: [":reqd_policy_mask.cil"],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900375 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900376 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900377 installable: false,
378}
379
380se_versioned_policy {
381 name: "vendor_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900382 base: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900383 target_policy: ":vendor_sepolicy.cil.raw",
384 version: "vendor",
385 dependent_cils: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900386 ":plat_sepolicy.cil",
387 ":system_ext_sepolicy.cil",
388 ":product_sepolicy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900389 ":plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900390 ":plat_mapping_file",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900391 ],
392 filter_out: [":plat_pub_versioned.cil"],
393 vendor: true,
394}
395
396// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
397// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
398// policy and the platform public policy files in order to use checkpolicy.
399se_policy_conf {
400 name: "odm_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900401 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim6c6aa012023-08-31 16:47:38 +0900402 srcs: plat_public_policy +
403 system_ext_public_policy +
404 product_public_policy +
405 reqd_mask_policy + [
406 ":se_build_files{.plat_vendor}",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900407 ":se_build_files{.vendor}",
408 ":se_build_files{.odm}",
409 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900410 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900411 installable: false,
412}
413
414se_policy_cil {
415 name: "odm_sepolicy.cil.raw",
416 src: ":odm_sepolicy.conf",
417 filter_out: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900418 ":reqd_policy_mask.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900419 ":vendor_sepolicy.cil",
420 ],
421 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900422 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900423 installable: false,
424}
425
426se_versioned_policy {
427 name: "odm_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900428 base: ":pub_policy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900429 target_policy: ":odm_sepolicy.cil.raw",
430 version: "vendor",
431 dependent_cils: [
Inseob Kim6c6aa012023-08-31 16:47:38 +0900432 ":plat_sepolicy.cil",
433 ":system_ext_sepolicy.cil",
434 ":product_sepolicy.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900435 ":plat_pub_versioned.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900436 ":plat_mapping_file",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900437 ":vendor_sepolicy.cil",
438 ],
439 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
440 device_specific: true,
441}
442
Inseob Kim039175b2021-03-25 15:37:34 +0900443//////////////////////////////////
444// Precompiled sepolicy is loaded if and only if:
445// - plat_sepolicy_and_mapping.sha256 equals
446// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
447// AND
448// - system_ext_sepolicy_and_mapping.sha256 equals
449// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
450// AND
451// - product_sepolicy_and_mapping.sha256 equals
452// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
453// See system/core/init/selinux.cpp for details.
454//////////////////////////////////
455genrule {
456 name: "plat_sepolicy_and_mapping.sha256_gen",
457 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
458 out: ["plat_sepolicy_and_mapping.sha256"],
459 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
460}
461
462prebuilt_etc {
463 name: "plat_sepolicy_and_mapping.sha256",
464 filename: "plat_sepolicy_and_mapping.sha256",
465 src: ":plat_sepolicy_and_mapping.sha256_gen",
466 relative_install_path: "selinux",
467}
468
469genrule {
470 name: "system_ext_sepolicy_and_mapping.sha256_gen",
471 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
472 out: ["system_ext_sepolicy_and_mapping.sha256"],
473 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
474}
475
476prebuilt_etc {
477 name: "system_ext_sepolicy_and_mapping.sha256",
478 filename: "system_ext_sepolicy_and_mapping.sha256",
479 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
480 relative_install_path: "selinux",
481 system_ext_specific: true,
482}
483
484genrule {
485 name: "product_sepolicy_and_mapping.sha256_gen",
486 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
487 out: ["product_sepolicy_and_mapping.sha256"],
488 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
489}
490
491prebuilt_etc {
492 name: "product_sepolicy_and_mapping.sha256",
493 filename: "product_sepolicy_and_mapping.sha256",
494 src: ":product_sepolicy_and_mapping.sha256_gen",
495 relative_install_path: "selinux",
496 product_specific: true,
497}
498
Inseob Kim1c056b12021-04-30 00:11:43 +0900499sepolicy_vers {
500 name: "plat_sepolicy_vers.txt",
501 version: "vendor",
502 vendor: true,
503}
504
Inseob Kim731182a2021-05-06 11:44:37 +0000505soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900506 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000507 module_type: "prebuilt_defaults",
508 config_namespace: "ANDROID",
509 bool_variables: ["BOARD_USES_ODMIMAGE"],
510 properties: ["vendor", "device_specific"],
511}
512
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900513precompiled_sepolicy_prebuilts_defaults {
514 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000515 soong_config_variables: {
516 BOARD_USES_ODMIMAGE: {
517 device_specific: true,
518 conditions_default: {
519 vendor: true,
520 },
521 },
522 },
523}
524
525//////////////////////////////////
526// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
527// which precompiled_policy was built.
528//////////////////////////////////
529prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900530 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000531 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
532 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
533 src: ":plat_sepolicy_and_mapping.sha256_gen",
534 relative_install_path: "selinux",
535}
536
537//////////////////////////////////
538// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
539// which precompiled_policy was built.
540//////////////////////////////////
541prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900542 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000543 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
544 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
545 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
546 relative_install_path: "selinux",
547}
548
549//////////////////////////////////
550// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
551// which precompiled_policy was built.
552//////////////////////////////////
553prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900554 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000555 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
556 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
557 src: ":product_sepolicy_and_mapping.sha256_gen",
558 relative_install_path: "selinux",
559}
560
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900561soong_config_module_type {
562 name: "precompiled_se_policy_binary",
563 module_type: "se_policy_binary",
564 config_namespace: "ANDROID",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900565 bool_variables: ["BOARD_USES_ODMIMAGE"],
566 properties: ["vendor", "device_specific"],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900567}
568
Garfield Tand8c51f22023-10-02 14:17:04 -0700569filegroup {
570 name: "precompiled_sepolicy_srcs",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900571 srcs: [
572 ":plat_sepolicy.cil",
Sandro143988d2022-08-05 11:38:56 +0000573 ":plat_pub_versioned.cil",
574 ":system_ext_sepolicy.cil",
575 ":product_sepolicy.cil",
576 ":vendor_sepolicy.cil",
577 ":odm_sepolicy.cil",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900578 ":plat_mapping_file",
579 ":system_ext_mapping_file",
580 ":product_mapping_file",
Sandro143988d2022-08-05 11:38:56 +0000581 ],
Garfield Tand8c51f22023-10-02 14:17:04 -0700582 // Make precompiled_sepolicy_srcs as public so that OEMs have access to them.
583 // Useful when some partitions need to be bind mounted across VM boundaries.
584 visibility: ["//visibility:public"],
585}
586
587precompiled_se_policy_binary {
588 name: "precompiled_sepolicy",
589 srcs: [
590 ":precompiled_sepolicy_srcs",
591 ],
Sandro143988d2022-08-05 11:38:56 +0000592 soong_config_variables: {
593 BOARD_USES_ODMIMAGE: {
594 device_specific: true,
595 conditions_default: {
596 vendor: true,
597 },
598 },
Sandro143988d2022-08-05 11:38:56 +0000599 },
600 required: [
601 "sepolicy_neverallows",
Sandro143988d2022-08-05 11:38:56 +0000602 ],
603 dist: {
604 targets: ["base-sepolicy-files-for-mapping"],
605 },
606}
607
Inseob Kim5bbcd682021-12-28 14:57:03 +0900608// policy for recovery
609se_policy_conf {
610 name: "recovery_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900611 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim6c6aa012023-08-31 16:47:38 +0900612 srcs: plat_public_policy +
613 plat_private_policy +
614 system_ext_public_policy +
615 system_ext_private_policy +
616 product_public_policy +
617 product_private_policy + [
618 ":se_build_files{.plat_vendor}",
Inseob Kim5bbcd682021-12-28 14:57:03 +0900619 ":se_build_files{.vendor}",
620 ":se_build_files{.odm}",
621 ],
622 target_recovery: true,
623 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900624 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900625}
626
627se_policy_cil {
628 name: "recovery_sepolicy.cil",
629 src: ":recovery_sepolicy.conf",
630 secilc_check: false, // will be done in se_policy_binary module
631 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900632 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900633}
634
635se_policy_binary {
636 name: "sepolicy.recovery",
637 srcs: [":recovery_sepolicy.cil"],
638 stem: "sepolicy",
639 recovery: true,
640}
641
Inseob Kima49e7242021-03-22 10:26:13 +0900642//////////////////////////////////
643// SELinux policy embedded into CTS.
644// CTS checks neverallow rules of this policy against the policy of the device under test.
645//////////////////////////////////
646se_policy_conf {
647 name: "general_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900648 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900649 srcs: plat_public_policy +
650 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900651 build_variant: "user",
652 cts: true,
653 exclude_build_test: true,
654}
Inseob Kimd5816612021-09-15 03:01:05 +0000655
656//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000657// Base system policy for treble sepolicy tests.
658// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
659// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
660// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
661// See treble_sepolicy_tests_for_release.mk for more details.
662//////////////////////////////////
663se_policy_conf {
664 name: "base_plat_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900665 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900666 srcs: plat_public_policy +
667 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000668 build_variant: "user",
669 installable: false,
670}
671
672se_policy_cil {
673 name: "base_plat_sepolicy.cil",
674 src: ":base_plat_sepolicy.conf",
675 additional_cil_files: ["private/technical_debt.cil"],
676 installable: false,
677 secilc_check: false, // done by se_policy_binary
678}
679
680se_policy_binary {
681 name: "base_plat_sepolicy",
682 srcs: [":base_plat_sepolicy.cil"],
683 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900684 dist: {
685 targets: ["base-sepolicy-files-for-mapping"],
686 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000687}
688
689se_policy_conf {
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000690 name: "base_product_sepolicy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900691 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900692 srcs: plat_public_policy +
693 plat_private_policy +
694 system_ext_public_policy +
695 system_ext_private_policy +
696 product_public_policy +
697 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000698 build_variant: "user",
699 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900700 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000701}
702
703se_policy_cil {
704 name: "base_product_sepolicy.cil",
705 src: ":base_product_sepolicy.conf",
706 additional_cil_files: ["private/technical_debt.cil"],
707 product_specific: true,
708 installable: false,
709 secilc_check: false, // done by se_policy_binary
710}
711
712se_policy_binary {
713 name: "base_product_sepolicy",
714 srcs: [":base_product_sepolicy.cil"],
715 product_specific: true,
716 installable: false,
717}
718
719se_policy_conf {
720 name: "base_plat_pub_policy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900721 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900722 srcs: plat_public_policy +
723 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000724 build_variant: "user",
725 installable: false,
726}
727
728se_policy_cil {
729 name: "base_plat_pub_policy.cil",
730 src: ":base_plat_pub_policy.conf",
731 filter_out: [":reqd_policy_mask.cil"],
732 secilc_check: false,
733 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900734 dist: {
735 targets: ["base-sepolicy-files-for-mapping"],
736 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000737}
738
739se_policy_conf {
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000740 name: "base_product_pub_policy.conf",
Inseob Kim085f22f2023-11-09 11:13:01 +0900741 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0a707fa2021-12-09 23:35:11 +0900742 srcs: plat_public_policy +
743 system_ext_public_policy +
744 product_public_policy +
745 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000746 build_variant: "user",
747 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900748 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000749}
750
751se_policy_cil {
752 name: "base_product_pub_policy.cil",
753 src: ":base_product_pub_policy.conf",
754 filter_out: [":reqd_policy_mask.cil"],
755 secilc_check: false,
756 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900757 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000758}
759
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800760// bug_map - Bug tracking information for selinux denials loaded by auditd.
Inseob Kim41964032022-04-22 07:50:22 +0900761se_build_files {
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800762 name: "bug_map_files",
763 srcs: ["bug_map"],
764}
765
766se_bug_map {
767 name: "plat_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900768 srcs: [":bug_map_files{.plat_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800769 stem: "bug_map",
770}
771
772se_bug_map {
773 name: "system_ext_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900774 srcs: [":bug_map_files{.system_ext_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800775 stem: "bug_map",
776 system_ext_specific: true,
777}
778
779se_bug_map {
780 name: "vendor_bug_map",
Inseob Kim6c6aa012023-08-31 16:47:38 +0900781 srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800782 // Legacy file name of the vendor partition bug_map.
783 stem: "selinux_denial_metadata",
784 vendor: true,
785}
786
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900787se_neverallow_test {
788 name: "sepolicy_neverallows",
Inseob Kim085f22f2023-11-09 11:13:01 +0900789 defaults: ["se_policy_conf_flags_defaults"],
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900790 srcs: plat_public_policy +
791 plat_private_policy +
792 system_ext_public_policy +
793 system_ext_private_policy +
794 product_public_policy +
Inseob Kim6c6aa012023-08-31 16:47:38 +0900795 product_private_policy + [
796 ":se_build_files{.plat_vendor}",
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900797 ":se_build_files{.vendor}",
798 ":se_build_files{.odm}",
799 ],
800}
801
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000802//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +0000803// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
804// Additional directories can be specified via Makefile variables:
805// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
806//////////////////////////////////
807se_freeze_test {
Inseob Kim36d9d392023-09-04 17:40:03 +0900808 name: "se_freeze_test",
Inseob Kimd5816612021-09-15 03:01:05 +0000809}
Inseob Kim61257ca2022-02-25 11:26:16 +0900810
811//////////////////////////////////
812// sepolicy_test checks various types of violations, which can't be easily done
813// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
814//////////////////////////////////
815genrule {
816 name: "sepolicy_test",
817 srcs: [
818 ":plat_file_contexts",
819 ":vendor_file_contexts",
820 ":system_ext_file_contexts",
821 ":product_file_contexts",
822 ":odm_file_contexts",
823 ":precompiled_sepolicy",
824 ],
825 tools: ["sepolicy_tests"],
826 out: ["sepolicy_test"],
827 cmd: "$(location sepolicy_tests) " +
828 "-f $(location :plat_file_contexts) " +
829 "-f $(location :vendor_file_contexts) " +
830 "-f $(location :system_ext_file_contexts) " +
831 "-f $(location :product_file_contexts) " +
832 "-f $(location :odm_file_contexts) " +
833 "-p $(location :precompiled_sepolicy) && " +
834 "touch $(out)",
835}