blob: 40282155392364ee28447dec388dc00f761e3fc7 [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 Kima49e7242021-03-22 10:26:13 +0900145 installable: false,
146}
147
148se_policy_cil {
149 name: "pub_policy.cil",
150 src: ":pub_policy.conf",
151 filter_out: [":reqd_policy_mask.cil"],
152 secilc_check: false,
153 installable: false,
154}
155
156se_policy_conf {
157 name: "system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900158 srcs: plat_public_policy +
159 system_ext_public_policy +
160 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900161 installable: false,
162}
163
164se_policy_cil {
165 name: "system_ext_pub_policy.cil",
166 src: ":system_ext_pub_policy.conf",
167 filter_out: [":reqd_policy_mask.cil"],
168 secilc_check: false,
169 installable: false,
170}
171
172se_policy_conf {
173 name: "plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900174 srcs: plat_public_policy +
175 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900176 installable: false,
177}
178
179se_policy_cil {
180 name: "plat_pub_policy.cil",
181 src: ":plat_pub_policy.conf",
182 filter_out: [":reqd_policy_mask.cil"],
183 secilc_check: false,
184 installable: false,
185}
186
187// plat_policy.conf - A combination of the private and public platform policy
188// which will ship with the device.
189//
190// The platform will always reflect the most recent platform version and is not
191// currently being attributized.
192se_policy_conf {
193 name: "plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900194 srcs: plat_public_policy +
195 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900196 installable: false,
197}
198
199se_policy_cil {
200 name: "plat_sepolicy.cil",
201 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900202 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900203}
204
Lokesh Gidra1269a172022-08-01 17:20:38 +0000205
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100206se_policy_conf {
207 name: "apex_sepolicy-33.conf",
Lokesh Gidra1269a172022-08-01 17:20:38 +0000208 srcs: plat_public_policy + plat_private_policy + ["com.android.sepolicy/33/*.te"],
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100209 installable: false,
210}
211
212se_policy_cil {
213 name: "apex_sepolicy-33.cil",
214 src: ":apex_sepolicy-33.conf",
Lokesh Gidra1269a172022-08-01 17:20:38 +0000215 filter_out: [":plat_sepolicy.cil"],
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100216 installable: false,
217 stem: "apex_sepolicy.cil",
218}
219
Sandro143988d2022-08-05 11:38:56 +0000220se_policy_cil {
221 name: "decompiled_sepolicy-without_apex.cil",
222 src: ":precompiled_sepolicy-without_apex",
223 decompile_binary: true,
224}
225
226se_policy_cil {
Sandro3f5c18c2022-09-01 16:07:28 +0000227 name: "apex_sepolicy-33.decompiled.cil",
Sandro143988d2022-08-05 11:38:56 +0000228 src: ":precompiled_sepolicy",
229 decompile_binary: true,
230 filter_out: [":decompiled_sepolicy-without_apex.cil"],
231 additional_cil_files: ["com.android.sepolicy/33/definitions/definitions.cil"],
232 secilc_check: false,
Sandro3f5c18c2022-09-01 16:07:28 +0000233 stem: "apex_sepolicy.decompiled.cil",
Sandro143988d2022-08-05 11:38:56 +0000234}
235
Inseob Kim6cc75f42021-04-29 13:53:20 +0000236// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
237se_policy_conf {
238 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900239 srcs: plat_public_policy +
240 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000241 build_variant: "userdebug",
242 installable: false,
243}
244
245se_policy_cil {
246 name: "userdebug_plat_sepolicy.cil",
247 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900248 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000249 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800250 dist: {
251 targets: ["droidcore"],
252 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000253}
254
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000255// A copy of the userdebug_plat_policy in GSI.
256soong_config_module_type {
257 name: "gsi_se_policy_cil",
258 module_type: "se_policy_cil",
259 config_namespace: "ANDROID",
260 bool_variables: [
261 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
262 ],
263 properties: [
264 "enabled",
265 "installable",
266 ],
267}
268
269gsi_se_policy_cil {
270 name: "system_ext_userdebug_plat_sepolicy.cil",
271 stem: "userdebug_plat_sepolicy.cil",
272 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900273 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000274 system_ext_specific: true,
275 enabled: false,
276 installable: false,
277 soong_config_variables: {
278 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
279 enabled: true,
280 installable: true,
281 },
282 },
283}
284
Inseob Kima49e7242021-03-22 10:26:13 +0900285// system_ext_policy.conf - A combination of the private and public system_ext
286// policy which will ship with the device. System_ext policy is not attributized
287se_policy_conf {
288 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900289 srcs: plat_public_policy +
290 plat_private_policy +
291 system_ext_public_policy +
292 system_ext_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900293 installable: false,
294}
295
296se_policy_cil {
297 name: "system_ext_sepolicy.cil",
298 src: ":system_ext_sepolicy.conf",
299 system_ext_specific: true,
300 filter_out: [":plat_sepolicy.cil"],
301 remove_line_marker: true,
302}
303
304// product_policy.conf - A combination of the private and public product policy
305// which will ship with the device. Product policy is not attributized
306se_policy_conf {
307 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900308 srcs: plat_public_policy +
309 plat_private_policy +
310 system_ext_public_policy +
311 system_ext_private_policy +
312 product_public_policy +
313 product_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900314 installable: false,
315}
316
317se_policy_cil {
318 name: "product_sepolicy.cil",
319 src: ":product_sepolicy.conf",
320 product_specific: true,
321 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
322 remove_line_marker: true,
323}
324
Inseob Kim039175b2021-03-25 15:37:34 +0900325// policy mapping files
326// auto-generate the mapping file for current platform policy, since it needs to
327// track platform policy development
328se_versioned_policy {
329 name: "plat_mapping_file",
330 base: ":plat_pub_policy.cil",
331 mapping: true,
332 version: "current",
333 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
334}
335
336se_versioned_policy {
337 name: "system_ext_mapping_file",
338 base: ":system_ext_pub_policy.cil",
339 mapping: true,
340 version: "current",
341 filter_out: [":plat_mapping_file"],
342 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
343 system_ext_specific: true,
344}
345
346se_versioned_policy {
347 name: "product_mapping_file",
348 base: ":pub_policy.cil",
349 mapping: true,
350 version: "current",
351 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
352 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
353 product_specific: true,
354}
355
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900356// vendor/odm sepolicy
357//
358// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
359// policy files of platform (system, system_ext, product) can't be mixed with
360// policy files of vendor (vendor, odm). If it's the case, platform policies and
361// vendor policies are separately built. More specifically,
362//
363// - Platform policy files needed to build vendor policies, such as plat_policy,
364// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
365// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
366//
367// - sepolicy_neverallows only checks platform policies, and a new module
368// sepolicy_neverallows_vendor checks vendor policies.
369//
370// - neverallow checks are turned off while compiling precompiled_sepolicy
371// module and sepolicy module.
372//
373// - Vendor policies are not checked on the compat test (compat.mk).
374//
375// In such scenario, we can grab platform policy files from the prebuilts/api
376// directory. But we need more than that: prebuilts of system_ext, product,
377// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
378// variables are introduced to specify such prebuilts.
379//
380// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
381// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
382// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
383// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
384// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
385// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
386//
387// Vendors are responsible for copying policy files from the old version of the
388// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
389// can be used to build vendor policies.
390//
391// To support both mixed build and normal build, platform policy files are
392// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
393// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
394// Otherwise, they will be equal to the Makefile variables above.
395
396plat_public_policies_for_vendor = [
397 ":se_build_files{.plat_public_for_vendor}",
398 ":se_build_files{.system_ext_public_for_vendor}",
399 ":se_build_files{.product_public_for_vendor}",
400 ":se_build_files{.reqd_mask_for_vendor}",
401]
402
403plat_policies_for_vendor = [
404 ":se_build_files{.plat_public_for_vendor}",
405 ":se_build_files{.plat_private_for_vendor}",
406 ":se_build_files{.system_ext_public_for_vendor}",
407 ":se_build_files{.system_ext_private_for_vendor}",
408 ":se_build_files{.product_public_for_vendor}",
409 ":se_build_files{.product_private_for_vendor}",
410]
411
412se_policy_conf {
413 name: "plat_policy_for_vendor.conf",
414 srcs: plat_policies_for_vendor,
415 installable: false,
416}
417
418se_policy_cil {
419 name: "plat_policy_for_vendor.cil",
420 src: ":plat_policy_for_vendor.conf",
421 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
422 installable: false,
423}
424
425se_policy_conf {
426 name: "reqd_policy_mask_for_vendor.conf",
427 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
428 installable: false,
429}
430
431se_policy_cil {
432 name: "reqd_policy_mask_for_vendor.cil",
433 src: ":reqd_policy_mask_for_vendor.conf",
434 secilc_check: false,
435 installable: false,
436}
437
438se_policy_conf {
439 name: "pub_policy_for_vendor.conf",
440 srcs: plat_public_policies_for_vendor,
441 installable: false,
442}
443
444se_policy_cil {
445 name: "pub_policy_for_vendor.cil",
446 src: ":pub_policy_for_vendor.conf",
447 filter_out: [":reqd_policy_mask_for_vendor.cil"],
448 secilc_check: false,
449 installable: false,
450}
451
452se_versioned_policy {
453 name: "plat_mapping_file_for_vendor",
454 base: ":pub_policy_for_vendor.cil",
455 mapping: true,
456 version: "vendor",
457 installable: false,
458}
459
Inseob Kim039175b2021-03-25 15:37:34 +0900460// plat_pub_versioned.cil - the exported platform policy associated with the version
461// that non-platform policy targets.
462se_versioned_policy {
463 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900464 base: ":pub_policy_for_vendor.cil",
465 target_policy: ":pub_policy_for_vendor.cil",
466 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900467 vendor: true,
468}
469
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900470// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
471// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
472// policy and the platform public policy files in order to use checkpolicy.
473se_policy_conf {
474 name: "vendor_sepolicy.conf",
475 srcs: plat_public_policies_for_vendor + [
476 ":se_build_files{.plat_vendor_for_vendor}",
477 ":se_build_files{.vendor}",
478 ],
479 installable: false,
480}
481
482se_policy_cil {
483 name: "vendor_sepolicy.cil.raw",
484 src: ":vendor_sepolicy.conf",
485 filter_out: [":reqd_policy_mask_for_vendor.cil"],
486 secilc_check: false, // will be done in se_versioned_policy module
487 installable: false,
488}
489
490se_versioned_policy {
491 name: "vendor_sepolicy.cil",
492 base: ":pub_policy_for_vendor.cil",
493 target_policy: ":vendor_sepolicy.cil.raw",
494 version: "vendor",
495 dependent_cils: [
496 ":plat_policy_for_vendor.cil",
497 ":plat_pub_versioned.cil",
498 ":plat_mapping_file_for_vendor",
499 ],
500 filter_out: [":plat_pub_versioned.cil"],
501 vendor: true,
502}
503
504// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
505// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
506// policy and the platform public policy files in order to use checkpolicy.
507se_policy_conf {
508 name: "odm_sepolicy.conf",
509 srcs: plat_public_policies_for_vendor + [
510 ":se_build_files{.plat_vendor_for_vendor}",
511 ":se_build_files{.vendor}",
512 ":se_build_files{.odm}",
513 ],
514 installable: false,
515}
516
517se_policy_cil {
518 name: "odm_sepolicy.cil.raw",
519 src: ":odm_sepolicy.conf",
520 filter_out: [
521 ":reqd_policy_mask_for_vendor.cil",
522 ":vendor_sepolicy.cil",
523 ],
524 secilc_check: false, // will be done in se_versioned_policy module
525 installable: false,
526}
527
528se_versioned_policy {
529 name: "odm_sepolicy.cil",
530 base: ":pub_policy_for_vendor.cil",
531 target_policy: ":odm_sepolicy.cil.raw",
532 version: "vendor",
533 dependent_cils: [
534 ":plat_policy_for_vendor.cil",
535 ":plat_pub_versioned.cil",
536 ":plat_mapping_file_for_vendor",
537 ":vendor_sepolicy.cil",
538 ],
539 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
540 device_specific: true,
541}
542
Inseob Kim039175b2021-03-25 15:37:34 +0900543//////////////////////////////////
544// Precompiled sepolicy is loaded if and only if:
545// - plat_sepolicy_and_mapping.sha256 equals
546// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
547// AND
548// - system_ext_sepolicy_and_mapping.sha256 equals
549// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
550// AND
551// - product_sepolicy_and_mapping.sha256 equals
552// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100553// AND
554// - apex_sepolicy.sha256 equals
555// precompiled_sepolicy.apex_sepolicy.sha256
Inseob Kim039175b2021-03-25 15:37:34 +0900556// See system/core/init/selinux.cpp for details.
557//////////////////////////////////
558genrule {
559 name: "plat_sepolicy_and_mapping.sha256_gen",
560 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
561 out: ["plat_sepolicy_and_mapping.sha256"],
562 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
563}
564
565prebuilt_etc {
566 name: "plat_sepolicy_and_mapping.sha256",
567 filename: "plat_sepolicy_and_mapping.sha256",
568 src: ":plat_sepolicy_and_mapping.sha256_gen",
569 relative_install_path: "selinux",
570}
571
572genrule {
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100573 name: "apex_sepolicy.sha256_gen",
574 srcs: [":apex_sepolicy-33.cil"],
575 out: ["apex_sepolicy.sha256"],
576 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
577}
578
579prebuilt_etc {
580 name: "apex_sepolicy.sha256",
581 filename: "apex_sepolicy.sha256",
582 src: ":apex_sepolicy.sha256_gen",
583 installable: false,
584}
585
586genrule {
Inseob Kim039175b2021-03-25 15:37:34 +0900587 name: "system_ext_sepolicy_and_mapping.sha256_gen",
588 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
589 out: ["system_ext_sepolicy_and_mapping.sha256"],
590 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
591}
592
593prebuilt_etc {
594 name: "system_ext_sepolicy_and_mapping.sha256",
595 filename: "system_ext_sepolicy_and_mapping.sha256",
596 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
597 relative_install_path: "selinux",
598 system_ext_specific: true,
599}
600
601genrule {
602 name: "product_sepolicy_and_mapping.sha256_gen",
603 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
604 out: ["product_sepolicy_and_mapping.sha256"],
605 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
606}
607
608prebuilt_etc {
609 name: "product_sepolicy_and_mapping.sha256",
610 filename: "product_sepolicy_and_mapping.sha256",
611 src: ":product_sepolicy_and_mapping.sha256_gen",
612 relative_install_path: "selinux",
613 product_specific: true,
614}
615
Inseob Kim1c056b12021-04-30 00:11:43 +0900616sepolicy_vers {
617 name: "plat_sepolicy_vers.txt",
618 version: "vendor",
619 vendor: true,
620}
621
Inseob Kim731182a2021-05-06 11:44:37 +0000622soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900623 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000624 module_type: "prebuilt_defaults",
625 config_namespace: "ANDROID",
626 bool_variables: ["BOARD_USES_ODMIMAGE"],
627 properties: ["vendor", "device_specific"],
628}
629
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900630precompiled_sepolicy_prebuilts_defaults {
631 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000632 soong_config_variables: {
633 BOARD_USES_ODMIMAGE: {
634 device_specific: true,
635 conditions_default: {
636 vendor: true,
637 },
638 },
639 },
640}
641
642//////////////////////////////////
643// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
644// which precompiled_policy was built.
645//////////////////////////////////
646prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900647 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000648 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
649 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
650 src: ":plat_sepolicy_and_mapping.sha256_gen",
651 relative_install_path: "selinux",
652}
653
654//////////////////////////////////
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100655// SHA-256 digest of the apex_sepolicy.cil against which precompiled_policy
656// was built.
657//////////////////////////////////
658prebuilt_etc {
659 defaults: ["precompiled_sepolicy_prebuilts"],
660 name: "precompiled_sepolicy.apex_sepolicy.sha256",
661 filename: "precompiled_sepolicy.apex_sepolicy.sha256",
662 src: ":apex_sepolicy.sha256_gen",
663 relative_install_path: "selinux",
664}
665
666//////////////////////////////////
Inseob Kim731182a2021-05-06 11:44:37 +0000667// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
668// which precompiled_policy was built.
669//////////////////////////////////
670prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900671 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000672 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
673 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
674 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
675 relative_install_path: "selinux",
676}
677
678//////////////////////////////////
679// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
680// which precompiled_policy was built.
681//////////////////////////////////
682prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900683 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000684 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
685 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
686 src: ":product_sepolicy_and_mapping.sha256_gen",
687 relative_install_path: "selinux",
688}
689
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900690soong_config_module_type {
691 name: "precompiled_se_policy_binary",
692 module_type: "se_policy_binary",
693 config_namespace: "ANDROID",
694 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
695 value_variables: ["MIXED_SEPOLICY_VERSION"],
696 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
697}
698
699precompiled_se_policy_binary {
700 name: "precompiled_sepolicy",
701 srcs: [
702 ":plat_sepolicy.cil",
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100703 ":apex_sepolicy-33.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900704 ":plat_pub_versioned.cil",
705 ":system_ext_sepolicy.cil",
706 ":product_sepolicy.cil",
707 ":vendor_sepolicy.cil",
708 ":odm_sepolicy.cil",
709 ],
710 soong_config_variables: {
711 BOARD_USES_ODMIMAGE: {
712 device_specific: true,
713 conditions_default: {
714 vendor: true,
715 },
716 },
717 IS_TARGET_MIXED_SEPOLICY: {
718 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900719 },
720 MIXED_SEPOLICY_VERSION: {
721 srcs: [
722 ":plat_%s.cil",
723 ":system_ext_%s.cil",
724 ":product_%s.cil",
725 ],
726 conditions_default: {
727 srcs: [
728 ":plat_mapping_file",
729 ":system_ext_mapping_file",
730 ":product_mapping_file",
731 ],
732 },
733 },
734 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900735 required: [
736 "sepolicy_neverallows",
737 "sepolicy_neverallows_vendor",
738 ],
Inseob Kimeec39192022-01-21 11:47:54 +0900739 dist: {
740 targets: ["base-sepolicy-files-for-mapping"],
741 },
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900742}
Inseob Kim731182a2021-05-06 11:44:37 +0000743
Sandro143988d2022-08-05 11:38:56 +0000744precompiled_se_policy_binary {
745 name: "precompiled_sepolicy-without_apex",
746 srcs: [
747 ":plat_sepolicy.cil",
748 ":plat_pub_versioned.cil",
749 ":system_ext_sepolicy.cil",
750 ":product_sepolicy.cil",
751 ":vendor_sepolicy.cil",
752 ":odm_sepolicy.cil",
753 ],
754 soong_config_variables: {
755 BOARD_USES_ODMIMAGE: {
756 device_specific: true,
757 conditions_default: {
758 vendor: true,
759 },
760 },
761 IS_TARGET_MIXED_SEPOLICY: {
762 ignore_neverallow: true,
763 },
764 MIXED_SEPOLICY_VERSION: {
765 srcs: [
766 ":plat_%s.cil",
767 ":system_ext_%s.cil",
768 ":product_%s.cil",
769 ],
770 conditions_default: {
771 srcs: [
772 ":plat_mapping_file",
773 ":system_ext_mapping_file",
774 ":product_mapping_file",
775 ],
776 },
777 },
778 },
779 required: [
780 "sepolicy_neverallows",
781 "sepolicy_neverallows_vendor",
782 ],
783 dist: {
784 targets: ["base-sepolicy-files-for-mapping"],
785 },
786}
787
Inseob Kim5bbcd682021-12-28 14:57:03 +0900788// policy for recovery
789se_policy_conf {
790 name: "recovery_sepolicy.conf",
791 srcs: plat_policies_for_vendor + [
792 ":se_build_files{.plat_vendor_for_vendor}",
793 ":se_build_files{.vendor}",
794 ":se_build_files{.odm}",
795 ],
796 target_recovery: true,
797 installable: false,
798}
799
800se_policy_cil {
801 name: "recovery_sepolicy.cil",
802 src: ":recovery_sepolicy.conf",
803 secilc_check: false, // will be done in se_policy_binary module
804 installable: false,
805}
806
807se_policy_binary {
808 name: "sepolicy.recovery",
809 srcs: [":recovery_sepolicy.cil"],
810 stem: "sepolicy",
811 recovery: true,
812}
813
Inseob Kima49e7242021-03-22 10:26:13 +0900814//////////////////////////////////
815// SELinux policy embedded into CTS.
816// CTS checks neverallow rules of this policy against the policy of the device under test.
817//////////////////////////////////
818se_policy_conf {
819 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900820 srcs: plat_public_policy +
821 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900822 build_variant: "user",
823 cts: true,
824 exclude_build_test: true,
825}
Inseob Kimd5816612021-09-15 03:01:05 +0000826
827//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000828// Base system policy for treble sepolicy tests.
829// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
830// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
831// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
832// See treble_sepolicy_tests_for_release.mk for more details.
833//////////////////////////////////
834se_policy_conf {
835 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900836 srcs: plat_public_policy +
837 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000838 build_variant: "user",
839 installable: false,
840}
841
842se_policy_cil {
843 name: "base_plat_sepolicy.cil",
844 src: ":base_plat_sepolicy.conf",
845 additional_cil_files: ["private/technical_debt.cil"],
846 installable: false,
847 secilc_check: false, // done by se_policy_binary
848}
849
850se_policy_binary {
851 name: "base_plat_sepolicy",
852 srcs: [":base_plat_sepolicy.cil"],
853 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900854 dist: {
855 targets: ["base-sepolicy-files-for-mapping"],
856 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000857}
858
859se_policy_conf {
860 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900861 srcs: plat_public_policy +
862 plat_private_policy +
863 system_ext_public_policy +
864 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000865 build_variant: "user",
866 installable: false,
867}
868
869se_policy_cil {
870 name: "base_system_ext_sepolicy.cil",
871 src: ":base_system_ext_sepolicy.conf",
872 additional_cil_files: ["private/technical_debt.cil"],
873 system_ext_specific: true,
874 installable: false,
875 secilc_check: false, // done by se_policy_binary
876}
877
878se_policy_binary {
879 name: "base_system_ext_sepolicy",
880 srcs: [":base_system_ext_sepolicy.cil"],
881 system_ext_specific: true,
882 installable: false,
883}
884
885se_policy_conf {
886 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900887 srcs: plat_public_policy +
888 plat_private_policy +
889 system_ext_public_policy +
890 system_ext_private_policy +
891 product_public_policy +
892 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000893 build_variant: "user",
894 installable: false,
895}
896
897se_policy_cil {
898 name: "base_product_sepolicy.cil",
899 src: ":base_product_sepolicy.conf",
900 additional_cil_files: ["private/technical_debt.cil"],
901 product_specific: true,
902 installable: false,
903 secilc_check: false, // done by se_policy_binary
904}
905
906se_policy_binary {
907 name: "base_product_sepolicy",
908 srcs: [":base_product_sepolicy.cil"],
909 product_specific: true,
910 installable: false,
911}
912
913se_policy_conf {
914 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900915 srcs: plat_public_policy +
916 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000917 build_variant: "user",
918 installable: false,
919}
920
921se_policy_cil {
922 name: "base_plat_pub_policy.cil",
923 src: ":base_plat_pub_policy.conf",
924 filter_out: [":reqd_policy_mask.cil"],
925 secilc_check: false,
926 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900927 dist: {
928 targets: ["base-sepolicy-files-for-mapping"],
929 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000930}
931
932se_policy_conf {
933 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900934 srcs: plat_public_policy +
935 system_ext_public_policy +
936 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000937 build_variant: "user",
938 installable: false,
939}
940
941se_policy_cil {
942 name: "base_system_ext_pub_policy.cil",
943 src: ":base_system_ext_pub_policy.conf",
944 filter_out: [":reqd_policy_mask.cil"],
945 secilc_check: false,
946 installable: false,
947}
948
949se_policy_conf {
950 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900951 srcs: plat_public_policy +
952 system_ext_public_policy +
953 product_public_policy +
954 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000955 build_variant: "user",
956 installable: false,
957}
958
959se_policy_cil {
960 name: "base_product_pub_policy.cil",
961 src: ":base_product_pub_policy.conf",
962 filter_out: [":reqd_policy_mask.cil"],
963 secilc_check: false,
964 installable: false,
965}
966
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800967// bug_map - Bug tracking information for selinux denials loaded by auditd.
Inseob Kim41964032022-04-22 07:50:22 +0900968se_build_files {
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800969 name: "bug_map_files",
970 srcs: ["bug_map"],
971}
972
973se_bug_map {
974 name: "plat_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900975 srcs: [":bug_map_files{.plat_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800976 stem: "bug_map",
977}
978
979se_bug_map {
980 name: "system_ext_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900981 srcs: [":bug_map_files{.system_ext_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800982 stem: "bug_map",
983 system_ext_specific: true,
984}
985
986se_bug_map {
987 name: "vendor_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900988 srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor_for_vendor}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800989 // Legacy file name of the vendor partition bug_map.
990 stem: "selinux_denial_metadata",
991 vendor: true,
992}
993
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900994se_neverallow_test {
995 name: "sepolicy_neverallows",
996 srcs: plat_public_policy +
997 plat_private_policy +
998 system_ext_public_policy +
999 system_ext_private_policy +
1000 product_public_policy +
1001 product_private_policy,
1002}
1003
1004se_neverallow_test {
1005 name: "sepolicy_neverallows_vendor",
1006 srcs: plat_policies_for_vendor + [
1007 ":se_build_files{.plat_vendor_for_vendor}",
1008 ":se_build_files{.vendor}",
1009 ":se_build_files{.odm}",
1010 ],
1011}
1012
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001013//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001014// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1015// Additional directories can be specified via Makefile variables:
1016// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1017//////////////////////////////////
1018se_freeze_test {
1019 name: "sepolicy_freeze_test",
1020}
Inseob Kim61257ca2022-02-25 11:26:16 +09001021
1022//////////////////////////////////
1023// sepolicy_test checks various types of violations, which can't be easily done
1024// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
1025//////////////////////////////////
1026genrule {
1027 name: "sepolicy_test",
1028 srcs: [
1029 ":plat_file_contexts",
1030 ":vendor_file_contexts",
1031 ":system_ext_file_contexts",
1032 ":product_file_contexts",
1033 ":odm_file_contexts",
1034 ":precompiled_sepolicy",
1035 ],
1036 tools: ["sepolicy_tests"],
1037 out: ["sepolicy_test"],
1038 cmd: "$(location sepolicy_tests) " +
1039 "-f $(location :plat_file_contexts) " +
1040 "-f $(location :vendor_file_contexts) " +
1041 "-f $(location :system_ext_file_contexts) " +
1042 "-f $(location :product_file_contexts) " +
1043 "-f $(location :odm_file_contexts) " +
1044 "-p $(location :precompiled_sepolicy) && " +
1045 "touch $(out)",
1046}