blob: cac07480d8d86cfbc35a04247364ef20781e21d0 [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
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100210se_policy_conf {
211 name: "apex_sepolicy-33.conf",
Lokesh Gidra1269a172022-08-01 17:20:38 +0000212 srcs: plat_public_policy + plat_private_policy + ["com.android.sepolicy/33/*.te"],
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100213 installable: false,
214}
215
216se_policy_cil {
217 name: "apex_sepolicy-33.cil",
218 src: ":apex_sepolicy-33.conf",
Lokesh Gidra1269a172022-08-01 17:20:38 +0000219 filter_out: [":plat_sepolicy.cil"],
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100220 installable: false,
221 stem: "apex_sepolicy.cil",
222}
223
Sandro143988d2022-08-05 11:38:56 +0000224se_policy_cil {
225 name: "decompiled_sepolicy-without_apex.cil",
226 src: ":precompiled_sepolicy-without_apex",
227 decompile_binary: true,
228}
229
230se_policy_cil {
Sandro3f5c18c2022-09-01 16:07:28 +0000231 name: "apex_sepolicy-33.decompiled.cil",
Sandro143988d2022-08-05 11:38:56 +0000232 src: ":precompiled_sepolicy",
233 decompile_binary: true,
234 filter_out: [":decompiled_sepolicy-without_apex.cil"],
235 additional_cil_files: ["com.android.sepolicy/33/definitions/definitions.cil"],
236 secilc_check: false,
Sandro3f5c18c2022-09-01 16:07:28 +0000237 stem: "apex_sepolicy.decompiled.cil",
Sandro143988d2022-08-05 11:38:56 +0000238}
239
Inseob Kim6cc75f42021-04-29 13:53:20 +0000240// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
241se_policy_conf {
242 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900243 srcs: plat_public_policy +
244 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000245 build_variant: "userdebug",
246 installable: false,
247}
248
249se_policy_cil {
250 name: "userdebug_plat_sepolicy.cil",
251 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900252 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000253 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800254 dist: {
255 targets: ["droidcore"],
256 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000257}
258
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000259// A copy of the userdebug_plat_policy in GSI.
260soong_config_module_type {
261 name: "gsi_se_policy_cil",
262 module_type: "se_policy_cil",
263 config_namespace: "ANDROID",
264 bool_variables: [
265 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
266 ],
267 properties: [
268 "enabled",
269 "installable",
270 ],
271}
272
273gsi_se_policy_cil {
274 name: "system_ext_userdebug_plat_sepolicy.cil",
275 stem: "userdebug_plat_sepolicy.cil",
276 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900277 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000278 system_ext_specific: true,
279 enabled: false,
280 installable: false,
281 soong_config_variables: {
282 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
283 enabled: true,
284 installable: true,
285 },
286 },
287}
288
Inseob Kima49e7242021-03-22 10:26:13 +0900289// system_ext_policy.conf - A combination of the private and public system_ext
290// policy which will ship with the device. System_ext policy is not attributized
291se_policy_conf {
292 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900293 srcs: plat_public_policy +
294 plat_private_policy +
295 system_ext_public_policy +
296 system_ext_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900297 system_ext_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900298 installable: false,
299}
300
301se_policy_cil {
302 name: "system_ext_sepolicy.cil",
303 src: ":system_ext_sepolicy.conf",
304 system_ext_specific: true,
305 filter_out: [":plat_sepolicy.cil"],
306 remove_line_marker: true,
307}
308
309// product_policy.conf - A combination of the private and public product policy
310// which will ship with the device. Product policy is not attributized
311se_policy_conf {
312 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900313 srcs: plat_public_policy +
314 plat_private_policy +
315 system_ext_public_policy +
316 system_ext_private_policy +
317 product_public_policy +
318 product_private_policy,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900319 product_specific: true,
Inseob Kima49e7242021-03-22 10:26:13 +0900320 installable: false,
321}
322
323se_policy_cil {
324 name: "product_sepolicy.cil",
325 src: ":product_sepolicy.conf",
326 product_specific: true,
327 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
328 remove_line_marker: true,
329}
330
Inseob Kim039175b2021-03-25 15:37:34 +0900331// policy mapping files
332// auto-generate the mapping file for current platform policy, since it needs to
333// track platform policy development
334se_versioned_policy {
335 name: "plat_mapping_file",
336 base: ":plat_pub_policy.cil",
337 mapping: true,
338 version: "current",
339 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
340}
341
342se_versioned_policy {
343 name: "system_ext_mapping_file",
344 base: ":system_ext_pub_policy.cil",
345 mapping: true,
346 version: "current",
347 filter_out: [":plat_mapping_file"],
348 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
349 system_ext_specific: true,
350}
351
352se_versioned_policy {
353 name: "product_mapping_file",
354 base: ":pub_policy.cil",
355 mapping: true,
356 version: "current",
357 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
358 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
359 product_specific: true,
360}
361
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900362// vendor/odm sepolicy
363//
364// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
365// policy files of platform (system, system_ext, product) can't be mixed with
366// policy files of vendor (vendor, odm). If it's the case, platform policies and
367// vendor policies are separately built. More specifically,
368//
369// - Platform policy files needed to build vendor policies, such as plat_policy,
370// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
371// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
372//
373// - sepolicy_neverallows only checks platform policies, and a new module
374// sepolicy_neverallows_vendor checks vendor policies.
375//
376// - neverallow checks are turned off while compiling precompiled_sepolicy
377// module and sepolicy module.
378//
379// - Vendor policies are not checked on the compat test (compat.mk).
380//
381// In such scenario, we can grab platform policy files from the prebuilts/api
382// directory. But we need more than that: prebuilts of system_ext, product,
383// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
384// variables are introduced to specify such prebuilts.
385//
386// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
387// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
388// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
389// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
390// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
391// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
392//
393// Vendors are responsible for copying policy files from the old version of the
394// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
395// can be used to build vendor policies.
396//
397// To support both mixed build and normal build, platform policy files are
398// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
399// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
400// Otherwise, they will be equal to the Makefile variables above.
401
402plat_public_policies_for_vendor = [
403 ":se_build_files{.plat_public_for_vendor}",
404 ":se_build_files{.system_ext_public_for_vendor}",
405 ":se_build_files{.product_public_for_vendor}",
406 ":se_build_files{.reqd_mask_for_vendor}",
407]
408
409plat_policies_for_vendor = [
410 ":se_build_files{.plat_public_for_vendor}",
411 ":se_build_files{.plat_private_for_vendor}",
412 ":se_build_files{.system_ext_public_for_vendor}",
413 ":se_build_files{.system_ext_private_for_vendor}",
414 ":se_build_files{.product_public_for_vendor}",
415 ":se_build_files{.product_private_for_vendor}",
416]
417
418se_policy_conf {
419 name: "plat_policy_for_vendor.conf",
420 srcs: plat_policies_for_vendor,
421 installable: false,
422}
423
424se_policy_cil {
425 name: "plat_policy_for_vendor.cil",
426 src: ":plat_policy_for_vendor.conf",
427 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
428 installable: false,
429}
430
431se_policy_conf {
432 name: "reqd_policy_mask_for_vendor.conf",
433 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
434 installable: false,
435}
436
437se_policy_cil {
438 name: "reqd_policy_mask_for_vendor.cil",
439 src: ":reqd_policy_mask_for_vendor.conf",
440 secilc_check: false,
441 installable: false,
442}
443
444se_policy_conf {
445 name: "pub_policy_for_vendor.conf",
446 srcs: plat_public_policies_for_vendor,
447 installable: false,
448}
449
450se_policy_cil {
451 name: "pub_policy_for_vendor.cil",
452 src: ":pub_policy_for_vendor.conf",
453 filter_out: [":reqd_policy_mask_for_vendor.cil"],
454 secilc_check: false,
455 installable: false,
456}
457
458se_versioned_policy {
459 name: "plat_mapping_file_for_vendor",
460 base: ":pub_policy_for_vendor.cil",
461 mapping: true,
462 version: "vendor",
463 installable: false,
464}
465
Inseob Kim039175b2021-03-25 15:37:34 +0900466// plat_pub_versioned.cil - the exported platform policy associated with the version
467// that non-platform policy targets.
468se_versioned_policy {
469 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900470 base: ":pub_policy_for_vendor.cil",
471 target_policy: ":pub_policy_for_vendor.cil",
472 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900473 vendor: true,
474}
475
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900476// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
477// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
478// policy and the platform public policy files in order to use checkpolicy.
479se_policy_conf {
480 name: "vendor_sepolicy.conf",
481 srcs: plat_public_policies_for_vendor + [
482 ":se_build_files{.plat_vendor_for_vendor}",
483 ":se_build_files{.vendor}",
484 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900485 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900486 installable: false,
487}
488
489se_policy_cil {
490 name: "vendor_sepolicy.cil.raw",
491 src: ":vendor_sepolicy.conf",
492 filter_out: [":reqd_policy_mask_for_vendor.cil"],
493 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900494 vendor: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900495 installable: false,
496}
497
498se_versioned_policy {
499 name: "vendor_sepolicy.cil",
500 base: ":pub_policy_for_vendor.cil",
501 target_policy: ":vendor_sepolicy.cil.raw",
502 version: "vendor",
503 dependent_cils: [
504 ":plat_policy_for_vendor.cil",
505 ":plat_pub_versioned.cil",
506 ":plat_mapping_file_for_vendor",
507 ],
508 filter_out: [":plat_pub_versioned.cil"],
509 vendor: true,
510}
511
512// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
513// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
514// policy and the platform public policy files in order to use checkpolicy.
515se_policy_conf {
516 name: "odm_sepolicy.conf",
517 srcs: plat_public_policies_for_vendor + [
518 ":se_build_files{.plat_vendor_for_vendor}",
519 ":se_build_files{.vendor}",
520 ":se_build_files{.odm}",
521 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900522 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900523 installable: false,
524}
525
526se_policy_cil {
527 name: "odm_sepolicy.cil.raw",
528 src: ":odm_sepolicy.conf",
529 filter_out: [
530 ":reqd_policy_mask_for_vendor.cil",
531 ":vendor_sepolicy.cil",
532 ],
533 secilc_check: false, // will be done in se_versioned_policy module
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900534 device_specific: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900535 installable: false,
536}
537
538se_versioned_policy {
539 name: "odm_sepolicy.cil",
540 base: ":pub_policy_for_vendor.cil",
541 target_policy: ":odm_sepolicy.cil.raw",
542 version: "vendor",
543 dependent_cils: [
544 ":plat_policy_for_vendor.cil",
545 ":plat_pub_versioned.cil",
546 ":plat_mapping_file_for_vendor",
547 ":vendor_sepolicy.cil",
548 ],
549 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
550 device_specific: true,
551}
552
Inseob Kim039175b2021-03-25 15:37:34 +0900553//////////////////////////////////
554// Precompiled sepolicy is loaded if and only if:
555// - plat_sepolicy_and_mapping.sha256 equals
556// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
557// AND
558// - system_ext_sepolicy_and_mapping.sha256 equals
559// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
560// AND
561// - product_sepolicy_and_mapping.sha256 equals
562// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100563// AND
564// - apex_sepolicy.sha256 equals
565// precompiled_sepolicy.apex_sepolicy.sha256
Inseob Kim039175b2021-03-25 15:37:34 +0900566// See system/core/init/selinux.cpp for details.
567//////////////////////////////////
568genrule {
569 name: "plat_sepolicy_and_mapping.sha256_gen",
570 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
571 out: ["plat_sepolicy_and_mapping.sha256"],
572 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
573}
574
575prebuilt_etc {
576 name: "plat_sepolicy_and_mapping.sha256",
577 filename: "plat_sepolicy_and_mapping.sha256",
578 src: ":plat_sepolicy_and_mapping.sha256_gen",
579 relative_install_path: "selinux",
580}
581
582genrule {
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100583 name: "apex_sepolicy.sha256_gen",
584 srcs: [":apex_sepolicy-33.cil"],
585 out: ["apex_sepolicy.sha256"],
586 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
587}
588
589prebuilt_etc {
590 name: "apex_sepolicy.sha256",
591 filename: "apex_sepolicy.sha256",
592 src: ":apex_sepolicy.sha256_gen",
593 installable: false,
594}
595
596genrule {
Inseob Kim039175b2021-03-25 15:37:34 +0900597 name: "system_ext_sepolicy_and_mapping.sha256_gen",
598 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
599 out: ["system_ext_sepolicy_and_mapping.sha256"],
600 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
601}
602
603prebuilt_etc {
604 name: "system_ext_sepolicy_and_mapping.sha256",
605 filename: "system_ext_sepolicy_and_mapping.sha256",
606 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
607 relative_install_path: "selinux",
608 system_ext_specific: true,
609}
610
611genrule {
612 name: "product_sepolicy_and_mapping.sha256_gen",
613 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
614 out: ["product_sepolicy_and_mapping.sha256"],
615 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
616}
617
618prebuilt_etc {
619 name: "product_sepolicy_and_mapping.sha256",
620 filename: "product_sepolicy_and_mapping.sha256",
621 src: ":product_sepolicy_and_mapping.sha256_gen",
622 relative_install_path: "selinux",
623 product_specific: true,
624}
625
Inseob Kim1c056b12021-04-30 00:11:43 +0900626sepolicy_vers {
627 name: "plat_sepolicy_vers.txt",
628 version: "vendor",
629 vendor: true,
630}
631
Inseob Kim731182a2021-05-06 11:44:37 +0000632soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900633 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000634 module_type: "prebuilt_defaults",
635 config_namespace: "ANDROID",
636 bool_variables: ["BOARD_USES_ODMIMAGE"],
637 properties: ["vendor", "device_specific"],
638}
639
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900640precompiled_sepolicy_prebuilts_defaults {
641 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000642 soong_config_variables: {
643 BOARD_USES_ODMIMAGE: {
644 device_specific: true,
645 conditions_default: {
646 vendor: true,
647 },
648 },
649 },
650}
651
652//////////////////////////////////
653// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
654// which precompiled_policy was built.
655//////////////////////////////////
656prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900657 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000658 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
659 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
660 src: ":plat_sepolicy_and_mapping.sha256_gen",
661 relative_install_path: "selinux",
662}
663
664//////////////////////////////////
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100665// SHA-256 digest of the apex_sepolicy.cil against which precompiled_policy
666// was built.
667//////////////////////////////////
668prebuilt_etc {
669 defaults: ["precompiled_sepolicy_prebuilts"],
670 name: "precompiled_sepolicy.apex_sepolicy.sha256",
671 filename: "precompiled_sepolicy.apex_sepolicy.sha256",
672 src: ":apex_sepolicy.sha256_gen",
673 relative_install_path: "selinux",
674}
675
676//////////////////////////////////
Inseob Kim731182a2021-05-06 11:44:37 +0000677// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
678// which precompiled_policy was built.
679//////////////////////////////////
680prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900681 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000682 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
683 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
684 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
685 relative_install_path: "selinux",
686}
687
688//////////////////////////////////
689// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
690// which precompiled_policy was built.
691//////////////////////////////////
692prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900693 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000694 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
695 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
696 src: ":product_sepolicy_and_mapping.sha256_gen",
697 relative_install_path: "selinux",
698}
699
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900700soong_config_module_type {
701 name: "precompiled_se_policy_binary",
702 module_type: "se_policy_binary",
703 config_namespace: "ANDROID",
704 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
705 value_variables: ["MIXED_SEPOLICY_VERSION"],
706 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
707}
708
709precompiled_se_policy_binary {
710 name: "precompiled_sepolicy",
711 srcs: [
712 ":plat_sepolicy.cil",
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100713 ":apex_sepolicy-33.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900714 ":plat_pub_versioned.cil",
715 ":system_ext_sepolicy.cil",
716 ":product_sepolicy.cil",
717 ":vendor_sepolicy.cil",
718 ":odm_sepolicy.cil",
719 ],
720 soong_config_variables: {
721 BOARD_USES_ODMIMAGE: {
722 device_specific: true,
723 conditions_default: {
724 vendor: true,
725 },
726 },
727 IS_TARGET_MIXED_SEPOLICY: {
728 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900729 },
730 MIXED_SEPOLICY_VERSION: {
731 srcs: [
732 ":plat_%s.cil",
733 ":system_ext_%s.cil",
734 ":product_%s.cil",
735 ],
736 conditions_default: {
737 srcs: [
738 ":plat_mapping_file",
739 ":system_ext_mapping_file",
740 ":product_mapping_file",
741 ],
742 },
743 },
744 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900745 required: [
746 "sepolicy_neverallows",
747 "sepolicy_neverallows_vendor",
748 ],
Inseob Kimeec39192022-01-21 11:47:54 +0900749 dist: {
750 targets: ["base-sepolicy-files-for-mapping"],
751 },
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900752}
Inseob Kim731182a2021-05-06 11:44:37 +0000753
Sandro143988d2022-08-05 11:38:56 +0000754precompiled_se_policy_binary {
755 name: "precompiled_sepolicy-without_apex",
756 srcs: [
757 ":plat_sepolicy.cil",
758 ":plat_pub_versioned.cil",
759 ":system_ext_sepolicy.cil",
760 ":product_sepolicy.cil",
761 ":vendor_sepolicy.cil",
762 ":odm_sepolicy.cil",
763 ],
764 soong_config_variables: {
765 BOARD_USES_ODMIMAGE: {
766 device_specific: true,
767 conditions_default: {
768 vendor: true,
769 },
770 },
771 IS_TARGET_MIXED_SEPOLICY: {
772 ignore_neverallow: true,
773 },
774 MIXED_SEPOLICY_VERSION: {
775 srcs: [
776 ":plat_%s.cil",
777 ":system_ext_%s.cil",
778 ":product_%s.cil",
779 ],
780 conditions_default: {
781 srcs: [
782 ":plat_mapping_file",
783 ":system_ext_mapping_file",
784 ":product_mapping_file",
785 ],
786 },
787 },
788 },
789 required: [
790 "sepolicy_neverallows",
791 "sepolicy_neverallows_vendor",
792 ],
793 dist: {
794 targets: ["base-sepolicy-files-for-mapping"],
795 },
796}
797
Inseob Kim5bbcd682021-12-28 14:57:03 +0900798// policy for recovery
799se_policy_conf {
800 name: "recovery_sepolicy.conf",
801 srcs: plat_policies_for_vendor + [
802 ":se_build_files{.plat_vendor_for_vendor}",
803 ":se_build_files{.vendor}",
804 ":se_build_files{.odm}",
805 ],
806 target_recovery: true,
807 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900808 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900809}
810
811se_policy_cil {
812 name: "recovery_sepolicy.cil",
813 src: ":recovery_sepolicy.conf",
814 secilc_check: false, // will be done in se_policy_binary module
815 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900816 recovery: true,
Inseob Kim5bbcd682021-12-28 14:57:03 +0900817}
818
819se_policy_binary {
820 name: "sepolicy.recovery",
821 srcs: [":recovery_sepolicy.cil"],
822 stem: "sepolicy",
823 recovery: true,
824}
825
Inseob Kima49e7242021-03-22 10:26:13 +0900826//////////////////////////////////
827// SELinux policy embedded into CTS.
828// CTS checks neverallow rules of this policy against the policy of the device under test.
829//////////////////////////////////
830se_policy_conf {
831 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900832 srcs: plat_public_policy +
833 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900834 build_variant: "user",
835 cts: true,
836 exclude_build_test: true,
837}
Inseob Kimd5816612021-09-15 03:01:05 +0000838
839//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000840// Base system policy for treble sepolicy tests.
841// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
842// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
843// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
844// See treble_sepolicy_tests_for_release.mk for more details.
845//////////////////////////////////
846se_policy_conf {
847 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900848 srcs: plat_public_policy +
849 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000850 build_variant: "user",
851 installable: false,
852}
853
854se_policy_cil {
855 name: "base_plat_sepolicy.cil",
856 src: ":base_plat_sepolicy.conf",
857 additional_cil_files: ["private/technical_debt.cil"],
858 installable: false,
859 secilc_check: false, // done by se_policy_binary
860}
861
862se_policy_binary {
863 name: "base_plat_sepolicy",
864 srcs: [":base_plat_sepolicy.cil"],
865 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900866 dist: {
867 targets: ["base-sepolicy-files-for-mapping"],
868 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000869}
870
871se_policy_conf {
872 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900873 srcs: plat_public_policy +
874 plat_private_policy +
875 system_ext_public_policy +
876 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000877 build_variant: "user",
878 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900879 system_ext_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000880}
881
882se_policy_cil {
883 name: "base_system_ext_sepolicy.cil",
884 src: ":base_system_ext_sepolicy.conf",
885 additional_cil_files: ["private/technical_debt.cil"],
886 system_ext_specific: true,
887 installable: false,
888 secilc_check: false, // done by se_policy_binary
889}
890
891se_policy_binary {
892 name: "base_system_ext_sepolicy",
893 srcs: [":base_system_ext_sepolicy.cil"],
894 system_ext_specific: true,
895 installable: false,
896}
897
898se_policy_conf {
899 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900900 srcs: plat_public_policy +
901 plat_private_policy +
902 system_ext_public_policy +
903 system_ext_private_policy +
904 product_public_policy +
905 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000906 build_variant: "user",
907 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900908 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000909}
910
911se_policy_cil {
912 name: "base_product_sepolicy.cil",
913 src: ":base_product_sepolicy.conf",
914 additional_cil_files: ["private/technical_debt.cil"],
915 product_specific: true,
916 installable: false,
917 secilc_check: false, // done by se_policy_binary
918}
919
920se_policy_binary {
921 name: "base_product_sepolicy",
922 srcs: [":base_product_sepolicy.cil"],
923 product_specific: true,
924 installable: false,
925}
926
927se_policy_conf {
928 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900929 srcs: plat_public_policy +
930 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000931 build_variant: "user",
932 installable: false,
933}
934
935se_policy_cil {
936 name: "base_plat_pub_policy.cil",
937 src: ":base_plat_pub_policy.conf",
938 filter_out: [":reqd_policy_mask.cil"],
939 secilc_check: false,
940 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900941 dist: {
942 targets: ["base-sepolicy-files-for-mapping"],
943 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000944}
945
946se_policy_conf {
947 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900948 srcs: plat_public_policy +
949 system_ext_public_policy +
950 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000951 build_variant: "user",
952 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900953 system_ext_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000954}
955
956se_policy_cil {
957 name: "base_system_ext_pub_policy.cil",
958 src: ":base_system_ext_pub_policy.conf",
959 filter_out: [":reqd_policy_mask.cil"],
960 secilc_check: false,
961 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900962 system_ext_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000963}
964
965se_policy_conf {
966 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900967 srcs: plat_public_policy +
968 system_ext_public_policy +
969 product_public_policy +
970 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000971 build_variant: "user",
972 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900973 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000974}
975
976se_policy_cil {
977 name: "base_product_pub_policy.cil",
978 src: ":base_product_pub_policy.conf",
979 filter_out: [":reqd_policy_mask.cil"],
980 secilc_check: false,
981 installable: false,
Inseob Kim6c6f53b2023-04-26 11:03:35 +0900982 product_specific: true,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000983}
984
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800985// bug_map - Bug tracking information for selinux denials loaded by auditd.
Inseob Kim41964032022-04-22 07:50:22 +0900986se_build_files {
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800987 name: "bug_map_files",
988 srcs: ["bug_map"],
989}
990
991se_bug_map {
992 name: "plat_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900993 srcs: [":bug_map_files{.plat_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800994 stem: "bug_map",
995}
996
997se_bug_map {
998 name: "system_ext_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +0900999 srcs: [":bug_map_files{.system_ext_private}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001000 stem: "bug_map",
1001 system_ext_specific: true,
1002}
1003
1004se_bug_map {
1005 name: "vendor_bug_map",
Inseob Kim41964032022-04-22 07:50:22 +09001006 srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor_for_vendor}"],
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001007 // Legacy file name of the vendor partition bug_map.
1008 stem: "selinux_denial_metadata",
1009 vendor: true,
1010}
1011
Inseob Kim0de7fcc2021-12-22 23:06:53 +09001012se_neverallow_test {
1013 name: "sepolicy_neverallows",
1014 srcs: plat_public_policy +
1015 plat_private_policy +
1016 system_ext_public_policy +
1017 system_ext_private_policy +
1018 product_public_policy +
1019 product_private_policy,
1020}
1021
1022se_neverallow_test {
1023 name: "sepolicy_neverallows_vendor",
1024 srcs: plat_policies_for_vendor + [
1025 ":se_build_files{.plat_vendor_for_vendor}",
1026 ":se_build_files{.vendor}",
1027 ":se_build_files{.odm}",
1028 ],
Inseob Kim6c6f53b2023-04-26 11:03:35 +09001029 vendor: true,
Inseob Kim0de7fcc2021-12-22 23:06:53 +09001030}
1031
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001032//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001033// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1034// Additional directories can be specified via Makefile variables:
1035// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1036//////////////////////////////////
1037se_freeze_test {
1038 name: "sepolicy_freeze_test",
1039}
Inseob Kim61257ca2022-02-25 11:26:16 +09001040
1041//////////////////////////////////
1042// sepolicy_test checks various types of violations, which can't be easily done
1043// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
1044//////////////////////////////////
1045genrule {
1046 name: "sepolicy_test",
1047 srcs: [
1048 ":plat_file_contexts",
1049 ":vendor_file_contexts",
1050 ":system_ext_file_contexts",
1051 ":product_file_contexts",
1052 ":odm_file_contexts",
1053 ":precompiled_sepolicy",
1054 ],
1055 tools: ["sepolicy_tests"],
1056 out: ["sepolicy_test"],
1057 cmd: "$(location sepolicy_tests) " +
1058 "-f $(location :plat_file_contexts) " +
1059 "-f $(location :vendor_file_contexts) " +
1060 "-f $(location :system_ext_file_contexts) " +
1061 "-f $(location :product_file_contexts) " +
1062 "-f $(location :odm_file_contexts) " +
1063 "-p $(location :precompiled_sepolicy) && " +
1064 "touch $(out)",
1065}