blob: 9f3a11146ba0aedb66402b20d0de351483f63dec [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
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100350
351se_policy_conf {
352 name: "apex_sepolicy-33.conf",
353 srcs: plat_public_policy + plat_private_policy + ["com.android.sepolicy/33/*.te"],
354 installable: false,
355}
356
357se_policy_cil {
358 name: "apex_sepolicy-33.cil",
359 src: ":apex_sepolicy-33.conf",
360 filter_out: [":plat_sepolicy.cil"],
361 installable: false,
362 stem: "apex_sepolicy.cil",
363}
364
Inseob Kim6cc75f42021-04-29 13:53:20 +0000365// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
366se_policy_conf {
367 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900368 srcs: plat_public_policy +
369 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000370 build_variant: "userdebug",
371 installable: false,
372}
373
374se_policy_cil {
375 name: "userdebug_plat_sepolicy.cil",
376 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900377 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000378 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800379 dist: {
380 targets: ["droidcore"],
381 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000382}
383
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000384// A copy of the userdebug_plat_policy in GSI.
385soong_config_module_type {
386 name: "gsi_se_policy_cil",
387 module_type: "se_policy_cil",
388 config_namespace: "ANDROID",
389 bool_variables: [
390 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
391 ],
392 properties: [
393 "enabled",
394 "installable",
395 ],
396}
397
398gsi_se_policy_cil {
399 name: "system_ext_userdebug_plat_sepolicy.cil",
400 stem: "userdebug_plat_sepolicy.cil",
401 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900402 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000403 system_ext_specific: true,
404 enabled: false,
405 installable: false,
406 soong_config_variables: {
407 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
408 enabled: true,
409 installable: true,
410 },
411 },
412}
413
Inseob Kima49e7242021-03-22 10:26:13 +0900414// system_ext_policy.conf - A combination of the private and public system_ext
415// policy which will ship with the device. System_ext policy is not attributized
416se_policy_conf {
417 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900418 srcs: plat_public_policy +
419 plat_private_policy +
420 system_ext_public_policy +
421 system_ext_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900422 installable: false,
423}
424
425se_policy_cil {
426 name: "system_ext_sepolicy.cil",
427 src: ":system_ext_sepolicy.conf",
428 system_ext_specific: true,
429 filter_out: [":plat_sepolicy.cil"],
430 remove_line_marker: true,
431}
432
433// product_policy.conf - A combination of the private and public product policy
434// which will ship with the device. Product policy is not attributized
435se_policy_conf {
436 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900437 srcs: plat_public_policy +
438 plat_private_policy +
439 system_ext_public_policy +
440 system_ext_private_policy +
441 product_public_policy +
442 product_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900443 installable: false,
444}
445
446se_policy_cil {
447 name: "product_sepolicy.cil",
448 src: ":product_sepolicy.conf",
449 product_specific: true,
450 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
451 remove_line_marker: true,
452}
453
Inseob Kim039175b2021-03-25 15:37:34 +0900454// policy mapping files
455// auto-generate the mapping file for current platform policy, since it needs to
456// track platform policy development
457se_versioned_policy {
458 name: "plat_mapping_file",
459 base: ":plat_pub_policy.cil",
460 mapping: true,
461 version: "current",
462 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
463}
464
465se_versioned_policy {
466 name: "system_ext_mapping_file",
467 base: ":system_ext_pub_policy.cil",
468 mapping: true,
469 version: "current",
470 filter_out: [":plat_mapping_file"],
471 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
472 system_ext_specific: true,
473}
474
475se_versioned_policy {
476 name: "product_mapping_file",
477 base: ":pub_policy.cil",
478 mapping: true,
479 version: "current",
480 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
481 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
482 product_specific: true,
483}
484
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900485// vendor/odm sepolicy
486//
487// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
488// policy files of platform (system, system_ext, product) can't be mixed with
489// policy files of vendor (vendor, odm). If it's the case, platform policies and
490// vendor policies are separately built. More specifically,
491//
492// - Platform policy files needed to build vendor policies, such as plat_policy,
493// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
494// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
495//
496// - sepolicy_neverallows only checks platform policies, and a new module
497// sepolicy_neverallows_vendor checks vendor policies.
498//
499// - neverallow checks are turned off while compiling precompiled_sepolicy
500// module and sepolicy module.
501//
502// - Vendor policies are not checked on the compat test (compat.mk).
503//
504// In such scenario, we can grab platform policy files from the prebuilts/api
505// directory. But we need more than that: prebuilts of system_ext, product,
506// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
507// variables are introduced to specify such prebuilts.
508//
509// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
510// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
511// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
512// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
513// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
514// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
515//
516// Vendors are responsible for copying policy files from the old version of the
517// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
518// can be used to build vendor policies.
519//
520// To support both mixed build and normal build, platform policy files are
521// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
522// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
523// Otherwise, they will be equal to the Makefile variables above.
524
525plat_public_policies_for_vendor = [
526 ":se_build_files{.plat_public_for_vendor}",
527 ":se_build_files{.system_ext_public_for_vendor}",
528 ":se_build_files{.product_public_for_vendor}",
529 ":se_build_files{.reqd_mask_for_vendor}",
530]
531
532plat_policies_for_vendor = [
533 ":se_build_files{.plat_public_for_vendor}",
534 ":se_build_files{.plat_private_for_vendor}",
535 ":se_build_files{.system_ext_public_for_vendor}",
536 ":se_build_files{.system_ext_private_for_vendor}",
537 ":se_build_files{.product_public_for_vendor}",
538 ":se_build_files{.product_private_for_vendor}",
539]
540
541se_policy_conf {
542 name: "plat_policy_for_vendor.conf",
543 srcs: plat_policies_for_vendor,
544 installable: false,
545}
546
547se_policy_cil {
548 name: "plat_policy_for_vendor.cil",
549 src: ":plat_policy_for_vendor.conf",
550 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
551 installable: false,
552}
553
554se_policy_conf {
555 name: "reqd_policy_mask_for_vendor.conf",
556 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
557 installable: false,
558}
559
560se_policy_cil {
561 name: "reqd_policy_mask_for_vendor.cil",
562 src: ":reqd_policy_mask_for_vendor.conf",
563 secilc_check: false,
564 installable: false,
565}
566
567se_policy_conf {
568 name: "pub_policy_for_vendor.conf",
569 srcs: plat_public_policies_for_vendor,
570 installable: false,
571}
572
573se_policy_cil {
574 name: "pub_policy_for_vendor.cil",
575 src: ":pub_policy_for_vendor.conf",
576 filter_out: [":reqd_policy_mask_for_vendor.cil"],
577 secilc_check: false,
578 installable: false,
579}
580
581se_versioned_policy {
582 name: "plat_mapping_file_for_vendor",
583 base: ":pub_policy_for_vendor.cil",
584 mapping: true,
585 version: "vendor",
586 installable: false,
587}
588
Inseob Kim039175b2021-03-25 15:37:34 +0900589// plat_pub_versioned.cil - the exported platform policy associated with the version
590// that non-platform policy targets.
591se_versioned_policy {
592 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900593 base: ":pub_policy_for_vendor.cil",
594 target_policy: ":pub_policy_for_vendor.cil",
595 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900596 vendor: true,
597}
598
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900599// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
600// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
601// policy and the platform public policy files in order to use checkpolicy.
602se_policy_conf {
603 name: "vendor_sepolicy.conf",
604 srcs: plat_public_policies_for_vendor + [
605 ":se_build_files{.plat_vendor_for_vendor}",
606 ":se_build_files{.vendor}",
607 ],
608 installable: false,
609}
610
611se_policy_cil {
612 name: "vendor_sepolicy.cil.raw",
613 src: ":vendor_sepolicy.conf",
614 filter_out: [":reqd_policy_mask_for_vendor.cil"],
615 secilc_check: false, // will be done in se_versioned_policy module
616 installable: false,
617}
618
619se_versioned_policy {
620 name: "vendor_sepolicy.cil",
621 base: ":pub_policy_for_vendor.cil",
622 target_policy: ":vendor_sepolicy.cil.raw",
623 version: "vendor",
624 dependent_cils: [
625 ":plat_policy_for_vendor.cil",
626 ":plat_pub_versioned.cil",
627 ":plat_mapping_file_for_vendor",
628 ],
629 filter_out: [":plat_pub_versioned.cil"],
630 vendor: true,
631}
632
633// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
634// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
635// policy and the platform public policy files in order to use checkpolicy.
636se_policy_conf {
637 name: "odm_sepolicy.conf",
638 srcs: plat_public_policies_for_vendor + [
639 ":se_build_files{.plat_vendor_for_vendor}",
640 ":se_build_files{.vendor}",
641 ":se_build_files{.odm}",
642 ],
643 installable: false,
644}
645
646se_policy_cil {
647 name: "odm_sepolicy.cil.raw",
648 src: ":odm_sepolicy.conf",
649 filter_out: [
650 ":reqd_policy_mask_for_vendor.cil",
651 ":vendor_sepolicy.cil",
652 ],
653 secilc_check: false, // will be done in se_versioned_policy module
654 installable: false,
655}
656
657se_versioned_policy {
658 name: "odm_sepolicy.cil",
659 base: ":pub_policy_for_vendor.cil",
660 target_policy: ":odm_sepolicy.cil.raw",
661 version: "vendor",
662 dependent_cils: [
663 ":plat_policy_for_vendor.cil",
664 ":plat_pub_versioned.cil",
665 ":plat_mapping_file_for_vendor",
666 ":vendor_sepolicy.cil",
667 ],
668 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
669 device_specific: true,
670}
671
Inseob Kim039175b2021-03-25 15:37:34 +0900672//////////////////////////////////
673// Precompiled sepolicy is loaded if and only if:
674// - plat_sepolicy_and_mapping.sha256 equals
675// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
676// AND
677// - system_ext_sepolicy_and_mapping.sha256 equals
678// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
679// AND
680// - product_sepolicy_and_mapping.sha256 equals
681// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100682// AND
683// - apex_sepolicy.sha256 equals
684// precompiled_sepolicy.apex_sepolicy.sha256
Inseob Kim039175b2021-03-25 15:37:34 +0900685// See system/core/init/selinux.cpp for details.
686//////////////////////////////////
687genrule {
688 name: "plat_sepolicy_and_mapping.sha256_gen",
689 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
690 out: ["plat_sepolicy_and_mapping.sha256"],
691 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
692}
693
694prebuilt_etc {
695 name: "plat_sepolicy_and_mapping.sha256",
696 filename: "plat_sepolicy_and_mapping.sha256",
697 src: ":plat_sepolicy_and_mapping.sha256_gen",
698 relative_install_path: "selinux",
699}
700
701genrule {
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100702 name: "apex_sepolicy.sha256_gen",
703 srcs: [":apex_sepolicy-33.cil"],
704 out: ["apex_sepolicy.sha256"],
705 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
706}
707
708prebuilt_etc {
709 name: "apex_sepolicy.sha256",
710 filename: "apex_sepolicy.sha256",
711 src: ":apex_sepolicy.sha256_gen",
712 installable: false,
713}
714
715genrule {
Inseob Kim039175b2021-03-25 15:37:34 +0900716 name: "system_ext_sepolicy_and_mapping.sha256_gen",
717 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
718 out: ["system_ext_sepolicy_and_mapping.sha256"],
719 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
720}
721
722prebuilt_etc {
723 name: "system_ext_sepolicy_and_mapping.sha256",
724 filename: "system_ext_sepolicy_and_mapping.sha256",
725 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
726 relative_install_path: "selinux",
727 system_ext_specific: true,
728}
729
730genrule {
731 name: "product_sepolicy_and_mapping.sha256_gen",
732 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
733 out: ["product_sepolicy_and_mapping.sha256"],
734 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
735}
736
737prebuilt_etc {
738 name: "product_sepolicy_and_mapping.sha256",
739 filename: "product_sepolicy_and_mapping.sha256",
740 src: ":product_sepolicy_and_mapping.sha256_gen",
741 relative_install_path: "selinux",
742 product_specific: true,
743}
744
Inseob Kim1c056b12021-04-30 00:11:43 +0900745sepolicy_vers {
746 name: "plat_sepolicy_vers.txt",
747 version: "vendor",
748 vendor: true,
749}
750
Inseob Kim731182a2021-05-06 11:44:37 +0000751soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900752 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000753 module_type: "prebuilt_defaults",
754 config_namespace: "ANDROID",
755 bool_variables: ["BOARD_USES_ODMIMAGE"],
756 properties: ["vendor", "device_specific"],
757}
758
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900759precompiled_sepolicy_prebuilts_defaults {
760 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000761 soong_config_variables: {
762 BOARD_USES_ODMIMAGE: {
763 device_specific: true,
764 conditions_default: {
765 vendor: true,
766 },
767 },
768 },
769}
770
771//////////////////////////////////
772// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
773// which precompiled_policy was built.
774//////////////////////////////////
775prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900776 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000777 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
778 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
779 src: ":plat_sepolicy_and_mapping.sha256_gen",
780 relative_install_path: "selinux",
781}
782
783//////////////////////////////////
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100784// SHA-256 digest of the apex_sepolicy.cil against which precompiled_policy
785// was built.
786//////////////////////////////////
787prebuilt_etc {
788 defaults: ["precompiled_sepolicy_prebuilts"],
789 name: "precompiled_sepolicy.apex_sepolicy.sha256",
790 filename: "precompiled_sepolicy.apex_sepolicy.sha256",
791 src: ":apex_sepolicy.sha256_gen",
792 relative_install_path: "selinux",
793}
794
795//////////////////////////////////
Inseob Kim731182a2021-05-06 11:44:37 +0000796// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
797// which precompiled_policy was built.
798//////////////////////////////////
799prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900800 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000801 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
802 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
803 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
804 relative_install_path: "selinux",
805}
806
807//////////////////////////////////
808// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
809// which precompiled_policy was built.
810//////////////////////////////////
811prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900812 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000813 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
814 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
815 src: ":product_sepolicy_and_mapping.sha256_gen",
816 relative_install_path: "selinux",
817}
818
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900819soong_config_module_type {
820 name: "precompiled_se_policy_binary",
821 module_type: "se_policy_binary",
822 config_namespace: "ANDROID",
823 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
824 value_variables: ["MIXED_SEPOLICY_VERSION"],
825 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
826}
827
828precompiled_se_policy_binary {
829 name: "precompiled_sepolicy",
830 srcs: [
831 ":plat_sepolicy.cil",
Jeff Vander Stoepf9348b52021-12-14 13:32:12 +0100832 ":apex_sepolicy-33.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900833 ":plat_pub_versioned.cil",
834 ":system_ext_sepolicy.cil",
835 ":product_sepolicy.cil",
836 ":vendor_sepolicy.cil",
837 ":odm_sepolicy.cil",
838 ],
839 soong_config_variables: {
840 BOARD_USES_ODMIMAGE: {
841 device_specific: true,
842 conditions_default: {
843 vendor: true,
844 },
845 },
846 IS_TARGET_MIXED_SEPOLICY: {
847 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900848 },
849 MIXED_SEPOLICY_VERSION: {
850 srcs: [
851 ":plat_%s.cil",
852 ":system_ext_%s.cil",
853 ":product_%s.cil",
854 ],
855 conditions_default: {
856 srcs: [
857 ":plat_mapping_file",
858 ":system_ext_mapping_file",
859 ":product_mapping_file",
860 ],
861 },
862 },
863 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900864 required: [
865 "sepolicy_neverallows",
866 "sepolicy_neverallows_vendor",
867 ],
Inseob Kimeec39192022-01-21 11:47:54 +0900868 dist: {
869 targets: ["base-sepolicy-files-for-mapping"],
870 },
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900871}
Inseob Kim731182a2021-05-06 11:44:37 +0000872
Inseob Kim5bbcd682021-12-28 14:57:03 +0900873// policy for recovery
874se_policy_conf {
875 name: "recovery_sepolicy.conf",
876 srcs: plat_policies_for_vendor + [
877 ":se_build_files{.plat_vendor_for_vendor}",
878 ":se_build_files{.vendor}",
879 ":se_build_files{.odm}",
880 ],
881 target_recovery: true,
882 installable: false,
883}
884
885se_policy_cil {
886 name: "recovery_sepolicy.cil",
887 src: ":recovery_sepolicy.conf",
888 secilc_check: false, // will be done in se_policy_binary module
889 installable: false,
890}
891
892se_policy_binary {
893 name: "sepolicy.recovery",
894 srcs: [":recovery_sepolicy.cil"],
895 stem: "sepolicy",
896 recovery: true,
897}
898
Inseob Kima49e7242021-03-22 10:26:13 +0900899//////////////////////////////////
900// SELinux policy embedded into CTS.
901// CTS checks neverallow rules of this policy against the policy of the device under test.
902//////////////////////////////////
903se_policy_conf {
904 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900905 srcs: plat_public_policy +
906 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900907 build_variant: "user",
908 cts: true,
909 exclude_build_test: true,
910}
Inseob Kimd5816612021-09-15 03:01:05 +0000911
912//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000913// Base system policy for treble sepolicy tests.
914// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
915// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
916// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
917// See treble_sepolicy_tests_for_release.mk for more details.
918//////////////////////////////////
919se_policy_conf {
920 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900921 srcs: plat_public_policy +
922 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000923 build_variant: "user",
924 installable: false,
925}
926
927se_policy_cil {
928 name: "base_plat_sepolicy.cil",
929 src: ":base_plat_sepolicy.conf",
930 additional_cil_files: ["private/technical_debt.cil"],
931 installable: false,
932 secilc_check: false, // done by se_policy_binary
933}
934
935se_policy_binary {
936 name: "base_plat_sepolicy",
937 srcs: [":base_plat_sepolicy.cil"],
938 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +0900939 dist: {
940 targets: ["base-sepolicy-files-for-mapping"],
941 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000942}
943
944se_policy_conf {
945 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900946 srcs: plat_public_policy +
947 plat_private_policy +
948 system_ext_public_policy +
949 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000950 build_variant: "user",
951 installable: false,
952}
953
954se_policy_cil {
955 name: "base_system_ext_sepolicy.cil",
956 src: ":base_system_ext_sepolicy.conf",
957 additional_cil_files: ["private/technical_debt.cil"],
958 system_ext_specific: true,
959 installable: false,
960 secilc_check: false, // done by se_policy_binary
961}
962
963se_policy_binary {
964 name: "base_system_ext_sepolicy",
965 srcs: [":base_system_ext_sepolicy.cil"],
966 system_ext_specific: true,
967 installable: false,
968}
969
970se_policy_conf {
971 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900972 srcs: plat_public_policy +
973 plat_private_policy +
974 system_ext_public_policy +
975 system_ext_private_policy +
976 product_public_policy +
977 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000978 build_variant: "user",
979 installable: false,
980}
981
982se_policy_cil {
983 name: "base_product_sepolicy.cil",
984 src: ":base_product_sepolicy.conf",
985 additional_cil_files: ["private/technical_debt.cil"],
986 product_specific: true,
987 installable: false,
988 secilc_check: false, // done by se_policy_binary
989}
990
991se_policy_binary {
992 name: "base_product_sepolicy",
993 srcs: [":base_product_sepolicy.cil"],
994 product_specific: true,
995 installable: false,
996}
997
998se_policy_conf {
999 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001000 srcs: plat_public_policy +
1001 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001002 build_variant: "user",
1003 installable: false,
1004}
1005
1006se_policy_cil {
1007 name: "base_plat_pub_policy.cil",
1008 src: ":base_plat_pub_policy.conf",
1009 filter_out: [":reqd_policy_mask.cil"],
1010 secilc_check: false,
1011 installable: false,
Inseob Kimeec39192022-01-21 11:47:54 +09001012 dist: {
1013 targets: ["base-sepolicy-files-for-mapping"],
1014 },
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001015}
1016
1017se_policy_conf {
1018 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001019 srcs: plat_public_policy +
1020 system_ext_public_policy +
1021 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001022 build_variant: "user",
1023 installable: false,
1024}
1025
1026se_policy_cil {
1027 name: "base_system_ext_pub_policy.cil",
1028 src: ":base_system_ext_pub_policy.conf",
1029 filter_out: [":reqd_policy_mask.cil"],
1030 secilc_check: false,
1031 installable: false,
1032}
1033
1034se_policy_conf {
1035 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +09001036 srcs: plat_public_policy +
1037 system_ext_public_policy +
1038 product_public_policy +
1039 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001040 build_variant: "user",
1041 installable: false,
1042}
1043
1044se_policy_cil {
1045 name: "base_product_pub_policy.cil",
1046 src: ":base_product_pub_policy.conf",
1047 filter_out: [":reqd_policy_mask.cil"],
1048 secilc_check: false,
1049 installable: false,
1050}
1051
Yi-Yo Chiang2c189652021-11-08 19:30:04 +08001052// bug_map - Bug tracking information for selinux denials loaded by auditd.
1053se_filegroup {
1054 name: "bug_map_files",
1055 srcs: ["bug_map"],
1056}
1057
1058se_bug_map {
1059 name: "plat_bug_map",
1060 srcs: [":bug_map_files"],
1061 stem: "bug_map",
1062}
1063
1064se_bug_map {
1065 name: "system_ext_bug_map",
1066 srcs: [":bug_map_files"],
1067 stem: "bug_map",
1068 system_ext_specific: true,
1069}
1070
1071se_bug_map {
1072 name: "vendor_bug_map",
1073 srcs: [":bug_map_files"],
1074 // Legacy file name of the vendor partition bug_map.
1075 stem: "selinux_denial_metadata",
1076 vendor: true,
1077}
1078
Inseob Kim0de7fcc2021-12-22 23:06:53 +09001079se_neverallow_test {
1080 name: "sepolicy_neverallows",
1081 srcs: plat_public_policy +
1082 plat_private_policy +
1083 system_ext_public_policy +
1084 system_ext_private_policy +
1085 product_public_policy +
1086 product_private_policy,
1087}
1088
1089se_neverallow_test {
1090 name: "sepolicy_neverallows_vendor",
1091 srcs: plat_policies_for_vendor + [
1092 ":se_build_files{.plat_vendor_for_vendor}",
1093 ":se_build_files{.vendor}",
1094 ":se_build_files{.odm}",
1095 ],
1096}
1097
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001098//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001099// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1100// Additional directories can be specified via Makefile variables:
1101// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1102//////////////////////////////////
1103se_freeze_test {
1104 name: "sepolicy_freeze_test",
1105}
Inseob Kim61257ca2022-02-25 11:26:16 +09001106
1107//////////////////////////////////
1108// sepolicy_test checks various types of violations, which can't be easily done
1109// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
1110//////////////////////////////////
1111genrule {
1112 name: "sepolicy_test",
1113 srcs: [
1114 ":plat_file_contexts",
1115 ":vendor_file_contexts",
1116 ":system_ext_file_contexts",
1117 ":product_file_contexts",
1118 ":odm_file_contexts",
1119 ":precompiled_sepolicy",
1120 ],
1121 tools: ["sepolicy_tests"],
1122 out: ["sepolicy_test"],
1123 cmd: "$(location sepolicy_tests) " +
1124 "-f $(location :plat_file_contexts) " +
1125 "-f $(location :vendor_file_contexts) " +
1126 "-f $(location :system_ext_file_contexts) " +
1127 "-f $(location :product_file_contexts) " +
1128 "-f $(location :odm_file_contexts) " +
1129 "-p $(location :precompiled_sepolicy) && " +
1130 "touch $(out)",
1131}