blob: 55951e218267162be8b3555563c38d95b7b33cfc [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 {
48 name: "26.0.board.compat.map",
49 srcs: [
50 "compat/26.0/26.0.cil",
51 ],
52}
53
54se_filegroup {
55 name: "27.0.board.compat.map",
56 srcs: [
57 "compat/27.0/27.0.cil",
58 ],
59}
60
Jae Shin1fa96342018-07-11 18:30:44 +090061se_filegroup {
62 name: "28.0.board.compat.map",
63 srcs: [
64 "compat/28.0/28.0.cil",
65 ],
66}
67
Jinguang Donge0125692019-03-05 17:20:54 +080068se_filegroup {
Tri Vo50aa0292019-06-01 17:04:13 -070069 name: "29.0.board.compat.map",
70 srcs: [
71 "compat/29.0/29.0.cil",
72 ],
73}
74
75se_filegroup {
Inseob Kimace36ab2020-05-07 20:19:05 +090076 name: "30.0.board.compat.map",
77 srcs: [
78 "compat/30.0/30.0.cil",
79 ],
80}
81
82se_filegroup {
Jinguang Donge0125692019-03-05 17:20:54 +080083 name: "26.0.board.ignore.map",
84 srcs: [
85 "compat/26.0/26.0.ignore.cil",
86 ],
87}
88
89se_filegroup {
90 name: "27.0.board.ignore.map",
91 srcs: [
92 "compat/27.0/27.0.ignore.cil",
93 ],
94}
95
96se_filegroup {
97 name: "28.0.board.ignore.map",
98 srcs: [
99 "compat/28.0/28.0.ignore.cil",
100 ],
101}
102
Tri Vo50aa0292019-06-01 17:04:13 -0700103se_filegroup {
104 name: "29.0.board.ignore.map",
105 srcs: [
106 "compat/29.0/29.0.ignore.cil",
107 ],
108}
109
Inseob Kimace36ab2020-05-07 20:19:05 +0900110se_filegroup {
111 name: "30.0.board.ignore.map",
112 srcs: [
113 "compat/30.0/30.0.ignore.cil",
114 ],
115}
116
Tri Voa5cfd3e2018-03-22 11:35:02 -0700117se_cil_compat_map {
Tri Vo61178552019-10-10 16:29:40 -0700118 name: "plat_26.0.cil",
119 stem: "26.0.cil",
Tri Vo438684b2018-09-29 17:47:10 -0700120 bottom_half: [":26.0.board.compat.map"],
Tri Vo61178552019-10-10 16:29:40 -0700121 top_half: "plat_27.0.cil",
Tri Voa5cfd3e2018-03-22 11:35:02 -0700122}
123
124se_cil_compat_map {
Tri Vo61178552019-10-10 16:29:40 -0700125 name: "plat_27.0.cil",
126 stem: "27.0.cil",
Tri Vo438684b2018-09-29 17:47:10 -0700127 bottom_half: [":27.0.board.compat.map"],
Tri Vo61178552019-10-10 16:29:40 -0700128 top_half: "plat_28.0.cil",
Tri Voa5cfd3e2018-03-22 11:35:02 -0700129}
Jae Shin1fa96342018-07-11 18:30:44 +0900130
131se_cil_compat_map {
Tri Vo61178552019-10-10 16:29:40 -0700132 name: "plat_28.0.cil",
133 stem: "28.0.cil",
Tri Vo438684b2018-09-29 17:47:10 -0700134 bottom_half: [":28.0.board.compat.map"],
Tri Vo61178552019-10-10 16:29:40 -0700135 top_half: "plat_29.0.cil",
Tri Vo50aa0292019-06-01 17:04:13 -0700136}
137
138se_cil_compat_map {
Tri Vo61178552019-10-10 16:29:40 -0700139 name: "plat_29.0.cil",
140 stem: "29.0.cil",
Tri Vo50aa0292019-06-01 17:04:13 -0700141 bottom_half: [":29.0.board.compat.map"],
Inseob Kimace36ab2020-05-07 20:19:05 +0900142 top_half: "plat_30.0.cil",
143}
144
145se_cil_compat_map {
146 name: "plat_30.0.cil",
147 stem: "30.0.cil",
148 bottom_half: [":30.0.board.compat.map"],
149 // top_half: "plat_31.0.cil",
Tri Vo61178552019-10-10 16:29:40 -0700150}
151
152se_cil_compat_map {
153 name: "system_ext_26.0.cil",
154 stem: "26.0.cil",
155 bottom_half: [":26.0.board.compat.map"],
156 top_half: "system_ext_27.0.cil",
157 system_ext_specific: true,
158}
159
160se_cil_compat_map {
161 name: "system_ext_27.0.cil",
162 stem: "27.0.cil",
163 bottom_half: [":27.0.board.compat.map"],
164 top_half: "system_ext_28.0.cil",
165 system_ext_specific: true,
166}
167
168se_cil_compat_map {
169 name: "system_ext_28.0.cil",
170 stem: "28.0.cil",
171 bottom_half: [":28.0.board.compat.map"],
172 top_half: "system_ext_29.0.cil",
173 system_ext_specific: true,
174}
175
176se_cil_compat_map {
177 name: "system_ext_29.0.cil",
178 stem: "29.0.cil",
179 bottom_half: [":29.0.board.compat.map"],
Inseob Kimace36ab2020-05-07 20:19:05 +0900180 top_half: "system_ext_30.0.cil",
181 system_ext_specific: true,
182}
183
184se_cil_compat_map {
185 name: "system_ext_30.0.cil",
186 stem: "30.0.cil",
187 bottom_half: [":30.0.board.compat.map"],
188 // top_half: "system_ext_31.0.cil",
Tri Vo61178552019-10-10 16:29:40 -0700189 system_ext_specific: true,
190}
191
192se_cil_compat_map {
193 name: "product_26.0.cil",
194 stem: "26.0.cil",
195 bottom_half: [":26.0.board.compat.map"],
196 top_half: "product_27.0.cil",
197 product_specific: true,
198}
199
200se_cil_compat_map {
201 name: "product_27.0.cil",
202 stem: "27.0.cil",
203 bottom_half: [":27.0.board.compat.map"],
204 top_half: "product_28.0.cil",
205 product_specific: true,
206}
207
208se_cil_compat_map {
209 name: "product_28.0.cil",
210 stem: "28.0.cil",
211 bottom_half: [":28.0.board.compat.map"],
212 top_half: "product_29.0.cil",
213 product_specific: true,
214}
215
216se_cil_compat_map {
217 name: "product_29.0.cil",
218 stem: "29.0.cil",
219 bottom_half: [":29.0.board.compat.map"],
Inseob Kimace36ab2020-05-07 20:19:05 +0900220 top_half: "product_30.0.cil",
221 product_specific: true,
222}
223
224se_cil_compat_map {
225 name: "product_30.0.cil",
226 stem: "30.0.cil",
227 bottom_half: [":30.0.board.compat.map"],
228 // top_half: "product_31.0.cil",
Tri Vo61178552019-10-10 16:29:40 -0700229 product_specific: true,
Tri Vo438684b2018-09-29 17:47:10 -0700230}
231
232se_cil_compat_map {
233 name: "26.0.ignore.cil",
Jinguang Donge0125692019-03-05 17:20:54 +0800234 bottom_half: [":26.0.board.ignore.map"],
Tri Vo438684b2018-09-29 17:47:10 -0700235 top_half: "27.0.ignore.cil",
236}
237
238se_cil_compat_map {
239 name: "27.0.ignore.cil",
Jinguang Donge0125692019-03-05 17:20:54 +0800240 bottom_half: [":27.0.board.ignore.map"],
Tri Vo438684b2018-09-29 17:47:10 -0700241 top_half: "28.0.ignore.cil",
242}
243
244se_cil_compat_map {
245 name: "28.0.ignore.cil",
Jinguang Donge0125692019-03-05 17:20:54 +0800246 bottom_half: [":28.0.board.ignore.map"],
Tri Voe381deb2019-06-12 15:52:30 -0700247 top_half: "29.0.ignore.cil",
Jae Shin1fa96342018-07-11 18:30:44 +0900248}
Inseob Kimb554e592019-04-15 20:10:46 +0900249
Tri Vo50aa0292019-06-01 17:04:13 -0700250se_cil_compat_map {
251 name: "29.0.ignore.cil",
252 bottom_half: [":29.0.board.ignore.map"],
Inseob Kimace36ab2020-05-07 20:19:05 +0900253 top_half: "30.0.ignore.cil",
254}
255
256se_cil_compat_map {
257 name: "30.0.ignore.cil",
258 bottom_half: [":30.0.board.ignore.map"],
259 // top_half: "31.0.ignore.cil",
Tri Vo50aa0292019-06-01 17:04:13 -0700260}
261
Jeff Vander Stoep564e2922019-05-02 13:48:44 -0700262prebuilt_etc {
Tri Vo50aa0292019-06-01 17:04:13 -0700263 name: "26.0.compat.cil",
264 src: "private/compat/26.0/26.0.compat.cil",
Jeff Vander Stoep564e2922019-05-02 13:48:44 -0700265 sub_dir: "selinux/mapping",
266}
267
268prebuilt_etc {
269 name: "27.0.compat.cil",
270 src: "private/compat/27.0/27.0.compat.cil",
271 sub_dir: "selinux/mapping",
272}
273
274prebuilt_etc {
Tri Vo50aa0292019-06-01 17:04:13 -0700275 name: "28.0.compat.cil",
276 src: "private/compat/28.0/28.0.compat.cil",
277 sub_dir: "selinux/mapping",
278}
279
280prebuilt_etc {
281 name: "29.0.compat.cil",
282 src: "private/compat/29.0/29.0.compat.cil",
Jeff Vander Stoep564e2922019-05-02 13:48:44 -0700283 sub_dir: "selinux/mapping",
284}
285
Inseob Kimace36ab2020-05-07 20:19:05 +0900286prebuilt_etc {
287 name: "30.0.compat.cil",
288 src: "private/compat/30.0/30.0.compat.cil",
289 sub_dir: "selinux/mapping",
290}
291
Inseob Kimb554e592019-04-15 20:10:46 +0900292se_filegroup {
293 name: "file_contexts_files",
294 srcs: ["file_contexts"],
295}
296
297se_filegroup {
298 name: "file_contexts_asan_files",
299 srcs: ["file_contexts_asan"],
300}
301
302se_filegroup {
303 name: "file_contexts_overlayfs_files",
304 srcs: ["file_contexts_overlayfs"],
305}
306
307se_filegroup {
308 name: "hwservice_contexts_files",
309 srcs: ["hwservice_contexts"],
310}
311
312se_filegroup {
313 name: "property_contexts_files",
314 srcs: ["property_contexts"],
315}
316
317se_filegroup {
318 name: "service_contexts_files",
319 srcs: ["service_contexts"],
320}
321
Janis Danisevskisc40681f2020-07-25 13:02:29 -0700322se_filegroup {
323 name: "keystore2_key_contexts_files",
324 srcs: ["keystore2_key_contexts"],
325}
326
Inseob Kimb554e592019-04-15 20:10:46 +0900327file_contexts {
328 name: "plat_file_contexts",
329 srcs: [":file_contexts_files"],
330 product_variables: {
331 address_sanitize: {
332 srcs: [":file_contexts_asan_files"],
333 },
334 debuggable: {
335 srcs: [":file_contexts_overlayfs_files"],
336 },
337 },
338
339 flatten_apex: {
340 srcs: ["apex/*-file_contexts"],
341 },
342
343 recovery_available: true,
344}
345
346file_contexts {
347 name: "vendor_file_contexts",
348 srcs: [":file_contexts_files"],
349 soc_specific: true,
350 recovery_available: true,
351}
352
353file_contexts {
Bowgo Tsai86a048d2019-09-09 22:04:06 +0800354 name: "system_ext_file_contexts",
355 srcs: [":file_contexts_files"],
356 system_ext_specific: true,
357 recovery_available: true,
358}
359
360file_contexts {
Inseob Kimb554e592019-04-15 20:10:46 +0900361 name: "product_file_contexts",
362 srcs: [":file_contexts_files"],
363 product_specific: true,
364 recovery_available: true,
365}
366
367file_contexts {
368 name: "odm_file_contexts",
369 srcs: [":file_contexts_files"],
370 device_specific: true,
371 recovery_available: true,
372}
373
374hwservice_contexts {
375 name: "plat_hwservice_contexts",
376 srcs: [":hwservice_contexts_files"],
377}
378
379hwservice_contexts {
Bowgo Tsai241d36e2019-09-09 22:05:10 +0800380 name: "system_ext_hwservice_contexts",
381 srcs: [":hwservice_contexts_files"],
382 system_ext_specific: true,
383}
384
385hwservice_contexts {
Inseob Kimb554e592019-04-15 20:10:46 +0900386 name: "product_hwservice_contexts",
387 srcs: [":hwservice_contexts_files"],
388 product_specific: true,
389}
390
391hwservice_contexts {
392 name: "vendor_hwservice_contexts",
393 srcs: [":hwservice_contexts_files"],
394 reqd_mask: true,
395 soc_specific: true,
396}
397
398hwservice_contexts {
399 name: "odm_hwservice_contexts",
400 srcs: [":hwservice_contexts_files"],
401 device_specific: true,
402}
403
404property_contexts {
405 name: "plat_property_contexts",
406 srcs: [":property_contexts_files"],
407 recovery_available: true,
408}
409
410property_contexts {
Bowgo Tsai1864cd02019-09-09 18:09:22 +0800411 name: "system_ext_property_contexts",
412 srcs: [":property_contexts_files"],
413 system_ext_specific: true,
414 recovery_available: true,
415}
416
417property_contexts {
Inseob Kimb554e592019-04-15 20:10:46 +0900418 name: "product_property_contexts",
419 srcs: [":property_contexts_files"],
420 product_specific: true,
421 recovery_available: true,
422}
423
424property_contexts {
425 name: "vendor_property_contexts",
426 srcs: [":property_contexts_files"],
427 reqd_mask: true,
428 soc_specific: true,
429 recovery_available: true,
430}
431
432property_contexts {
433 name: "odm_property_contexts",
434 srcs: [":property_contexts_files"],
435 device_specific: true,
436 recovery_available: true,
437}
438
439service_contexts {
440 name: "plat_service_contexts",
441 srcs: [":service_contexts_files"],
442}
443
444service_contexts {
Bowgo Tsai98231162019-09-09 22:05:29 +0800445 name: "system_ext_service_contexts",
446 srcs: [":service_contexts_files"],
447 system_ext_specific: true,
448}
449
450service_contexts {
Inseob Kimb554e592019-04-15 20:10:46 +0900451 name: "product_service_contexts",
452 srcs: [":service_contexts_files"],
453 product_specific: true,
454}
455
456service_contexts {
457 name: "vendor_service_contexts",
458 srcs: [":service_contexts_files"],
459 reqd_mask: true,
460 soc_specific: true,
461}
yangbill3e345372020-04-15 13:55:47 +0800462
Janis Danisevskisc40681f2020-07-25 13:02:29 -0700463keystore2_key_contexts {
464 name: "plat_keystore2_key_contexts",
465 srcs: [":keystore2_key_contexts_files"],
466}
467
468keystore2_key_contexts {
469 name: "system_keystore2_key_contexts",
470 srcs: [":keystore2_key_contexts_files"],
471 system_ext_specific: true,
472}
473
474keystore2_key_contexts {
475 name: "product_keystore2_key_contexts",
476 srcs: [":keystore2_key_contexts_files"],
477 product_specific: true,
478}
479
480keystore2_key_contexts {
481 name: "vendor_keystore2_key_contexts",
482 srcs: [":keystore2_key_contexts_files"],
483 reqd_mask: true,
484 soc_specific: true,
485}
486
yangbill3e345372020-04-15 13:55:47 +0800487// For vts_treble_sys_prop_test
488filegroup {
489 name: "private_property_contexts",
490 srcs: ["private/property_contexts"],
491 visibility: [
492 "//test/vts-testcase/security/system_property",
493 ],
494}
Inseob Kime35b49b2021-02-18 19:15:41 +0900495
496// This is a minimized cil modules to test microdroid.
497// TODO(b/178993690): migrate cil files to Android.bp and remove below
498filegroup {
499 name: "microdroid_sepolicy_build_files",
500 srcs: [
501 // This order is important. Should be identical to sepolicy_build_files in Android.mk
502 "private/security_classes",
503 "private/initial_sids",
504 "private/access_vectors",
505 "public/global_macros",
506 "public/neverallow_macros",
507 "private/mls_macros",
508 "private/mls_decl",
509 "private/mls",
510 "private/policy_capabilities",
511 "public/te_macros",
512 "public/attributes",
513 "private/attributes",
514 "public/ioctl_defines",
515 "public/ioctl_macros",
516 "public/*.te",
517 "private/*.te",
518 "private/roles_decl",
519 "public/roles",
520 "private/users",
521 "private/initial_sid_contexts",
522 "private/fs_use",
523 "private/genfs_contexts",
524 "private/port_contexts",
525 ],
526}
527
528filegroup {
529 name: "microdroid_sepolicy_public_and_reqd_mask_build_files",
530 srcs: [
531 // This order is important. Should be identical to sepolicy_build_files in Android.mk
532 "reqd_mask/security_classes",
533 "reqd_mask/initial_sids",
534 "reqd_mask/access_vectors",
535 "public/global_macros",
536 "public/neverallow_macros",
537 "reqd_mask/mls_macros",
538 "reqd_mask/mls_decl",
539 "reqd_mask/mls",
540 "public/te_macros",
541 "public/attributes",
542 "public/ioctl_defines",
543 "public/ioctl_macros",
544 "public/*.te",
545 "reqd_mask/*.te",
546 "reqd_mask/roles_decl",
547 "public/roles",
548 "reqd_mask/roles",
549 "reqd_mask/users",
550 "reqd_mask/initial_sid_contexts",
551 ],
552}
553
554filegroup {
555 name: "microdroid_sepolicy_reqd_mask_build_files",
556 srcs: [
557 // This order is important. Should be identical to sepolicy_build_files in Android.mk
558 "reqd_mask/security_classes",
559 "reqd_mask/initial_sids",
560 "reqd_mask/access_vectors",
561 "reqd_mask/mls_macros",
562 "reqd_mask/mls_decl",
563 "reqd_mask/mls",
564 "reqd_mask/*.te",
565 "reqd_mask/roles_decl",
566 "reqd_mask/roles",
567 "reqd_mask/users",
568 "reqd_mask/initial_sid_contexts",
569 ],
570}
571
572// These variables are based on aosp_cf_x86_64_only_phone-userdebug. Other than target_arch,
573// these configurations should be fine to test microdroid on normal devices with full treble.
574// The exception is target_arch. But as target_arch is meaningful only on mips, and as we are not
575// running microdroid on mips for now, we skip assigning target_arch here. After cil files are fully
576// migrated into Soong, these will have correct values.
577policy_to_conf_flags = "$(location m4) --fatal-warnings " +
578"-D mls_num_sens=1 -D mls_num_cats=1024 " +
579"-D target_build_variant=userdebug " +
580"-D target_with_asan=false " +
581"-D target_with_native_coverage=false " +
582"-D target_full_treble=true " +
583"-D target_compatible_property=true " +
584"-D target_treble_sysprop_neverallow=true " +
585"-D target_enforce_sysprop_owner=true "
586
587genrule {
588 name: "microdroid_plat_sepolicy.cil_gen",
589 srcs: [":microdroid_sepolicy_build_files"],
590 tools: ["m4", "checkpolicy"],
591 out: ["plat_sepolicy.cil"],
592 cmd: policy_to_conf_flags +
593 "-s $(locations :microdroid_sepolicy_build_files) > $(out).conf" +
594 "&& $(location checkpolicy) -M -C -c 30 -o $(out) $(out).conf",
595 visibility: ["//visibility:private"],
596}
597
598prebuilt_etc {
599 name: "microdroid_plat_sepolicy.cil",
600 src: ":microdroid_plat_sepolicy.cil_gen",
601 filename: "plat_sepolicy.cil",
602 relative_install_path: "selinux",
603 installable: false,
604}
605
606genrule {
607 name: "microdroid_reqd_policy_mask.cil_gen",
608 srcs: [":microdroid_sepolicy_reqd_mask_build_files"],
609 tools: ["m4", "checkpolicy"],
610 out: ["reqd_policy_mask.cil"],
611 cmd: policy_to_conf_flags +
612 "-s $(in) > $(out).conf" +
613 "&& $(location checkpolicy) -C -M -c 30 -o $(out) $(out).conf",
614 visibility: ["//visibility:private"],
615}
616
617genrule {
618 name: "microdroid_plat_mapping_file_gen",
619 srcs: [":microdroid_sepolicy_public_and_reqd_mask_build_files", ":microdroid_reqd_policy_mask.cil_gen"],
620 tools: ["m4", "checkpolicy", "build_sepolicy", "version_policy"],
621 out: ["10000.0.cil"],
622 cmd: policy_to_conf_flags +
623 "-s $(locations :microdroid_sepolicy_public_and_reqd_mask_build_files) > $(out).conf" +
624 "&& $(location checkpolicy) -M -C -c 30 -o $(out).pub $(out).conf" +
625 "&& $(location build_sepolicy) filter_out -f $(location :microdroid_reqd_policy_mask.cil_gen) -t $(out).pub" +
626 "&& $(location version_policy) -b $(out).pub -m -n 10000.0 -o $(out)",
627 visibility: ["//visibility:private"],
628}
629
630prebuilt_etc {
631 name: "microdroid_plat_mapping_file",
632 src: ":microdroid_plat_mapping_file_gen",
633 filename: "10000.0.cil",
634 relative_install_path: "selinux/mapping",
635 installable: false,
636}