blob: 6aeb27bce01d60e1cfea2e0f85e302fae639b344 [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
Tri Vo84e247a2018-03-25 20:03:58 -070047se_filegroup {
Jae Shin1fa96342018-07-11 18:30:44 +090048 name: "28.0.board.compat.map",
49 srcs: [
50 "compat/28.0/28.0.cil",
51 ],
52}
53
Jinguang Donge0125692019-03-05 17:20:54 +080054se_filegroup {
Tri Vo50aa0292019-06-01 17:04:13 -070055 name: "29.0.board.compat.map",
56 srcs: [
57 "compat/29.0/29.0.cil",
58 ],
59}
60
61se_filegroup {
Inseob Kimace36ab2020-05-07 20:19:05 +090062 name: "30.0.board.compat.map",
63 srcs: [
64 "compat/30.0/30.0.cil",
65 ],
66}
67
68se_filegroup {
Inseob Kim4f20ff72021-06-15 21:05:39 +090069 name: "31.0.board.compat.map",
70 srcs: [
71 "compat/31.0/31.0.cil",
72 ],
73}
74
75se_filegroup {
Inseob Kimbee558e2021-11-30 14:58:10 +090076 name: "32.0.board.compat.map",
77 srcs: [
78 "compat/32.0/32.0.cil",
79 ],
80}
81
82se_filegroup {
Yi-Yo Chiang8be93c02021-04-13 02:49:29 +080083 name: "28.0.board.compat.cil",
84 srcs: [
85 "compat/28.0/28.0.compat.cil",
86 ],
87}
88
89se_filegroup {
90 name: "29.0.board.compat.cil",
91 srcs: [
92 "compat/29.0/29.0.compat.cil",
93 ],
94}
95
96se_filegroup {
97 name: "30.0.board.compat.cil",
98 srcs: [
99 "compat/30.0/30.0.compat.cil",
100 ],
101}
102
103se_filegroup {
Inseob Kim4f20ff72021-06-15 21:05:39 +0900104 name: "31.0.board.compat.cil",
105 srcs: [
106 "compat/31.0/31.0.compat.cil",
107 ],
108}
109
110se_filegroup {
Inseob Kimbee558e2021-11-30 14:58:10 +0900111 name: "32.0.board.compat.cil",
112 srcs: [
113 "compat/32.0/32.0.compat.cil",
114 ],
115}
116
117se_filegroup {
Jinguang Donge0125692019-03-05 17:20:54 +0800118 name: "28.0.board.ignore.map",
119 srcs: [
120 "compat/28.0/28.0.ignore.cil",
121 ],
122}
123
Tri Vo50aa0292019-06-01 17:04:13 -0700124se_filegroup {
125 name: "29.0.board.ignore.map",
126 srcs: [
127 "compat/29.0/29.0.ignore.cil",
128 ],
129}
130
Inseob Kimace36ab2020-05-07 20:19:05 +0900131se_filegroup {
132 name: "30.0.board.ignore.map",
133 srcs: [
134 "compat/30.0/30.0.ignore.cil",
135 ],
136}
137
Inseob Kim4f20ff72021-06-15 21:05:39 +0900138se_filegroup {
139 name: "31.0.board.ignore.map",
140 srcs: [
141 "compat/31.0/31.0.ignore.cil",
142 ],
143}
144
Inseob Kimbee558e2021-11-30 14:58:10 +0900145se_filegroup {
146 name: "32.0.board.ignore.map",
147 srcs: [
148 "compat/32.0/32.0.ignore.cil",
149 ],
150}
151
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900152se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900153 name: "file_contexts_files",
154 srcs: ["file_contexts"],
155}
156
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900157se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900158 name: "file_contexts_asan_files",
159 srcs: ["file_contexts_asan"],
160}
161
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900162se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900163 name: "file_contexts_overlayfs_files",
164 srcs: ["file_contexts_overlayfs"],
165}
166
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900167se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900168 name: "hwservice_contexts_files",
169 srcs: ["hwservice_contexts"],
170}
171
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900172se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900173 name: "property_contexts_files",
174 srcs: ["property_contexts"],
175}
176
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900177se_build_files {
Inseob Kimb554e592019-04-15 20:10:46 +0900178 name: "service_contexts_files",
179 srcs: ["service_contexts"],
180}
181
Inseob Kim6d3d5a62021-12-21 20:55:32 +0900182se_build_files {
Janis Danisevskisc40681f2020-07-25 13:02:29 -0700183 name: "keystore2_key_contexts_files",
184 srcs: ["keystore2_key_contexts"],
185}
186
Inseob Kim2dac2672021-12-29 17:54:57 +0900187se_build_files {
188 name: "seapp_contexts_files",
189 srcs: ["seapp_contexts"],
190}
191
yangbill3e345372020-04-15 13:55:47 +0800192// For vts_treble_sys_prop_test
193filegroup {
194 name: "private_property_contexts",
195 srcs: ["private/property_contexts"],
196 visibility: [
197 "//test/vts-testcase/security/system_property",
198 ],
199}
Inseob Kime35b49b2021-02-18 19:15:41 +0900200
Inseob Kima49e7242021-03-22 10:26:13 +0900201se_build_files {
202 name: "se_build_files",
Inseob Kime35b49b2021-02-18 19:15:41 +0900203 srcs: [
Inseob Kima49e7242021-03-22 10:26:13 +0900204 "security_classes",
205 "initial_sids",
206 "access_vectors",
207 "global_macros",
208 "neverallow_macros",
209 "mls_macros",
210 "mls_decl",
211 "mls",
212 "policy_capabilities",
213 "te_macros",
214 "attributes",
215 "ioctl_defines",
216 "ioctl_macros",
217 "*.te",
218 "roles_decl",
219 "roles",
220 "users",
221 "initial_sid_contexts",
222 "fs_use",
223 "genfs_contexts",
224 "port_contexts",
Inseob Kime35b49b2021-02-18 19:15:41 +0900225 ],
226}
227
Inseob Kim7cb20812021-12-16 16:52:14 +0900228se_build_files {
229 name: "sepolicy_technical_debt",
230 srcs: ["technical_debt.cil"],
231}
232
Inseob Kim0a707fa2021-12-09 23:35:11 +0900233reqd_mask_policy = [":se_build_files{.reqd_mask}"]
234plat_public_policy = [":se_build_files{.plat_public}"]
235plat_private_policy = [":se_build_files{.plat_private}"]
236system_ext_public_policy = [":se_build_files{.system_ext_public}"]
237system_ext_private_policy = [":se_build_files{.system_ext_private}"]
238product_public_policy = [":se_build_files{.product_public}"]
239product_private_policy = [":se_build_files{.product_private}"]
240
Inseob Kima49e7242021-03-22 10:26:13 +0900241// reqd_policy_mask - a policy.conf file which contains only the bare minimum
242// policy necessary to use checkpolicy.
243//
244// This bare-minimum policy needs to be present in all policy.conf files, but
245// should not necessarily be exported as part of the public policy.
246//
247// The rules generated by reqd_policy_mask will allow the compilation of public
248// policy and subsequent removal of CIL policy that should not be exported.
249se_policy_conf {
250 name: "reqd_policy_mask.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900251 srcs: reqd_mask_policy,
Inseob Kime35b49b2021-02-18 19:15:41 +0900252 installable: false,
253}
254
Inseob Kima49e7242021-03-22 10:26:13 +0900255se_policy_cil {
256 name: "reqd_policy_mask.cil",
257 src: ":reqd_policy_mask.conf",
258 secilc_check: false,
259 installable: false,
Inseob Kime35b49b2021-02-18 19:15:41 +0900260}
261
Inseob Kima49e7242021-03-22 10:26:13 +0900262// pub_policy - policy that will be exported to be a part of non-platform
263// policy corresponding to this platform version.
264//
265// This is a limited subset of policy that would not compile in checkpolicy on
266// its own.
267//
268// To get around this limitation, add only the required files from private
269// policy, which will generate CIL policy that will then be filtered out by the
270// reqd_policy_mask.
271//
272// There are three pub_policy.cil files below:
273// - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
274// - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
275// - plat_pub_policy.cil: exported 'system' policy.
276//
277// Those above files will in turn be used to generate the following versioned cil files:
278// - product_mapping_file: the versioned, exported 'product' policy in product partition.
279// - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
280// - plat_mapping_file: the versioned, exported 'system' policy in system partition.
281// - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
282// in vendor partition.
283//
284se_policy_conf {
285 name: "pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900286 srcs: plat_public_policy +
287 system_ext_public_policy +
288 product_public_policy +
289 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900290 installable: false,
291}
292
293se_policy_cil {
294 name: "pub_policy.cil",
295 src: ":pub_policy.conf",
296 filter_out: [":reqd_policy_mask.cil"],
297 secilc_check: false,
298 installable: false,
299}
300
301se_policy_conf {
302 name: "system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900303 srcs: plat_public_policy +
304 system_ext_public_policy +
305 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900306 installable: false,
307}
308
309se_policy_cil {
310 name: "system_ext_pub_policy.cil",
311 src: ":system_ext_pub_policy.conf",
312 filter_out: [":reqd_policy_mask.cil"],
313 secilc_check: false,
314 installable: false,
315}
316
317se_policy_conf {
318 name: "plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900319 srcs: plat_public_policy +
320 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900321 installable: false,
322}
323
324se_policy_cil {
325 name: "plat_pub_policy.cil",
326 src: ":plat_pub_policy.conf",
327 filter_out: [":reqd_policy_mask.cil"],
328 secilc_check: false,
329 installable: false,
330}
331
332// plat_policy.conf - A combination of the private and public platform policy
333// which will ship with the device.
334//
335// The platform will always reflect the most recent platform version and is not
336// currently being attributized.
337se_policy_conf {
338 name: "plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900339 srcs: plat_public_policy +
340 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900341 installable: false,
342}
343
344se_policy_cil {
345 name: "plat_sepolicy.cil",
346 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900347 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900348}
349
Inseob Kim6cc75f42021-04-29 13:53:20 +0000350// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
351se_policy_conf {
352 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900353 srcs: plat_public_policy +
354 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000355 build_variant: "userdebug",
356 installable: false,
357}
358
359se_policy_cil {
360 name: "userdebug_plat_sepolicy.cil",
361 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900362 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000363 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800364 dist: {
365 targets: ["droidcore"],
366 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000367}
368
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000369// A copy of the userdebug_plat_policy in GSI.
370soong_config_module_type {
371 name: "gsi_se_policy_cil",
372 module_type: "se_policy_cil",
373 config_namespace: "ANDROID",
374 bool_variables: [
375 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
376 ],
377 properties: [
378 "enabled",
379 "installable",
380 ],
381}
382
383gsi_se_policy_cil {
384 name: "system_ext_userdebug_plat_sepolicy.cil",
385 stem: "userdebug_plat_sepolicy.cil",
386 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900387 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000388 system_ext_specific: true,
389 enabled: false,
390 installable: false,
391 soong_config_variables: {
392 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
393 enabled: true,
394 installable: true,
395 },
396 },
397}
398
Inseob Kima49e7242021-03-22 10:26:13 +0900399// system_ext_policy.conf - A combination of the private and public system_ext
400// policy which will ship with the device. System_ext policy is not attributized
401se_policy_conf {
402 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900403 srcs: plat_public_policy +
404 plat_private_policy +
405 system_ext_public_policy +
406 system_ext_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900407 installable: false,
408}
409
410se_policy_cil {
411 name: "system_ext_sepolicy.cil",
412 src: ":system_ext_sepolicy.conf",
413 system_ext_specific: true,
414 filter_out: [":plat_sepolicy.cil"],
415 remove_line_marker: true,
416}
417
418// product_policy.conf - A combination of the private and public product policy
419// which will ship with the device. Product policy is not attributized
420se_policy_conf {
421 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900422 srcs: plat_public_policy +
423 plat_private_policy +
424 system_ext_public_policy +
425 system_ext_private_policy +
426 product_public_policy +
427 product_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900428 installable: false,
429}
430
431se_policy_cil {
432 name: "product_sepolicy.cil",
433 src: ":product_sepolicy.conf",
434 product_specific: true,
435 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
436 remove_line_marker: true,
437}
438
Inseob Kim039175b2021-03-25 15:37:34 +0900439// policy mapping files
440// auto-generate the mapping file for current platform policy, since it needs to
441// track platform policy development
442se_versioned_policy {
443 name: "plat_mapping_file",
444 base: ":plat_pub_policy.cil",
445 mapping: true,
446 version: "current",
447 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
448}
449
450se_versioned_policy {
451 name: "system_ext_mapping_file",
452 base: ":system_ext_pub_policy.cil",
453 mapping: true,
454 version: "current",
455 filter_out: [":plat_mapping_file"],
456 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
457 system_ext_specific: true,
458}
459
460se_versioned_policy {
461 name: "product_mapping_file",
462 base: ":pub_policy.cil",
463 mapping: true,
464 version: "current",
465 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
466 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
467 product_specific: true,
468}
469
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900470// vendor/odm sepolicy
471//
472// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
473// policy files of platform (system, system_ext, product) can't be mixed with
474// policy files of vendor (vendor, odm). If it's the case, platform policies and
475// vendor policies are separately built. More specifically,
476//
477// - Platform policy files needed to build vendor policies, such as plat_policy,
478// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
479// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
480//
481// - sepolicy_neverallows only checks platform policies, and a new module
482// sepolicy_neverallows_vendor checks vendor policies.
483//
484// - neverallow checks are turned off while compiling precompiled_sepolicy
485// module and sepolicy module.
486//
487// - Vendor policies are not checked on the compat test (compat.mk).
488//
489// In such scenario, we can grab platform policy files from the prebuilts/api
490// directory. But we need more than that: prebuilts of system_ext, product,
491// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
492// variables are introduced to specify such prebuilts.
493//
494// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
495// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
496// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
497// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
498// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
499// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
500//
501// Vendors are responsible for copying policy files from the old version of the
502// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
503// can be used to build vendor policies.
504//
505// To support both mixed build and normal build, platform policy files are
506// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
507// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
508// Otherwise, they will be equal to the Makefile variables above.
509
510plat_public_policies_for_vendor = [
511 ":se_build_files{.plat_public_for_vendor}",
512 ":se_build_files{.system_ext_public_for_vendor}",
513 ":se_build_files{.product_public_for_vendor}",
514 ":se_build_files{.reqd_mask_for_vendor}",
515]
516
517plat_policies_for_vendor = [
518 ":se_build_files{.plat_public_for_vendor}",
519 ":se_build_files{.plat_private_for_vendor}",
520 ":se_build_files{.system_ext_public_for_vendor}",
521 ":se_build_files{.system_ext_private_for_vendor}",
522 ":se_build_files{.product_public_for_vendor}",
523 ":se_build_files{.product_private_for_vendor}",
524]
525
526se_policy_conf {
527 name: "plat_policy_for_vendor.conf",
528 srcs: plat_policies_for_vendor,
529 installable: false,
530}
531
532se_policy_cil {
533 name: "plat_policy_for_vendor.cil",
534 src: ":plat_policy_for_vendor.conf",
535 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
536 installable: false,
537}
538
539se_policy_conf {
540 name: "reqd_policy_mask_for_vendor.conf",
541 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
542 installable: false,
543}
544
545se_policy_cil {
546 name: "reqd_policy_mask_for_vendor.cil",
547 src: ":reqd_policy_mask_for_vendor.conf",
548 secilc_check: false,
549 installable: false,
550}
551
552se_policy_conf {
553 name: "pub_policy_for_vendor.conf",
554 srcs: plat_public_policies_for_vendor,
555 installable: false,
556}
557
558se_policy_cil {
559 name: "pub_policy_for_vendor.cil",
560 src: ":pub_policy_for_vendor.conf",
561 filter_out: [":reqd_policy_mask_for_vendor.cil"],
562 secilc_check: false,
563 installable: false,
564}
565
566se_versioned_policy {
567 name: "plat_mapping_file_for_vendor",
568 base: ":pub_policy_for_vendor.cil",
569 mapping: true,
570 version: "vendor",
571 installable: false,
572}
573
Inseob Kim039175b2021-03-25 15:37:34 +0900574// plat_pub_versioned.cil - the exported platform policy associated with the version
575// that non-platform policy targets.
576se_versioned_policy {
577 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900578 base: ":pub_policy_for_vendor.cil",
579 target_policy: ":pub_policy_for_vendor.cil",
580 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900581 vendor: true,
582}
583
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900584// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
585// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
586// policy and the platform public policy files in order to use checkpolicy.
587se_policy_conf {
588 name: "vendor_sepolicy.conf",
589 srcs: plat_public_policies_for_vendor + [
590 ":se_build_files{.plat_vendor_for_vendor}",
591 ":se_build_files{.vendor}",
592 ],
593 installable: false,
594}
595
596se_policy_cil {
597 name: "vendor_sepolicy.cil.raw",
598 src: ":vendor_sepolicy.conf",
599 filter_out: [":reqd_policy_mask_for_vendor.cil"],
600 secilc_check: false, // will be done in se_versioned_policy module
601 installable: false,
602}
603
604se_versioned_policy {
605 name: "vendor_sepolicy.cil",
606 base: ":pub_policy_for_vendor.cil",
607 target_policy: ":vendor_sepolicy.cil.raw",
608 version: "vendor",
609 dependent_cils: [
610 ":plat_policy_for_vendor.cil",
611 ":plat_pub_versioned.cil",
612 ":plat_mapping_file_for_vendor",
613 ],
614 filter_out: [":plat_pub_versioned.cil"],
615 vendor: true,
616}
617
618// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
619// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
620// policy and the platform public policy files in order to use checkpolicy.
621se_policy_conf {
622 name: "odm_sepolicy.conf",
623 srcs: plat_public_policies_for_vendor + [
624 ":se_build_files{.plat_vendor_for_vendor}",
625 ":se_build_files{.vendor}",
626 ":se_build_files{.odm}",
627 ],
628 installable: false,
629}
630
631se_policy_cil {
632 name: "odm_sepolicy.cil.raw",
633 src: ":odm_sepolicy.conf",
634 filter_out: [
635 ":reqd_policy_mask_for_vendor.cil",
636 ":vendor_sepolicy.cil",
637 ],
638 secilc_check: false, // will be done in se_versioned_policy module
639 installable: false,
640}
641
642se_versioned_policy {
643 name: "odm_sepolicy.cil",
644 base: ":pub_policy_for_vendor.cil",
645 target_policy: ":odm_sepolicy.cil.raw",
646 version: "vendor",
647 dependent_cils: [
648 ":plat_policy_for_vendor.cil",
649 ":plat_pub_versioned.cil",
650 ":plat_mapping_file_for_vendor",
651 ":vendor_sepolicy.cil",
652 ],
653 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
654 device_specific: true,
655}
656
Inseob Kim039175b2021-03-25 15:37:34 +0900657//////////////////////////////////
658// Precompiled sepolicy is loaded if and only if:
659// - plat_sepolicy_and_mapping.sha256 equals
660// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
661// AND
662// - system_ext_sepolicy_and_mapping.sha256 equals
663// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
664// AND
665// - product_sepolicy_and_mapping.sha256 equals
666// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
667// See system/core/init/selinux.cpp for details.
668//////////////////////////////////
669genrule {
670 name: "plat_sepolicy_and_mapping.sha256_gen",
671 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
672 out: ["plat_sepolicy_and_mapping.sha256"],
673 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
674}
675
676prebuilt_etc {
677 name: "plat_sepolicy_and_mapping.sha256",
678 filename: "plat_sepolicy_and_mapping.sha256",
679 src: ":plat_sepolicy_and_mapping.sha256_gen",
680 relative_install_path: "selinux",
681}
682
683genrule {
684 name: "system_ext_sepolicy_and_mapping.sha256_gen",
685 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
686 out: ["system_ext_sepolicy_and_mapping.sha256"],
687 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
688}
689
690prebuilt_etc {
691 name: "system_ext_sepolicy_and_mapping.sha256",
692 filename: "system_ext_sepolicy_and_mapping.sha256",
693 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
694 relative_install_path: "selinux",
695 system_ext_specific: true,
696}
697
698genrule {
699 name: "product_sepolicy_and_mapping.sha256_gen",
700 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
701 out: ["product_sepolicy_and_mapping.sha256"],
702 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
703}
704
705prebuilt_etc {
706 name: "product_sepolicy_and_mapping.sha256",
707 filename: "product_sepolicy_and_mapping.sha256",
708 src: ":product_sepolicy_and_mapping.sha256_gen",
709 relative_install_path: "selinux",
710 product_specific: true,
711}
712
Inseob Kim1c056b12021-04-30 00:11:43 +0900713sepolicy_vers {
714 name: "plat_sepolicy_vers.txt",
715 version: "vendor",
716 vendor: true,
717}
718
Inseob Kim731182a2021-05-06 11:44:37 +0000719soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900720 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000721 module_type: "prebuilt_defaults",
722 config_namespace: "ANDROID",
723 bool_variables: ["BOARD_USES_ODMIMAGE"],
724 properties: ["vendor", "device_specific"],
725}
726
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900727precompiled_sepolicy_prebuilts_defaults {
728 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000729 soong_config_variables: {
730 BOARD_USES_ODMIMAGE: {
731 device_specific: true,
732 conditions_default: {
733 vendor: true,
734 },
735 },
736 },
737}
738
739//////////////////////////////////
740// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
741// which precompiled_policy was built.
742//////////////////////////////////
743prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900744 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000745 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
746 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
747 src: ":plat_sepolicy_and_mapping.sha256_gen",
748 relative_install_path: "selinux",
749}
750
751//////////////////////////////////
752// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
753// which precompiled_policy was built.
754//////////////////////////////////
755prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900756 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000757 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
758 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
759 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
760 relative_install_path: "selinux",
761}
762
763//////////////////////////////////
764// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
765// which precompiled_policy was built.
766//////////////////////////////////
767prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900768 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000769 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
770 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
771 src: ":product_sepolicy_and_mapping.sha256_gen",
772 relative_install_path: "selinux",
773}
774
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900775soong_config_module_type {
776 name: "precompiled_se_policy_binary",
777 module_type: "se_policy_binary",
778 config_namespace: "ANDROID",
779 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
780 value_variables: ["MIXED_SEPOLICY_VERSION"],
781 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
782}
783
784precompiled_se_policy_binary {
785 name: "precompiled_sepolicy",
786 srcs: [
787 ":plat_sepolicy.cil",
788 ":plat_pub_versioned.cil",
789 ":system_ext_sepolicy.cil",
790 ":product_sepolicy.cil",
791 ":vendor_sepolicy.cil",
792 ":odm_sepolicy.cil",
793 ],
794 soong_config_variables: {
795 BOARD_USES_ODMIMAGE: {
796 device_specific: true,
797 conditions_default: {
798 vendor: true,
799 },
800 },
801 IS_TARGET_MIXED_SEPOLICY: {
802 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900803 },
804 MIXED_SEPOLICY_VERSION: {
805 srcs: [
806 ":plat_%s.cil",
807 ":system_ext_%s.cil",
808 ":product_%s.cil",
809 ],
810 conditions_default: {
811 srcs: [
812 ":plat_mapping_file",
813 ":system_ext_mapping_file",
814 ":product_mapping_file",
815 ],
816 },
817 },
818 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900819 required: [
820 "sepolicy_neverallows",
821 "sepolicy_neverallows_vendor",
822 ],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900823}
Inseob Kim731182a2021-05-06 11:44:37 +0000824
Inseob Kim5bbcd682021-12-28 14:57:03 +0900825// policy for recovery
826se_policy_conf {
827 name: "recovery_sepolicy.conf",
828 srcs: plat_policies_for_vendor + [
829 ":se_build_files{.plat_vendor_for_vendor}",
830 ":se_build_files{.vendor}",
831 ":se_build_files{.odm}",
832 ],
833 target_recovery: true,
834 installable: false,
835}
836
837se_policy_cil {
838 name: "recovery_sepolicy.cil",
839 src: ":recovery_sepolicy.conf",
840 secilc_check: false, // will be done in se_policy_binary module
841 installable: false,
842}
843
844se_policy_binary {
845 name: "sepolicy.recovery",
846 srcs: [":recovery_sepolicy.cil"],
847 stem: "sepolicy",
848 recovery: true,
849}
850
Inseob Kima49e7242021-03-22 10:26:13 +0900851//////////////////////////////////
852// SELinux policy embedded into CTS.
853// CTS checks neverallow rules of this policy against the policy of the device under test.
854//////////////////////////////////
855se_policy_conf {
856 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900857 srcs: plat_public_policy +
858 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900859 build_variant: "user",
860 cts: true,
861 exclude_build_test: true,
862}
Inseob Kimd5816612021-09-15 03:01:05 +0000863
864//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000865// Base system policy for treble sepolicy tests.
866// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
867// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
868// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
869// See treble_sepolicy_tests_for_release.mk for more details.
870//////////////////////////////////
871se_policy_conf {
872 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900873 srcs: plat_public_policy +
874 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000875 build_variant: "user",
876 installable: false,
877}
878
879se_policy_cil {
880 name: "base_plat_sepolicy.cil",
881 src: ":base_plat_sepolicy.conf",
882 additional_cil_files: ["private/technical_debt.cil"],
883 installable: false,
884 secilc_check: false, // done by se_policy_binary
885}
886
887se_policy_binary {
888 name: "base_plat_sepolicy",
889 srcs: [":base_plat_sepolicy.cil"],
890 installable: false,
891}
892
893se_policy_conf {
894 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900895 srcs: plat_public_policy +
896 plat_private_policy +
897 system_ext_public_policy +
898 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000899 build_variant: "user",
900 installable: false,
901}
902
903se_policy_cil {
904 name: "base_system_ext_sepolicy.cil",
905 src: ":base_system_ext_sepolicy.conf",
906 additional_cil_files: ["private/technical_debt.cil"],
907 system_ext_specific: true,
908 installable: false,
909 secilc_check: false, // done by se_policy_binary
910}
911
912se_policy_binary {
913 name: "base_system_ext_sepolicy",
914 srcs: [":base_system_ext_sepolicy.cil"],
915 system_ext_specific: true,
916 installable: false,
917}
918
919se_policy_conf {
920 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900921 srcs: plat_public_policy +
922 plat_private_policy +
923 system_ext_public_policy +
924 system_ext_private_policy +
925 product_public_policy +
926 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000927 build_variant: "user",
928 installable: false,
929}
930
931se_policy_cil {
932 name: "base_product_sepolicy.cil",
933 src: ":base_product_sepolicy.conf",
934 additional_cil_files: ["private/technical_debt.cil"],
935 product_specific: true,
936 installable: false,
937 secilc_check: false, // done by se_policy_binary
938}
939
940se_policy_binary {
941 name: "base_product_sepolicy",
942 srcs: [":base_product_sepolicy.cil"],
943 product_specific: true,
944 installable: false,
945}
946
947se_policy_conf {
948 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900949 srcs: plat_public_policy +
950 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000951 build_variant: "user",
952 installable: false,
953}
954
955se_policy_cil {
956 name: "base_plat_pub_policy.cil",
957 src: ":base_plat_pub_policy.conf",
958 filter_out: [":reqd_policy_mask.cil"],
959 secilc_check: false,
960 installable: false,
961}
962
963se_policy_conf {
964 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900965 srcs: plat_public_policy +
966 system_ext_public_policy +
967 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000968 build_variant: "user",
969 installable: false,
970}
971
972se_policy_cil {
973 name: "base_system_ext_pub_policy.cil",
974 src: ":base_system_ext_pub_policy.conf",
975 filter_out: [":reqd_policy_mask.cil"],
976 secilc_check: false,
977 installable: false,
978}
979
980se_policy_conf {
981 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900982 srcs: plat_public_policy +
983 system_ext_public_policy +
984 product_public_policy +
985 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000986 build_variant: "user",
987 installable: false,
988}
989
990se_policy_cil {
991 name: "base_product_pub_policy.cil",
992 src: ":base_product_pub_policy.conf",
993 filter_out: [":reqd_policy_mask.cil"],
994 secilc_check: false,
995 installable: false,
996}
997
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800998// bug_map - Bug tracking information for selinux denials loaded by auditd.
999se_filegroup {
1000 name: "bug_map_files",
1001 srcs: ["bug_map"],
1002}
1003
1004se_bug_map {
1005 name: "plat_bug_map",
1006 srcs: [":bug_map_files"],
1007 stem: "bug_map",
1008}
1009
1010se_bug_map {
1011 name: "system_ext_bug_map",
1012 srcs: [":bug_map_files"],
1013 stem: "bug_map",
1014 system_ext_specific: true,
1015}
1016
1017se_bug_map {
1018 name: "vendor_bug_map",
1019 srcs: [":bug_map_files"],
1020 // Legacy file name of the vendor partition bug_map.
1021 stem: "selinux_denial_metadata",
1022 vendor: true,
1023}
1024
Inseob Kim0de7fcc2021-12-22 23:06:53 +09001025se_neverallow_test {
1026 name: "sepolicy_neverallows",
1027 srcs: plat_public_policy +
1028 plat_private_policy +
1029 system_ext_public_policy +
1030 system_ext_private_policy +
1031 product_public_policy +
1032 product_private_policy,
1033}
1034
1035se_neverallow_test {
1036 name: "sepolicy_neverallows_vendor",
1037 srcs: plat_policies_for_vendor + [
1038 ":se_build_files{.plat_vendor_for_vendor}",
1039 ":se_build_files{.vendor}",
1040 ":se_build_files{.odm}",
1041 ],
1042}
1043
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001044//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001045// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1046// Additional directories can be specified via Makefile variables:
1047// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1048//////////////////////////////////
1049se_freeze_test {
1050 name: "sepolicy_freeze_test",
1051}