blob: 874e96f3ab1231df0d928cc54024c0c7fe185a5f [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
yangbill3e345372020-04-15 13:55:47 +0800187// For vts_treble_sys_prop_test
188filegroup {
189 name: "private_property_contexts",
190 srcs: ["private/property_contexts"],
191 visibility: [
192 "//test/vts-testcase/security/system_property",
193 ],
194}
Inseob Kime35b49b2021-02-18 19:15:41 +0900195
Inseob Kima49e7242021-03-22 10:26:13 +0900196se_build_files {
197 name: "se_build_files",
Inseob Kime35b49b2021-02-18 19:15:41 +0900198 srcs: [
Inseob Kima49e7242021-03-22 10:26:13 +0900199 "security_classes",
200 "initial_sids",
201 "access_vectors",
202 "global_macros",
203 "neverallow_macros",
204 "mls_macros",
205 "mls_decl",
206 "mls",
207 "policy_capabilities",
208 "te_macros",
209 "attributes",
210 "ioctl_defines",
211 "ioctl_macros",
212 "*.te",
213 "roles_decl",
214 "roles",
215 "users",
216 "initial_sid_contexts",
217 "fs_use",
218 "genfs_contexts",
219 "port_contexts",
Inseob Kime35b49b2021-02-18 19:15:41 +0900220 ],
221}
222
Inseob Kim7cb20812021-12-16 16:52:14 +0900223se_build_files {
224 name: "sepolicy_technical_debt",
225 srcs: ["technical_debt.cil"],
226}
227
Inseob Kim0a707fa2021-12-09 23:35:11 +0900228reqd_mask_policy = [":se_build_files{.reqd_mask}"]
229plat_public_policy = [":se_build_files{.plat_public}"]
230plat_private_policy = [":se_build_files{.plat_private}"]
231system_ext_public_policy = [":se_build_files{.system_ext_public}"]
232system_ext_private_policy = [":se_build_files{.system_ext_private}"]
233product_public_policy = [":se_build_files{.product_public}"]
234product_private_policy = [":se_build_files{.product_private}"]
235
Inseob Kima49e7242021-03-22 10:26:13 +0900236// reqd_policy_mask - a policy.conf file which contains only the bare minimum
237// policy necessary to use checkpolicy.
238//
239// This bare-minimum policy needs to be present in all policy.conf files, but
240// should not necessarily be exported as part of the public policy.
241//
242// The rules generated by reqd_policy_mask will allow the compilation of public
243// policy and subsequent removal of CIL policy that should not be exported.
244se_policy_conf {
245 name: "reqd_policy_mask.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900246 srcs: reqd_mask_policy,
Inseob Kime35b49b2021-02-18 19:15:41 +0900247 installable: false,
248}
249
Inseob Kima49e7242021-03-22 10:26:13 +0900250se_policy_cil {
251 name: "reqd_policy_mask.cil",
252 src: ":reqd_policy_mask.conf",
253 secilc_check: false,
254 installable: false,
Inseob Kime35b49b2021-02-18 19:15:41 +0900255}
256
Inseob Kima49e7242021-03-22 10:26:13 +0900257// pub_policy - policy that will be exported to be a part of non-platform
258// policy corresponding to this platform version.
259//
260// This is a limited subset of policy that would not compile in checkpolicy on
261// its own.
262//
263// To get around this limitation, add only the required files from private
264// policy, which will generate CIL policy that will then be filtered out by the
265// reqd_policy_mask.
266//
267// There are three pub_policy.cil files below:
268// - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
269// - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
270// - plat_pub_policy.cil: exported 'system' policy.
271//
272// Those above files will in turn be used to generate the following versioned cil files:
273// - product_mapping_file: the versioned, exported 'product' policy in product partition.
274// - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
275// - plat_mapping_file: the versioned, exported 'system' policy in system partition.
276// - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
277// in vendor partition.
278//
279se_policy_conf {
280 name: "pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900281 srcs: plat_public_policy +
282 system_ext_public_policy +
283 product_public_policy +
284 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900285 installable: false,
286}
287
288se_policy_cil {
289 name: "pub_policy.cil",
290 src: ":pub_policy.conf",
291 filter_out: [":reqd_policy_mask.cil"],
292 secilc_check: false,
293 installable: false,
294}
295
296se_policy_conf {
297 name: "system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900298 srcs: plat_public_policy +
299 system_ext_public_policy +
300 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900301 installable: false,
302}
303
304se_policy_cil {
305 name: "system_ext_pub_policy.cil",
306 src: ":system_ext_pub_policy.conf",
307 filter_out: [":reqd_policy_mask.cil"],
308 secilc_check: false,
309 installable: false,
310}
311
312se_policy_conf {
313 name: "plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900314 srcs: plat_public_policy +
315 reqd_mask_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900316 installable: false,
317}
318
319se_policy_cil {
320 name: "plat_pub_policy.cil",
321 src: ":plat_pub_policy.conf",
322 filter_out: [":reqd_policy_mask.cil"],
323 secilc_check: false,
324 installable: false,
325}
326
327// plat_policy.conf - A combination of the private and public platform policy
328// which will ship with the device.
329//
330// The platform will always reflect the most recent platform version and is not
331// currently being attributized.
332se_policy_conf {
333 name: "plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900334 srcs: plat_public_policy +
335 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900336 installable: false,
337}
338
339se_policy_cil {
340 name: "plat_sepolicy.cil",
341 src: ":plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900342 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kima49e7242021-03-22 10:26:13 +0900343}
344
Inseob Kim6cc75f42021-04-29 13:53:20 +0000345// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
346se_policy_conf {
347 name: "userdebug_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900348 srcs: plat_public_policy +
349 plat_private_policy,
Inseob Kim6cc75f42021-04-29 13:53:20 +0000350 build_variant: "userdebug",
351 installable: false,
352}
353
354se_policy_cil {
355 name: "userdebug_plat_sepolicy.cil",
356 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900357 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Inseob Kim6cc75f42021-04-29 13:53:20 +0000358 debug_ramdisk: true,
Yi-Yo Chiang68478b12021-10-16 03:23:05 +0800359 dist: {
360 targets: ["droidcore"],
361 },
Inseob Kim6cc75f42021-04-29 13:53:20 +0000362}
363
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000364// A copy of the userdebug_plat_policy in GSI.
365soong_config_module_type {
366 name: "gsi_se_policy_cil",
367 module_type: "se_policy_cil",
368 config_namespace: "ANDROID",
369 bool_variables: [
370 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
371 ],
372 properties: [
373 "enabled",
374 "installable",
375 ],
376}
377
378gsi_se_policy_cil {
379 name: "system_ext_userdebug_plat_sepolicy.cil",
380 stem: "userdebug_plat_sepolicy.cil",
381 src: ":userdebug_plat_sepolicy.conf",
Inseob Kim7cb20812021-12-16 16:52:14 +0900382 additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
Yi-Yo Chiang857ffc42021-09-23 14:14:16 +0000383 system_ext_specific: true,
384 enabled: false,
385 installable: false,
386 soong_config_variables: {
387 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
388 enabled: true,
389 installable: true,
390 },
391 },
392}
393
Inseob Kima49e7242021-03-22 10:26:13 +0900394// system_ext_policy.conf - A combination of the private and public system_ext
395// policy which will ship with the device. System_ext policy is not attributized
396se_policy_conf {
397 name: "system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900398 srcs: plat_public_policy +
399 plat_private_policy +
400 system_ext_public_policy +
401 system_ext_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900402 installable: false,
403}
404
405se_policy_cil {
406 name: "system_ext_sepolicy.cil",
407 src: ":system_ext_sepolicy.conf",
408 system_ext_specific: true,
409 filter_out: [":plat_sepolicy.cil"],
410 remove_line_marker: true,
411}
412
413// product_policy.conf - A combination of the private and public product policy
414// which will ship with the device. Product policy is not attributized
415se_policy_conf {
416 name: "product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900417 srcs: plat_public_policy +
418 plat_private_policy +
419 system_ext_public_policy +
420 system_ext_private_policy +
421 product_public_policy +
422 product_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900423 installable: false,
424}
425
426se_policy_cil {
427 name: "product_sepolicy.cil",
428 src: ":product_sepolicy.conf",
429 product_specific: true,
430 filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"],
431 remove_line_marker: true,
432}
433
Inseob Kim039175b2021-03-25 15:37:34 +0900434// policy mapping files
435// auto-generate the mapping file for current platform policy, since it needs to
436// track platform policy development
437se_versioned_policy {
438 name: "plat_mapping_file",
439 base: ":plat_pub_policy.cil",
440 mapping: true,
441 version: "current",
442 relative_install_path: "mapping", // install to /system/etc/selinux/mapping
443}
444
445se_versioned_policy {
446 name: "system_ext_mapping_file",
447 base: ":system_ext_pub_policy.cil",
448 mapping: true,
449 version: "current",
450 filter_out: [":plat_mapping_file"],
451 relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
452 system_ext_specific: true,
453}
454
455se_versioned_policy {
456 name: "product_mapping_file",
457 base: ":pub_policy.cil",
458 mapping: true,
459 version: "current",
460 filter_out: [":plat_mapping_file", ":system_ext_mapping_file"],
461 relative_install_path: "mapping", // install to /product/etc/selinux/mapping
462 product_specific: true,
463}
464
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900465// vendor/odm sepolicy
466//
467// If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION,
468// policy files of platform (system, system_ext, product) can't be mixed with
469// policy files of vendor (vendor, odm). If it's the case, platform policies and
470// vendor policies are separately built. More specifically,
471//
472// - Platform policy files needed to build vendor policies, such as plat_policy,
473// plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the
474// prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS).
475//
476// - sepolicy_neverallows only checks platform policies, and a new module
477// sepolicy_neverallows_vendor checks vendor policies.
478//
479// - neverallow checks are turned off while compiling precompiled_sepolicy
480// module and sepolicy module.
481//
482// - Vendor policies are not checked on the compat test (compat.mk).
483//
484// In such scenario, we can grab platform policy files from the prebuilts/api
485// directory. But we need more than that: prebuilts of system_ext, product,
486// system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following
487// variables are introduced to specify such prebuilts.
488//
489// - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask)
490// - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor)
491// - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public)
492// - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private)
493// - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public)
494// - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private)
495//
496// Vendors are responsible for copying policy files from the old version of the
497// source tree as prebuilts, and for setting BOARD_*_POLICY variables so they
498// can be used to build vendor policies.
499//
500// To support both mixed build and normal build, platform policy files are
501// indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal
502// to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION.
503// Otherwise, they will be equal to the Makefile variables above.
504
505plat_public_policies_for_vendor = [
506 ":se_build_files{.plat_public_for_vendor}",
507 ":se_build_files{.system_ext_public_for_vendor}",
508 ":se_build_files{.product_public_for_vendor}",
509 ":se_build_files{.reqd_mask_for_vendor}",
510]
511
512plat_policies_for_vendor = [
513 ":se_build_files{.plat_public_for_vendor}",
514 ":se_build_files{.plat_private_for_vendor}",
515 ":se_build_files{.system_ext_public_for_vendor}",
516 ":se_build_files{.system_ext_private_for_vendor}",
517 ":se_build_files{.product_public_for_vendor}",
518 ":se_build_files{.product_private_for_vendor}",
519]
520
521se_policy_conf {
522 name: "plat_policy_for_vendor.conf",
523 srcs: plat_policies_for_vendor,
524 installable: false,
525}
526
527se_policy_cil {
528 name: "plat_policy_for_vendor.cil",
529 src: ":plat_policy_for_vendor.conf",
530 additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"],
531 installable: false,
532}
533
534se_policy_conf {
535 name: "reqd_policy_mask_for_vendor.conf",
536 srcs: [":se_build_files{.reqd_mask_for_vendor}"],
537 installable: false,
538}
539
540se_policy_cil {
541 name: "reqd_policy_mask_for_vendor.cil",
542 src: ":reqd_policy_mask_for_vendor.conf",
543 secilc_check: false,
544 installable: false,
545}
546
547se_policy_conf {
548 name: "pub_policy_for_vendor.conf",
549 srcs: plat_public_policies_for_vendor,
550 installable: false,
551}
552
553se_policy_cil {
554 name: "pub_policy_for_vendor.cil",
555 src: ":pub_policy_for_vendor.conf",
556 filter_out: [":reqd_policy_mask_for_vendor.cil"],
557 secilc_check: false,
558 installable: false,
559}
560
561se_versioned_policy {
562 name: "plat_mapping_file_for_vendor",
563 base: ":pub_policy_for_vendor.cil",
564 mapping: true,
565 version: "vendor",
566 installable: false,
567}
568
Inseob Kim039175b2021-03-25 15:37:34 +0900569// plat_pub_versioned.cil - the exported platform policy associated with the version
570// that non-platform policy targets.
571se_versioned_policy {
572 name: "plat_pub_versioned.cil",
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900573 base: ":pub_policy_for_vendor.cil",
574 target_policy: ":pub_policy_for_vendor.cil",
575 version: "vendor",
Inseob Kim039175b2021-03-25 15:37:34 +0900576 vendor: true,
577}
578
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900579// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
580// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
581// policy and the platform public policy files in order to use checkpolicy.
582se_policy_conf {
583 name: "vendor_sepolicy.conf",
584 srcs: plat_public_policies_for_vendor + [
585 ":se_build_files{.plat_vendor_for_vendor}",
586 ":se_build_files{.vendor}",
587 ],
588 installable: false,
589}
590
591se_policy_cil {
592 name: "vendor_sepolicy.cil.raw",
593 src: ":vendor_sepolicy.conf",
594 filter_out: [":reqd_policy_mask_for_vendor.cil"],
595 secilc_check: false, // will be done in se_versioned_policy module
596 installable: false,
597}
598
599se_versioned_policy {
600 name: "vendor_sepolicy.cil",
601 base: ":pub_policy_for_vendor.cil",
602 target_policy: ":vendor_sepolicy.cil.raw",
603 version: "vendor",
604 dependent_cils: [
605 ":plat_policy_for_vendor.cil",
606 ":plat_pub_versioned.cil",
607 ":plat_mapping_file_for_vendor",
608 ],
609 filter_out: [":plat_pub_versioned.cil"],
610 vendor: true,
611}
612
613// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
614// with the platform-provided policy. It makes use of the reqd_policy_mask files from private
615// policy and the platform public policy files in order to use checkpolicy.
616se_policy_conf {
617 name: "odm_sepolicy.conf",
618 srcs: plat_public_policies_for_vendor + [
619 ":se_build_files{.plat_vendor_for_vendor}",
620 ":se_build_files{.vendor}",
621 ":se_build_files{.odm}",
622 ],
623 installable: false,
624}
625
626se_policy_cil {
627 name: "odm_sepolicy.cil.raw",
628 src: ":odm_sepolicy.conf",
629 filter_out: [
630 ":reqd_policy_mask_for_vendor.cil",
631 ":vendor_sepolicy.cil",
632 ],
633 secilc_check: false, // will be done in se_versioned_policy module
634 installable: false,
635}
636
637se_versioned_policy {
638 name: "odm_sepolicy.cil",
639 base: ":pub_policy_for_vendor.cil",
640 target_policy: ":odm_sepolicy.cil.raw",
641 version: "vendor",
642 dependent_cils: [
643 ":plat_policy_for_vendor.cil",
644 ":plat_pub_versioned.cil",
645 ":plat_mapping_file_for_vendor",
646 ":vendor_sepolicy.cil",
647 ],
648 filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"],
649 device_specific: true,
650}
651
Inseob Kim039175b2021-03-25 15:37:34 +0900652//////////////////////////////////
653// Precompiled sepolicy is loaded if and only if:
654// - plat_sepolicy_and_mapping.sha256 equals
655// precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
656// AND
657// - system_ext_sepolicy_and_mapping.sha256 equals
658// precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
659// AND
660// - product_sepolicy_and_mapping.sha256 equals
661// precompiled_sepolicy.product_sepolicy_and_mapping.sha256
662// See system/core/init/selinux.cpp for details.
663//////////////////////////////////
664genrule {
665 name: "plat_sepolicy_and_mapping.sha256_gen",
666 srcs: [":plat_sepolicy.cil", ":plat_mapping_file"],
667 out: ["plat_sepolicy_and_mapping.sha256"],
668 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
669}
670
671prebuilt_etc {
672 name: "plat_sepolicy_and_mapping.sha256",
673 filename: "plat_sepolicy_and_mapping.sha256",
674 src: ":plat_sepolicy_and_mapping.sha256_gen",
675 relative_install_path: "selinux",
676}
677
678genrule {
679 name: "system_ext_sepolicy_and_mapping.sha256_gen",
680 srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"],
681 out: ["system_ext_sepolicy_and_mapping.sha256"],
682 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
683}
684
685prebuilt_etc {
686 name: "system_ext_sepolicy_and_mapping.sha256",
687 filename: "system_ext_sepolicy_and_mapping.sha256",
688 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
689 relative_install_path: "selinux",
690 system_ext_specific: true,
691}
692
693genrule {
694 name: "product_sepolicy_and_mapping.sha256_gen",
695 srcs: [":product_sepolicy.cil", ":product_mapping_file"],
696 out: ["product_sepolicy_and_mapping.sha256"],
697 cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
698}
699
700prebuilt_etc {
701 name: "product_sepolicy_and_mapping.sha256",
702 filename: "product_sepolicy_and_mapping.sha256",
703 src: ":product_sepolicy_and_mapping.sha256_gen",
704 relative_install_path: "selinux",
705 product_specific: true,
706}
707
Inseob Kim1c056b12021-04-30 00:11:43 +0900708sepolicy_vers {
709 name: "plat_sepolicy_vers.txt",
710 version: "vendor",
711 vendor: true,
712}
713
Inseob Kim731182a2021-05-06 11:44:37 +0000714soong_config_module_type {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900715 name: "precompiled_sepolicy_prebuilts_defaults",
Inseob Kim731182a2021-05-06 11:44:37 +0000716 module_type: "prebuilt_defaults",
717 config_namespace: "ANDROID",
718 bool_variables: ["BOARD_USES_ODMIMAGE"],
719 properties: ["vendor", "device_specific"],
720}
721
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900722precompiled_sepolicy_prebuilts_defaults {
723 name: "precompiled_sepolicy_prebuilts",
Inseob Kim731182a2021-05-06 11:44:37 +0000724 soong_config_variables: {
725 BOARD_USES_ODMIMAGE: {
726 device_specific: true,
727 conditions_default: {
728 vendor: true,
729 },
730 },
731 },
732}
733
734//////////////////////////////////
735// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
736// which precompiled_policy was built.
737//////////////////////////////////
738prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900739 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000740 name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
741 filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
742 src: ":plat_sepolicy_and_mapping.sha256_gen",
743 relative_install_path: "selinux",
744}
745
746//////////////////////////////////
747// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
748// which precompiled_policy was built.
749//////////////////////////////////
750prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900751 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000752 name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
753 filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
754 src: ":system_ext_sepolicy_and_mapping.sha256_gen",
755 relative_install_path: "selinux",
756}
757
758//////////////////////////////////
759// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
760// which precompiled_policy was built.
761//////////////////////////////////
762prebuilt_etc {
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900763 defaults: ["precompiled_sepolicy_prebuilts"],
Inseob Kim731182a2021-05-06 11:44:37 +0000764 name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
765 filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
766 src: ":product_sepolicy_and_mapping.sha256_gen",
767 relative_install_path: "selinux",
768}
769
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900770soong_config_module_type {
771 name: "precompiled_se_policy_binary",
772 module_type: "se_policy_binary",
773 config_namespace: "ANDROID",
774 bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"],
775 value_variables: ["MIXED_SEPOLICY_VERSION"],
776 properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"],
777}
778
779precompiled_se_policy_binary {
780 name: "precompiled_sepolicy",
781 srcs: [
782 ":plat_sepolicy.cil",
783 ":plat_pub_versioned.cil",
784 ":system_ext_sepolicy.cil",
785 ":product_sepolicy.cil",
786 ":vendor_sepolicy.cil",
787 ":odm_sepolicy.cil",
788 ],
789 soong_config_variables: {
790 BOARD_USES_ODMIMAGE: {
791 device_specific: true,
792 conditions_default: {
793 vendor: true,
794 },
795 },
796 IS_TARGET_MIXED_SEPOLICY: {
797 ignore_neverallow: true,
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900798 },
799 MIXED_SEPOLICY_VERSION: {
800 srcs: [
801 ":plat_%s.cil",
802 ":system_ext_%s.cil",
803 ":product_%s.cil",
804 ],
805 conditions_default: {
806 srcs: [
807 ":plat_mapping_file",
808 ":system_ext_mapping_file",
809 ":product_mapping_file",
810 ],
811 },
812 },
813 },
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900814 required: [
815 "sepolicy_neverallows",
816 "sepolicy_neverallows_vendor",
817 ],
Inseob Kim3ac62fe2021-12-16 19:00:03 +0900818}
Inseob Kim731182a2021-05-06 11:44:37 +0000819
Inseob Kima49e7242021-03-22 10:26:13 +0900820//////////////////////////////////
821// SELinux policy embedded into CTS.
822// CTS checks neverallow rules of this policy against the policy of the device under test.
823//////////////////////////////////
824se_policy_conf {
825 name: "general_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900826 srcs: plat_public_policy +
827 plat_private_policy,
Inseob Kima49e7242021-03-22 10:26:13 +0900828 build_variant: "user",
829 cts: true,
830 exclude_build_test: true,
831}
Inseob Kimd5816612021-09-15 03:01:05 +0000832
833//////////////////////////////////
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000834// Base system policy for treble sepolicy tests.
835// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
836// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
837// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
838// See treble_sepolicy_tests_for_release.mk for more details.
839//////////////////////////////////
840se_policy_conf {
841 name: "base_plat_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900842 srcs: plat_public_policy +
843 plat_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000844 build_variant: "user",
845 installable: false,
846}
847
848se_policy_cil {
849 name: "base_plat_sepolicy.cil",
850 src: ":base_plat_sepolicy.conf",
851 additional_cil_files: ["private/technical_debt.cil"],
852 installable: false,
853 secilc_check: false, // done by se_policy_binary
854}
855
856se_policy_binary {
857 name: "base_plat_sepolicy",
858 srcs: [":base_plat_sepolicy.cil"],
859 installable: false,
860}
861
862se_policy_conf {
863 name: "base_system_ext_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900864 srcs: plat_public_policy +
865 plat_private_policy +
866 system_ext_public_policy +
867 system_ext_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000868 build_variant: "user",
869 installable: false,
870}
871
872se_policy_cil {
873 name: "base_system_ext_sepolicy.cil",
874 src: ":base_system_ext_sepolicy.conf",
875 additional_cil_files: ["private/technical_debt.cil"],
876 system_ext_specific: true,
877 installable: false,
878 secilc_check: false, // done by se_policy_binary
879}
880
881se_policy_binary {
882 name: "base_system_ext_sepolicy",
883 srcs: [":base_system_ext_sepolicy.cil"],
884 system_ext_specific: true,
885 installable: false,
886}
887
888se_policy_conf {
889 name: "base_product_sepolicy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900890 srcs: plat_public_policy +
891 plat_private_policy +
892 system_ext_public_policy +
893 system_ext_private_policy +
894 product_public_policy +
895 product_private_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000896 build_variant: "user",
897 installable: false,
898}
899
900se_policy_cil {
901 name: "base_product_sepolicy.cil",
902 src: ":base_product_sepolicy.conf",
903 additional_cil_files: ["private/technical_debt.cil"],
904 product_specific: true,
905 installable: false,
906 secilc_check: false, // done by se_policy_binary
907}
908
909se_policy_binary {
910 name: "base_product_sepolicy",
911 srcs: [":base_product_sepolicy.cil"],
912 product_specific: true,
913 installable: false,
914}
915
916se_policy_conf {
917 name: "base_plat_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900918 srcs: plat_public_policy +
919 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000920 build_variant: "user",
921 installable: false,
922}
923
924se_policy_cil {
925 name: "base_plat_pub_policy.cil",
926 src: ":base_plat_pub_policy.conf",
927 filter_out: [":reqd_policy_mask.cil"],
928 secilc_check: false,
929 installable: false,
930}
931
932se_policy_conf {
933 name: "base_system_ext_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900934 srcs: plat_public_policy +
935 system_ext_public_policy +
936 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000937 build_variant: "user",
938 installable: false,
939}
940
941se_policy_cil {
942 name: "base_system_ext_pub_policy.cil",
943 src: ":base_system_ext_pub_policy.conf",
944 filter_out: [":reqd_policy_mask.cil"],
945 secilc_check: false,
946 installable: false,
947}
948
949se_policy_conf {
950 name: "base_product_pub_policy.conf",
Inseob Kim0a707fa2021-12-09 23:35:11 +0900951 srcs: plat_public_policy +
952 system_ext_public_policy +
953 product_public_policy +
954 reqd_mask_policy,
Inseob Kim4d90b7e2021-09-27 13:43:01 +0000955 build_variant: "user",
956 installable: false,
957}
958
959se_policy_cil {
960 name: "base_product_pub_policy.cil",
961 src: ":base_product_pub_policy.conf",
962 filter_out: [":reqd_policy_mask.cil"],
963 secilc_check: false,
964 installable: false,
965}
966
Yi-Yo Chiang2c189652021-11-08 19:30:04 +0800967// bug_map - Bug tracking information for selinux denials loaded by auditd.
968se_filegroup {
969 name: "bug_map_files",
970 srcs: ["bug_map"],
971}
972
973se_bug_map {
974 name: "plat_bug_map",
975 srcs: [":bug_map_files"],
976 stem: "bug_map",
977}
978
979se_bug_map {
980 name: "system_ext_bug_map",
981 srcs: [":bug_map_files"],
982 stem: "bug_map",
983 system_ext_specific: true,
984}
985
986se_bug_map {
987 name: "vendor_bug_map",
988 srcs: [":bug_map_files"],
989 // Legacy file name of the vendor partition bug_map.
990 stem: "selinux_denial_metadata",
991 vendor: true,
992}
993
Inseob Kim0de7fcc2021-12-22 23:06:53 +0900994se_neverallow_test {
995 name: "sepolicy_neverallows",
996 srcs: plat_public_policy +
997 plat_private_policy +
998 system_ext_public_policy +
999 system_ext_private_policy +
1000 product_public_policy +
1001 product_private_policy,
1002}
1003
1004se_neverallow_test {
1005 name: "sepolicy_neverallows_vendor",
1006 srcs: plat_policies_for_vendor + [
1007 ":se_build_files{.plat_vendor_for_vendor}",
1008 ":se_build_files{.vendor}",
1009 ":se_build_files{.odm}",
1010 ],
1011}
1012
Inseob Kim4d90b7e2021-09-27 13:43:01 +00001013//////////////////////////////////
Inseob Kimd5816612021-09-15 03:01:05 +00001014// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
1015// Additional directories can be specified via Makefile variables:
1016// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
1017//////////////////////////////////
1018se_freeze_test {
1019 name: "sepolicy_freeze_test",
1020}
Yuntao Xu42e732c2021-11-18 22:33:02 +00001021
1022//////////////////////////////////
1023// Makefile rules temporary imported to Soong
1024// TODO(b/33691272): remove these after migrating seapp to Soong
1025//////////////////////////////////
1026makefile_goal {
1027 name: "plat_seapp_contexts_rule",
1028 product_out_path: "obj/ETC/plat_seapp_contexts_intermediates/plat_seapp_contexts",
1029}
1030
1031makefile_goal {
1032 name: "plat_seapp_neverallows_rule",
1033 product_out_path: "obj/ETC/plat_seapp_neverallows_intermediates/plat_seapp_neverallows",
1034}