xref: /aosp_15_r20/system/sepolicy/Android.bp (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker// Copyright (C) 2018 The Android Open Source Project
2*e4a36f41SAndroid Build Coastguard Worker//
3*e4a36f41SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*e4a36f41SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*e4a36f41SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*e4a36f41SAndroid Build Coastguard Worker//
7*e4a36f41SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*e4a36f41SAndroid Build Coastguard Worker//
9*e4a36f41SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*e4a36f41SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*e4a36f41SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*e4a36f41SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*e4a36f41SAndroid Build Coastguard Worker// limitations under the License.
14*e4a36f41SAndroid Build Coastguard Worker
15*e4a36f41SAndroid Build Coastguard Workerpackage {
16*e4a36f41SAndroid Build Coastguard Worker    default_applicable_licenses: ["system_sepolicy_license"],
17*e4a36f41SAndroid Build Coastguard Worker}
18*e4a36f41SAndroid Build Coastguard Worker
19*e4a36f41SAndroid Build Coastguard Worker// Added automatically by a large-scale-change that took the approach of
20*e4a36f41SAndroid Build Coastguard Worker// 'apply every license found to every target'. While this makes sure we respect
21*e4a36f41SAndroid Build Coastguard Worker// every license restriction, it may not be entirely correct.
22*e4a36f41SAndroid Build Coastguard Worker//
23*e4a36f41SAndroid Build Coastguard Worker// e.g. GPL in an MIT project might only apply to the contrib/ directory.
24*e4a36f41SAndroid Build Coastguard Worker//
25*e4a36f41SAndroid Build Coastguard Worker// Please consider splitting the single license below into multiple licenses,
26*e4a36f41SAndroid Build Coastguard Worker// taking care not to lose any license_kind information, and overriding the
27*e4a36f41SAndroid Build Coastguard Worker// default license using the 'licenses: [...]' property on targets as needed.
28*e4a36f41SAndroid Build Coastguard Worker//
29*e4a36f41SAndroid Build Coastguard Worker// For unused files, consider creating a 'filegroup' with "//visibility:private"
30*e4a36f41SAndroid Build Coastguard Worker// to attach the license to, and including a comment whether the files may be
31*e4a36f41SAndroid Build Coastguard Worker// used in the current project.
32*e4a36f41SAndroid Build Coastguard Worker// http://go/android-license-faq
33*e4a36f41SAndroid Build Coastguard Workerlicense {
34*e4a36f41SAndroid Build Coastguard Worker    name: "system_sepolicy_license",
35*e4a36f41SAndroid Build Coastguard Worker    visibility: [":__subpackages__"],
36*e4a36f41SAndroid Build Coastguard Worker    license_kinds: [
37*e4a36f41SAndroid Build Coastguard Worker        "SPDX-license-identifier-Apache-2.0",
38*e4a36f41SAndroid Build Coastguard Worker        "legacy_unencumbered",
39*e4a36f41SAndroid Build Coastguard Worker    ],
40*e4a36f41SAndroid Build Coastguard Worker    license_text: [
41*e4a36f41SAndroid Build Coastguard Worker        "NOTICE",
42*e4a36f41SAndroid Build Coastguard Worker    ],
43*e4a36f41SAndroid Build Coastguard Worker}
44*e4a36f41SAndroid Build Coastguard Worker
45*e4a36f41SAndroid Build Coastguard Workercc_defaults {
46*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_version",
47*e4a36f41SAndroid Build Coastguard Worker    cflags: ["-DSEPOLICY_VERSION=30"],
48*e4a36f41SAndroid Build Coastguard Worker}
49*e4a36f41SAndroid Build Coastguard Worker
50*e4a36f41SAndroid Build Coastguard Worker// For vts_treble_sys_prop_test
51*e4a36f41SAndroid Build Coastguard Workerfilegroup {
52*e4a36f41SAndroid Build Coastguard Worker    name: "private_property_contexts",
53*e4a36f41SAndroid Build Coastguard Worker    srcs: ["private/property_contexts"],
54*e4a36f41SAndroid Build Coastguard Worker    visibility: [
55*e4a36f41SAndroid Build Coastguard Worker        "//test/vts-testcase/security/system_property",
56*e4a36f41SAndroid Build Coastguard Worker    ],
57*e4a36f41SAndroid Build Coastguard Worker}
58*e4a36f41SAndroid Build Coastguard Worker
59*e4a36f41SAndroid Build Coastguard Workerse_build_files {
60*e4a36f41SAndroid Build Coastguard Worker    name: "se_build_files",
61*e4a36f41SAndroid Build Coastguard Worker    srcs: [
62*e4a36f41SAndroid Build Coastguard Worker        "security_classes",
63*e4a36f41SAndroid Build Coastguard Worker        "initial_sids",
64*e4a36f41SAndroid Build Coastguard Worker        "access_vectors",
65*e4a36f41SAndroid Build Coastguard Worker        "global_macros",
66*e4a36f41SAndroid Build Coastguard Worker        "neverallow_macros",
67*e4a36f41SAndroid Build Coastguard Worker        "mls_macros",
68*e4a36f41SAndroid Build Coastguard Worker        "mls_decl",
69*e4a36f41SAndroid Build Coastguard Worker        "mls",
70*e4a36f41SAndroid Build Coastguard Worker        "policy_capabilities",
71*e4a36f41SAndroid Build Coastguard Worker        "te_macros",
72*e4a36f41SAndroid Build Coastguard Worker        "attributes",
73*e4a36f41SAndroid Build Coastguard Worker        "ioctl_defines",
74*e4a36f41SAndroid Build Coastguard Worker        "ioctl_macros",
75*e4a36f41SAndroid Build Coastguard Worker        "*.te",
76*e4a36f41SAndroid Build Coastguard Worker        "roles_decl",
77*e4a36f41SAndroid Build Coastguard Worker        "roles",
78*e4a36f41SAndroid Build Coastguard Worker        "users",
79*e4a36f41SAndroid Build Coastguard Worker        "initial_sid_contexts",
80*e4a36f41SAndroid Build Coastguard Worker        "fs_use",
81*e4a36f41SAndroid Build Coastguard Worker        "genfs_contexts",
82*e4a36f41SAndroid Build Coastguard Worker        "port_contexts",
83*e4a36f41SAndroid Build Coastguard Worker    ],
84*e4a36f41SAndroid Build Coastguard Worker}
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Workerse_build_files {
87*e4a36f41SAndroid Build Coastguard Worker    name: "sepolicy_technical_debt",
88*e4a36f41SAndroid Build Coastguard Worker    srcs: ["technical_debt.cil"],
89*e4a36f41SAndroid Build Coastguard Worker}
90*e4a36f41SAndroid Build Coastguard Worker
91*e4a36f41SAndroid Build Coastguard Workerphony {
92*e4a36f41SAndroid Build Coastguard Worker    // Currently used only for aosp_cf_system_x86_64
93*e4a36f41SAndroid Build Coastguard Worker    // TODO(b/329208946): migrate selinux_policy_system to Soong
94*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_system_soong",
95*e4a36f41SAndroid Build Coastguard Worker    required: [
96*e4a36f41SAndroid Build Coastguard Worker        "plat_bug_map",
97*e4a36f41SAndroid Build Coastguard Worker        "plat_file_contexts",
98*e4a36f41SAndroid Build Coastguard Worker        "plat_hwservice_contexts",
99*e4a36f41SAndroid Build Coastguard Worker        "plat_keystore2_key_contexts",
100*e4a36f41SAndroid Build Coastguard Worker        "plat_mac_permissions.xml",
101*e4a36f41SAndroid Build Coastguard Worker        "plat_mapping_file",
102*e4a36f41SAndroid Build Coastguard Worker        "plat_property_contexts",
103*e4a36f41SAndroid Build Coastguard Worker        "plat_seapp_contexts",
104*e4a36f41SAndroid Build Coastguard Worker        "plat_sepolicy.cil",
105*e4a36f41SAndroid Build Coastguard Worker        "plat_sepolicy_genfs_202504.cil",
106*e4a36f41SAndroid Build Coastguard Worker        "plat_service_contexts",
107*e4a36f41SAndroid Build Coastguard Worker        "secilc",
108*e4a36f41SAndroid Build Coastguard Worker        "plat_29.0.cil",
109*e4a36f41SAndroid Build Coastguard Worker        "29.0.compat.cil",
110*e4a36f41SAndroid Build Coastguard Worker        "plat_30.0.cil",
111*e4a36f41SAndroid Build Coastguard Worker        "30.0.compat.cil",
112*e4a36f41SAndroid Build Coastguard Worker        "plat_31.0.cil",
113*e4a36f41SAndroid Build Coastguard Worker        "31.0.compat.cil",
114*e4a36f41SAndroid Build Coastguard Worker        "plat_32.0.cil",
115*e4a36f41SAndroid Build Coastguard Worker        "32.0.compat.cil",
116*e4a36f41SAndroid Build Coastguard Worker        "plat_33.0.cil",
117*e4a36f41SAndroid Build Coastguard Worker        "33.0.compat.cil",
118*e4a36f41SAndroid Build Coastguard Worker        "plat_34.0.cil",
119*e4a36f41SAndroid Build Coastguard Worker        "34.0.compat.cil",
120*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
121*e4a36f41SAndroid Build Coastguard Worker        "202404": [],
122*e4a36f41SAndroid Build Coastguard Worker        default: [
123*e4a36f41SAndroid Build Coastguard Worker            "plat_202404.cil",
124*e4a36f41SAndroid Build Coastguard Worker            "202404.compat.cil",
125*e4a36f41SAndroid Build Coastguard Worker        ],
126*e4a36f41SAndroid Build Coastguard Worker    }) + select(soong_config_variable("ANDROID", "PRODUCT_PRECOMPILED_SEPOLICY"), {
127*e4a36f41SAndroid Build Coastguard Worker        true: ["plat_sepolicy_and_mapping.sha256"],
128*e4a36f41SAndroid Build Coastguard Worker        default: [],
129*e4a36f41SAndroid Build Coastguard Worker    }) + select(release_flag("RELEASE_AVF_ENABLE_VM_TO_TEE_SERVICES_ALLOWLIST"), {
130*e4a36f41SAndroid Build Coastguard Worker        true: ["plat_tee_service_contexts"],
131*e4a36f41SAndroid Build Coastguard Worker        default: [],
132*e4a36f41SAndroid Build Coastguard Worker    }),
133*e4a36f41SAndroid Build Coastguard Worker}
134*e4a36f41SAndroid Build Coastguard Worker
135*e4a36f41SAndroid Build Coastguard Workerreqd_mask_policy = [":se_build_files{.reqd_mask}"]
136*e4a36f41SAndroid Build Coastguard Workerplat_public_policy = [":se_build_files{.plat_public}"]
137*e4a36f41SAndroid Build Coastguard Workerplat_private_policy = [":se_build_files{.plat_private}"]
138*e4a36f41SAndroid Build Coastguard Workersystem_ext_public_policy = [":se_build_files{.system_ext_public}"]
139*e4a36f41SAndroid Build Coastguard Workersystem_ext_private_policy = [":se_build_files{.system_ext_private}"]
140*e4a36f41SAndroid Build Coastguard Workerproduct_public_policy = [":se_build_files{.product_public}"]
141*e4a36f41SAndroid Build Coastguard Workerproduct_private_policy = [":se_build_files{.product_private}"]
142*e4a36f41SAndroid Build Coastguard Worker
143*e4a36f41SAndroid Build Coastguard Worker// reqd_policy_mask - a policy.conf file which contains only the bare minimum
144*e4a36f41SAndroid Build Coastguard Worker// policy necessary to use checkpolicy.
145*e4a36f41SAndroid Build Coastguard Worker//
146*e4a36f41SAndroid Build Coastguard Worker// This bare-minimum policy needs to be present in all policy.conf files, but
147*e4a36f41SAndroid Build Coastguard Worker// should not necessarily be exported as part of the public policy.
148*e4a36f41SAndroid Build Coastguard Worker//
149*e4a36f41SAndroid Build Coastguard Worker// The rules generated by reqd_policy_mask will allow the compilation of public
150*e4a36f41SAndroid Build Coastguard Worker// policy and subsequent removal of CIL policy that should not be exported.
151*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
152*e4a36f41SAndroid Build Coastguard Worker    name: "reqd_policy_mask.conf",
153*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
154*e4a36f41SAndroid Build Coastguard Worker    srcs: reqd_mask_policy,
155*e4a36f41SAndroid Build Coastguard Worker    installable: false,
156*e4a36f41SAndroid Build Coastguard Worker}
157*e4a36f41SAndroid Build Coastguard Worker
158*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
159*e4a36f41SAndroid Build Coastguard Worker    name: "reqd_policy_mask.cil",
160*e4a36f41SAndroid Build Coastguard Worker    src: ":reqd_policy_mask.conf",
161*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
162*e4a36f41SAndroid Build Coastguard Worker    installable: false,
163*e4a36f41SAndroid Build Coastguard Worker}
164*e4a36f41SAndroid Build Coastguard Worker
165*e4a36f41SAndroid Build Coastguard Worker// pub_policy - policy that will be exported to be a part of non-platform
166*e4a36f41SAndroid Build Coastguard Worker// policy corresponding to this platform version.
167*e4a36f41SAndroid Build Coastguard Worker//
168*e4a36f41SAndroid Build Coastguard Worker// This is a limited subset of policy that would not compile in checkpolicy on
169*e4a36f41SAndroid Build Coastguard Worker// its own.
170*e4a36f41SAndroid Build Coastguard Worker//
171*e4a36f41SAndroid Build Coastguard Worker// To get around this limitation, add only the required files from private
172*e4a36f41SAndroid Build Coastguard Worker// policy, which will generate CIL policy that will then be filtered out by the
173*e4a36f41SAndroid Build Coastguard Worker// reqd_policy_mask.
174*e4a36f41SAndroid Build Coastguard Worker//
175*e4a36f41SAndroid Build Coastguard Worker// There are three pub_policy.cil files below:
176*e4a36f41SAndroid Build Coastguard Worker//   - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy.
177*e4a36f41SAndroid Build Coastguard Worker//   - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy.
178*e4a36f41SAndroid Build Coastguard Worker//   - plat_pub_policy.cil: exported 'system' policy.
179*e4a36f41SAndroid Build Coastguard Worker//
180*e4a36f41SAndroid Build Coastguard Worker// Those above files will in turn be used to generate the following versioned cil files:
181*e4a36f41SAndroid Build Coastguard Worker//   - product_mapping_file: the versioned, exported 'product' policy in product partition.
182*e4a36f41SAndroid Build Coastguard Worker//   - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition.
183*e4a36f41SAndroid Build Coastguard Worker//   - plat_mapping_file: the versioned, exported 'system' policy in system partition.
184*e4a36f41SAndroid Build Coastguard Worker//   - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy
185*e4a36f41SAndroid Build Coastguard Worker//                             in vendor partition.
186*e4a36f41SAndroid Build Coastguard Worker//
187*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
188*e4a36f41SAndroid Build Coastguard Worker    name: "pub_policy.conf",
189*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
190*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
191*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
192*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
193*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy,
194*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
195*e4a36f41SAndroid Build Coastguard Worker    installable: false,
196*e4a36f41SAndroid Build Coastguard Worker}
197*e4a36f41SAndroid Build Coastguard Worker
198*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
199*e4a36f41SAndroid Build Coastguard Worker    name: "pub_policy.cil",
200*e4a36f41SAndroid Build Coastguard Worker    src: ":pub_policy.conf",
201*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
202*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
203*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
204*e4a36f41SAndroid Build Coastguard Worker    installable: false,
205*e4a36f41SAndroid Build Coastguard Worker}
206*e4a36f41SAndroid Build Coastguard Worker
207*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
208*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_pub_policy.conf",
209*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
210*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
211*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
212*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy,
213*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
214*e4a36f41SAndroid Build Coastguard Worker    installable: false,
215*e4a36f41SAndroid Build Coastguard Worker}
216*e4a36f41SAndroid Build Coastguard Worker
217*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
218*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_pub_policy.cil",
219*e4a36f41SAndroid Build Coastguard Worker    src: ":system_ext_pub_policy.conf",
220*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
221*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
222*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
223*e4a36f41SAndroid Build Coastguard Worker    installable: false,
224*e4a36f41SAndroid Build Coastguard Worker}
225*e4a36f41SAndroid Build Coastguard Worker
226*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
227*e4a36f41SAndroid Build Coastguard Worker    name: "plat_pub_policy.conf",
228*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
229*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
230*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy,
231*e4a36f41SAndroid Build Coastguard Worker    installable: false,
232*e4a36f41SAndroid Build Coastguard Worker}
233*e4a36f41SAndroid Build Coastguard Worker
234*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
235*e4a36f41SAndroid Build Coastguard Worker    name: "plat_pub_policy.cil",
236*e4a36f41SAndroid Build Coastguard Worker    src: ":plat_pub_policy.conf",
237*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
238*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
239*e4a36f41SAndroid Build Coastguard Worker    installable: false,
240*e4a36f41SAndroid Build Coastguard Worker}
241*e4a36f41SAndroid Build Coastguard Worker
242*e4a36f41SAndroid Build Coastguard Worker// plat_policy.conf - A combination of the private and public platform policy
243*e4a36f41SAndroid Build Coastguard Worker// which will ship with the device.
244*e4a36f41SAndroid Build Coastguard Worker//
245*e4a36f41SAndroid Build Coastguard Worker// The platform will always reflect the most recent platform version and is not
246*e4a36f41SAndroid Build Coastguard Worker// currently being attributized.
247*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
248*e4a36f41SAndroid Build Coastguard Worker    name: "plat_sepolicy.conf",
249*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
250*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
251*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy,
252*e4a36f41SAndroid Build Coastguard Worker    installable: false,
253*e4a36f41SAndroid Build Coastguard Worker}
254*e4a36f41SAndroid Build Coastguard Worker
255*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
256*e4a36f41SAndroid Build Coastguard Worker    name: "plat_sepolicy.cil",
257*e4a36f41SAndroid Build Coastguard Worker    src: ":plat_sepolicy.conf",
258*e4a36f41SAndroid Build Coastguard Worker    additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
259*e4a36f41SAndroid Build Coastguard Worker    dist: {
260*e4a36f41SAndroid Build Coastguard Worker        targets: ["sepolicy_finalize"],
261*e4a36f41SAndroid Build Coastguard Worker    },
262*e4a36f41SAndroid Build Coastguard Worker}
263*e4a36f41SAndroid Build Coastguard Worker
264*e4a36f41SAndroid Build Coastguard Worker// userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil
265*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
266*e4a36f41SAndroid Build Coastguard Worker    name: "userdebug_plat_sepolicy.conf",
267*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
268*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
269*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy,
270*e4a36f41SAndroid Build Coastguard Worker    build_variant: "userdebug",
271*e4a36f41SAndroid Build Coastguard Worker    installable: false,
272*e4a36f41SAndroid Build Coastguard Worker}
273*e4a36f41SAndroid Build Coastguard Worker
274*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
275*e4a36f41SAndroid Build Coastguard Worker    name: "userdebug_plat_sepolicy.cil",
276*e4a36f41SAndroid Build Coastguard Worker    src: ":userdebug_plat_sepolicy.conf",
277*e4a36f41SAndroid Build Coastguard Worker    additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
278*e4a36f41SAndroid Build Coastguard Worker    debug_ramdisk: true,
279*e4a36f41SAndroid Build Coastguard Worker    dist: {
280*e4a36f41SAndroid Build Coastguard Worker        targets: ["droidcore"],
281*e4a36f41SAndroid Build Coastguard Worker    },
282*e4a36f41SAndroid Build Coastguard Worker}
283*e4a36f41SAndroid Build Coastguard Worker
284*e4a36f41SAndroid Build Coastguard Worker// A copy of the userdebug_plat_policy in GSI.
285*e4a36f41SAndroid Build Coastguard Workersoong_config_module_type {
286*e4a36f41SAndroid Build Coastguard Worker    name: "gsi_se_policy_cil",
287*e4a36f41SAndroid Build Coastguard Worker    module_type: "se_policy_cil",
288*e4a36f41SAndroid Build Coastguard Worker    config_namespace: "ANDROID",
289*e4a36f41SAndroid Build Coastguard Worker    bool_variables: [
290*e4a36f41SAndroid Build Coastguard Worker        "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
291*e4a36f41SAndroid Build Coastguard Worker    ],
292*e4a36f41SAndroid Build Coastguard Worker    properties: [
293*e4a36f41SAndroid Build Coastguard Worker        "enabled",
294*e4a36f41SAndroid Build Coastguard Worker        "installable",
295*e4a36f41SAndroid Build Coastguard Worker    ],
296*e4a36f41SAndroid Build Coastguard Worker}
297*e4a36f41SAndroid Build Coastguard Worker
298*e4a36f41SAndroid Build Coastguard Workergsi_se_policy_cil {
299*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_userdebug_plat_sepolicy.cil",
300*e4a36f41SAndroid Build Coastguard Worker    stem: "userdebug_plat_sepolicy.cil",
301*e4a36f41SAndroid Build Coastguard Worker    src: ":userdebug_plat_sepolicy.conf",
302*e4a36f41SAndroid Build Coastguard Worker    additional_cil_files: [":sepolicy_technical_debt{.plat_private}"],
303*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
304*e4a36f41SAndroid Build Coastguard Worker    enabled: false,
305*e4a36f41SAndroid Build Coastguard Worker    installable: false,
306*e4a36f41SAndroid Build Coastguard Worker    soong_config_variables: {
307*e4a36f41SAndroid Build Coastguard Worker        PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
308*e4a36f41SAndroid Build Coastguard Worker            enabled: true,
309*e4a36f41SAndroid Build Coastguard Worker            installable: true,
310*e4a36f41SAndroid Build Coastguard Worker        },
311*e4a36f41SAndroid Build Coastguard Worker    },
312*e4a36f41SAndroid Build Coastguard Worker}
313*e4a36f41SAndroid Build Coastguard Worker
314*e4a36f41SAndroid Build Coastguard Worker// system_ext_policy.conf - A combination of the private and public system_ext
315*e4a36f41SAndroid Build Coastguard Worker// policy which will ship with the device. System_ext policy is not attributized
316*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
317*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_sepolicy.conf",
318*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
319*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
320*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy +
321*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
322*e4a36f41SAndroid Build Coastguard Worker        system_ext_private_policy,
323*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
324*e4a36f41SAndroid Build Coastguard Worker    installable: false,
325*e4a36f41SAndroid Build Coastguard Worker}
326*e4a36f41SAndroid Build Coastguard Worker
327*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
328*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_sepolicy.cil",
329*e4a36f41SAndroid Build Coastguard Worker    src: ":system_ext_sepolicy.conf",
330*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
331*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":plat_sepolicy.cil"],
332*e4a36f41SAndroid Build Coastguard Worker    remove_line_marker: true,
333*e4a36f41SAndroid Build Coastguard Worker}
334*e4a36f41SAndroid Build Coastguard Worker
335*e4a36f41SAndroid Build Coastguard Worker// product_policy.conf - A combination of the private and public product policy
336*e4a36f41SAndroid Build Coastguard Worker// which will ship with the device. Product policy is not attributized
337*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
338*e4a36f41SAndroid Build Coastguard Worker    name: "product_sepolicy.conf",
339*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
340*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
341*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy +
342*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
343*e4a36f41SAndroid Build Coastguard Worker        system_ext_private_policy +
344*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
345*e4a36f41SAndroid Build Coastguard Worker        product_private_policy,
346*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
347*e4a36f41SAndroid Build Coastguard Worker    installable: false,
348*e4a36f41SAndroid Build Coastguard Worker}
349*e4a36f41SAndroid Build Coastguard Worker
350*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
351*e4a36f41SAndroid Build Coastguard Worker    name: "product_sepolicy.cil",
352*e4a36f41SAndroid Build Coastguard Worker    src: ":product_sepolicy.conf",
353*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
354*e4a36f41SAndroid Build Coastguard Worker    filter_out: [
355*e4a36f41SAndroid Build Coastguard Worker        ":plat_sepolicy.cil",
356*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_sepolicy.cil",
357*e4a36f41SAndroid Build Coastguard Worker    ],
358*e4a36f41SAndroid Build Coastguard Worker    remove_line_marker: true,
359*e4a36f41SAndroid Build Coastguard Worker}
360*e4a36f41SAndroid Build Coastguard Worker
361*e4a36f41SAndroid Build Coastguard Worker// policy mapping files
362*e4a36f41SAndroid Build Coastguard Worker// auto-generate the mapping file for current platform policy, since it needs to
363*e4a36f41SAndroid Build Coastguard Worker// track platform policy development
364*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
365*e4a36f41SAndroid Build Coastguard Worker    name: "plat_mapping_file",
366*e4a36f41SAndroid Build Coastguard Worker    base: ":plat_pub_policy.cil",
367*e4a36f41SAndroid Build Coastguard Worker    mapping: true,
368*e4a36f41SAndroid Build Coastguard Worker    version: "current",
369*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "mapping", // install to /system/etc/selinux/mapping
370*e4a36f41SAndroid Build Coastguard Worker    dist: {
371*e4a36f41SAndroid Build Coastguard Worker        targets: ["sepolicy_finalize"],
372*e4a36f41SAndroid Build Coastguard Worker    },
373*e4a36f41SAndroid Build Coastguard Worker}
374*e4a36f41SAndroid Build Coastguard Worker
375*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
376*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_mapping_file",
377*e4a36f41SAndroid Build Coastguard Worker    base: ":system_ext_pub_policy.cil",
378*e4a36f41SAndroid Build Coastguard Worker    mapping: true,
379*e4a36f41SAndroid Build Coastguard Worker    version: "current",
380*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":plat_mapping_file"],
381*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping
382*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
383*e4a36f41SAndroid Build Coastguard Worker}
384*e4a36f41SAndroid Build Coastguard Worker
385*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
386*e4a36f41SAndroid Build Coastguard Worker    name: "product_mapping_file",
387*e4a36f41SAndroid Build Coastguard Worker    base: ":pub_policy.cil",
388*e4a36f41SAndroid Build Coastguard Worker    mapping: true,
389*e4a36f41SAndroid Build Coastguard Worker    version: "current",
390*e4a36f41SAndroid Build Coastguard Worker    filter_out: [
391*e4a36f41SAndroid Build Coastguard Worker        ":plat_mapping_file",
392*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_mapping_file",
393*e4a36f41SAndroid Build Coastguard Worker    ],
394*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "mapping", // install to /product/etc/selinux/mapping
395*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
396*e4a36f41SAndroid Build Coastguard Worker}
397*e4a36f41SAndroid Build Coastguard Worker
398*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
399*e4a36f41SAndroid Build Coastguard Worker// vendor/odm sepolicy
400*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
401*e4a36f41SAndroid Build Coastguard Worker
402*e4a36f41SAndroid Build Coastguard Worker// plat_pub_versioned.cil - the exported platform policy associated with the version
403*e4a36f41SAndroid Build Coastguard Worker// that non-platform policy targets.
404*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
405*e4a36f41SAndroid Build Coastguard Worker    name: "plat_pub_versioned.cil",
406*e4a36f41SAndroid Build Coastguard Worker    base: ":pub_policy.cil",
407*e4a36f41SAndroid Build Coastguard Worker    target_policy: ":pub_policy.cil",
408*e4a36f41SAndroid Build Coastguard Worker    version: "vendor",
409*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
410*e4a36f41SAndroid Build Coastguard Worker}
411*e4a36f41SAndroid Build Coastguard Worker
412*e4a36f41SAndroid Build Coastguard Worker// vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined
413*e4a36f41SAndroid Build Coastguard Worker// with the platform-provided policy.  It makes use of the reqd_policy_mask files from private
414*e4a36f41SAndroid Build Coastguard Worker// policy and the platform public policy files in order to use checkpolicy.
415*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
416*e4a36f41SAndroid Build Coastguard Worker    name: "vendor_sepolicy.conf",
417*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
418*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
419*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
420*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
421*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy + [
422*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.plat_vendor}",
423*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.vendor}",
424*e4a36f41SAndroid Build Coastguard Worker        ],
425*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
426*e4a36f41SAndroid Build Coastguard Worker    installable: false,
427*e4a36f41SAndroid Build Coastguard Worker}
428*e4a36f41SAndroid Build Coastguard Worker
429*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
430*e4a36f41SAndroid Build Coastguard Worker    name: "vendor_sepolicy.cil.raw",
431*e4a36f41SAndroid Build Coastguard Worker    src: ":vendor_sepolicy.conf",
432*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
433*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false, // will be done in se_versioned_policy module
434*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
435*e4a36f41SAndroid Build Coastguard Worker    installable: false,
436*e4a36f41SAndroid Build Coastguard Worker}
437*e4a36f41SAndroid Build Coastguard Worker
438*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
439*e4a36f41SAndroid Build Coastguard Worker    name: "vendor_sepolicy.cil",
440*e4a36f41SAndroid Build Coastguard Worker    base: ":pub_policy.cil",
441*e4a36f41SAndroid Build Coastguard Worker    target_policy: ":vendor_sepolicy.cil.raw",
442*e4a36f41SAndroid Build Coastguard Worker    version: "vendor",
443*e4a36f41SAndroid Build Coastguard Worker    dependent_cils: [
444*e4a36f41SAndroid Build Coastguard Worker        ":plat_sepolicy.cil",
445*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_sepolicy.cil",
446*e4a36f41SAndroid Build Coastguard Worker        ":product_sepolicy.cil",
447*e4a36f41SAndroid Build Coastguard Worker        ":plat_pub_versioned.cil",
448*e4a36f41SAndroid Build Coastguard Worker        ":plat_mapping_file",
449*e4a36f41SAndroid Build Coastguard Worker    ],
450*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":plat_pub_versioned.cil"],
451*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
452*e4a36f41SAndroid Build Coastguard Worker}
453*e4a36f41SAndroid Build Coastguard Worker
454*e4a36f41SAndroid Build Coastguard Worker// odm_policy.cil - the odl sepolicy. This needs attributization and to be combined
455*e4a36f41SAndroid Build Coastguard Worker// with the platform-provided policy.  It makes use of the reqd_policy_mask files from private
456*e4a36f41SAndroid Build Coastguard Worker// policy and the platform public policy files in order to use checkpolicy.
457*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
458*e4a36f41SAndroid Build Coastguard Worker    name: "odm_sepolicy.conf",
459*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
460*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
461*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
462*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
463*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy + [
464*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.plat_vendor}",
465*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.vendor}",
466*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.odm}",
467*e4a36f41SAndroid Build Coastguard Worker        ],
468*e4a36f41SAndroid Build Coastguard Worker    device_specific: true,
469*e4a36f41SAndroid Build Coastguard Worker    installable: false,
470*e4a36f41SAndroid Build Coastguard Worker}
471*e4a36f41SAndroid Build Coastguard Worker
472*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
473*e4a36f41SAndroid Build Coastguard Worker    name: "odm_sepolicy.cil.raw",
474*e4a36f41SAndroid Build Coastguard Worker    src: ":odm_sepolicy.conf",
475*e4a36f41SAndroid Build Coastguard Worker    filter_out: [
476*e4a36f41SAndroid Build Coastguard Worker        ":reqd_policy_mask.cil",
477*e4a36f41SAndroid Build Coastguard Worker        ":vendor_sepolicy.cil",
478*e4a36f41SAndroid Build Coastguard Worker    ],
479*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false, // will be done in se_versioned_policy module
480*e4a36f41SAndroid Build Coastguard Worker    device_specific: true,
481*e4a36f41SAndroid Build Coastguard Worker    installable: false,
482*e4a36f41SAndroid Build Coastguard Worker}
483*e4a36f41SAndroid Build Coastguard Worker
484*e4a36f41SAndroid Build Coastguard Workerse_versioned_policy {
485*e4a36f41SAndroid Build Coastguard Worker    name: "odm_sepolicy.cil",
486*e4a36f41SAndroid Build Coastguard Worker    base: ":pub_policy.cil",
487*e4a36f41SAndroid Build Coastguard Worker    target_policy: ":odm_sepolicy.cil.raw",
488*e4a36f41SAndroid Build Coastguard Worker    version: "vendor",
489*e4a36f41SAndroid Build Coastguard Worker    dependent_cils: [
490*e4a36f41SAndroid Build Coastguard Worker        ":plat_sepolicy.cil",
491*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_sepolicy.cil",
492*e4a36f41SAndroid Build Coastguard Worker        ":product_sepolicy.cil",
493*e4a36f41SAndroid Build Coastguard Worker        ":plat_pub_versioned.cil",
494*e4a36f41SAndroid Build Coastguard Worker        ":plat_mapping_file",
495*e4a36f41SAndroid Build Coastguard Worker        ":vendor_sepolicy.cil",
496*e4a36f41SAndroid Build Coastguard Worker    ],
497*e4a36f41SAndroid Build Coastguard Worker    filter_out: [
498*e4a36f41SAndroid Build Coastguard Worker        ":plat_pub_versioned.cil",
499*e4a36f41SAndroid Build Coastguard Worker        ":vendor_sepolicy.cil",
500*e4a36f41SAndroid Build Coastguard Worker    ],
501*e4a36f41SAndroid Build Coastguard Worker    device_specific: true,
502*e4a36f41SAndroid Build Coastguard Worker}
503*e4a36f41SAndroid Build Coastguard Worker
504*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
505*e4a36f41SAndroid Build Coastguard Worker// Precompiled sepolicy is loaded if and only if:
506*e4a36f41SAndroid Build Coastguard Worker// - plat_sepolicy_and_mapping.sha256 equals
507*e4a36f41SAndroid Build Coastguard Worker//   precompiled_sepolicy.plat_sepolicy_and_mapping.sha256
508*e4a36f41SAndroid Build Coastguard Worker// AND
509*e4a36f41SAndroid Build Coastguard Worker// - system_ext_sepolicy_and_mapping.sha256 equals
510*e4a36f41SAndroid Build Coastguard Worker//   precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256
511*e4a36f41SAndroid Build Coastguard Worker// AND
512*e4a36f41SAndroid Build Coastguard Worker// - product_sepolicy_and_mapping.sha256 equals
513*e4a36f41SAndroid Build Coastguard Worker//   precompiled_sepolicy.product_sepolicy_and_mapping.sha256
514*e4a36f41SAndroid Build Coastguard Worker// See system/core/init/selinux.cpp for details.
515*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
516*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
517*e4a36f41SAndroid Build Coastguard Worker    name: "plat_sepolicy_and_mapping.sha256_gen",
518*e4a36f41SAndroid Build Coastguard Worker    srcs: [
519*e4a36f41SAndroid Build Coastguard Worker        ":plat_sepolicy.cil",
520*e4a36f41SAndroid Build Coastguard Worker        ":plat_mapping_file",
521*e4a36f41SAndroid Build Coastguard Worker    ],
522*e4a36f41SAndroid Build Coastguard Worker    out: ["plat_sepolicy_and_mapping.sha256"],
523*e4a36f41SAndroid Build Coastguard Worker    cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
524*e4a36f41SAndroid Build Coastguard Worker}
525*e4a36f41SAndroid Build Coastguard Worker
526*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
527*e4a36f41SAndroid Build Coastguard Worker    name: "plat_sepolicy_and_mapping.sha256",
528*e4a36f41SAndroid Build Coastguard Worker    filename: "plat_sepolicy_and_mapping.sha256",
529*e4a36f41SAndroid Build Coastguard Worker    src: ":plat_sepolicy_and_mapping.sha256_gen",
530*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
531*e4a36f41SAndroid Build Coastguard Worker}
532*e4a36f41SAndroid Build Coastguard Worker
533*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
534*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_sepolicy_and_mapping.sha256_gen",
535*e4a36f41SAndroid Build Coastguard Worker    srcs: [
536*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_sepolicy.cil",
537*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_mapping_file",
538*e4a36f41SAndroid Build Coastguard Worker    ],
539*e4a36f41SAndroid Build Coastguard Worker    out: ["system_ext_sepolicy_and_mapping.sha256"],
540*e4a36f41SAndroid Build Coastguard Worker    cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
541*e4a36f41SAndroid Build Coastguard Worker}
542*e4a36f41SAndroid Build Coastguard Worker
543*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
544*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_sepolicy_and_mapping.sha256",
545*e4a36f41SAndroid Build Coastguard Worker    filename: "system_ext_sepolicy_and_mapping.sha256",
546*e4a36f41SAndroid Build Coastguard Worker    src: ":system_ext_sepolicy_and_mapping.sha256_gen",
547*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
548*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
549*e4a36f41SAndroid Build Coastguard Worker}
550*e4a36f41SAndroid Build Coastguard Worker
551*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
552*e4a36f41SAndroid Build Coastguard Worker    name: "product_sepolicy_and_mapping.sha256_gen",
553*e4a36f41SAndroid Build Coastguard Worker    srcs: [
554*e4a36f41SAndroid Build Coastguard Worker        ":product_sepolicy.cil",
555*e4a36f41SAndroid Build Coastguard Worker        ":product_mapping_file",
556*e4a36f41SAndroid Build Coastguard Worker    ],
557*e4a36f41SAndroid Build Coastguard Worker    out: ["product_sepolicy_and_mapping.sha256"],
558*e4a36f41SAndroid Build Coastguard Worker    cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)",
559*e4a36f41SAndroid Build Coastguard Worker}
560*e4a36f41SAndroid Build Coastguard Worker
561*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
562*e4a36f41SAndroid Build Coastguard Worker    name: "product_sepolicy_and_mapping.sha256",
563*e4a36f41SAndroid Build Coastguard Worker    filename: "product_sepolicy_and_mapping.sha256",
564*e4a36f41SAndroid Build Coastguard Worker    src: ":product_sepolicy_and_mapping.sha256_gen",
565*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
566*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
567*e4a36f41SAndroid Build Coastguard Worker}
568*e4a36f41SAndroid Build Coastguard Worker
569*e4a36f41SAndroid Build Coastguard Workersepolicy_vers {
570*e4a36f41SAndroid Build Coastguard Worker    name: "plat_sepolicy_vers.txt",
571*e4a36f41SAndroid Build Coastguard Worker    version: "vendor",
572*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
573*e4a36f41SAndroid Build Coastguard Worker}
574*e4a36f41SAndroid Build Coastguard Worker
575*e4a36f41SAndroid Build Coastguard Workergenrule {
576*e4a36f41SAndroid Build Coastguard Worker    name: "genfs_labels_version.txt.gen",
577*e4a36f41SAndroid Build Coastguard Worker    out: ["genfs_labels_version.txt"],
578*e4a36f41SAndroid Build Coastguard Worker    cmd: select(soong_config_variable("ANDROID", "BOARD_GENFS_LABELS_VERSION"), {
579*e4a36f41SAndroid Build Coastguard Worker        any @ value: "echo " + value + " > $(out)",
580*e4a36f41SAndroid Build Coastguard Worker        default: "echo > $(out)",
581*e4a36f41SAndroid Build Coastguard Worker    }),
582*e4a36f41SAndroid Build Coastguard Worker}
583*e4a36f41SAndroid Build Coastguard Worker
584*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
585*e4a36f41SAndroid Build Coastguard Worker    name: "genfs_labels_version.txt",
586*e4a36f41SAndroid Build Coastguard Worker    src: ":genfs_labels_version.txt.gen",
587*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
588*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
589*e4a36f41SAndroid Build Coastguard Worker}
590*e4a36f41SAndroid Build Coastguard Worker
591*e4a36f41SAndroid Build Coastguard Workersoong_config_module_type {
592*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy_prebuilts_defaults",
593*e4a36f41SAndroid Build Coastguard Worker    module_type: "prebuilt_defaults",
594*e4a36f41SAndroid Build Coastguard Worker    config_namespace: "ANDROID",
595*e4a36f41SAndroid Build Coastguard Worker    bool_variables: ["BOARD_USES_ODMIMAGE"],
596*e4a36f41SAndroid Build Coastguard Worker    properties: [
597*e4a36f41SAndroid Build Coastguard Worker        "vendor",
598*e4a36f41SAndroid Build Coastguard Worker        "device_specific",
599*e4a36f41SAndroid Build Coastguard Worker    ],
600*e4a36f41SAndroid Build Coastguard Worker}
601*e4a36f41SAndroid Build Coastguard Worker
602*e4a36f41SAndroid Build Coastguard Workerprecompiled_sepolicy_prebuilts_defaults {
603*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy_prebuilts",
604*e4a36f41SAndroid Build Coastguard Worker    soong_config_variables: {
605*e4a36f41SAndroid Build Coastguard Worker        BOARD_USES_ODMIMAGE: {
606*e4a36f41SAndroid Build Coastguard Worker            device_specific: true,
607*e4a36f41SAndroid Build Coastguard Worker            conditions_default: {
608*e4a36f41SAndroid Build Coastguard Worker                vendor: true,
609*e4a36f41SAndroid Build Coastguard Worker            },
610*e4a36f41SAndroid Build Coastguard Worker        },
611*e4a36f41SAndroid Build Coastguard Worker    },
612*e4a36f41SAndroid Build Coastguard Worker}
613*e4a36f41SAndroid Build Coastguard Worker
614*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
615*e4a36f41SAndroid Build Coastguard Worker// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against
616*e4a36f41SAndroid Build Coastguard Worker// which precompiled_policy was built.
617*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
618*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
619*e4a36f41SAndroid Build Coastguard Worker    defaults: ["precompiled_sepolicy_prebuilts"],
620*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
621*e4a36f41SAndroid Build Coastguard Worker    filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
622*e4a36f41SAndroid Build Coastguard Worker    src: ":plat_sepolicy_and_mapping.sha256_gen",
623*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
624*e4a36f41SAndroid Build Coastguard Worker}
625*e4a36f41SAndroid Build Coastguard Worker
626*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
627*e4a36f41SAndroid Build Coastguard Worker// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against
628*e4a36f41SAndroid Build Coastguard Worker// which precompiled_policy was built.
629*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
630*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
631*e4a36f41SAndroid Build Coastguard Worker    defaults: ["precompiled_sepolicy_prebuilts"],
632*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
633*e4a36f41SAndroid Build Coastguard Worker    filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
634*e4a36f41SAndroid Build Coastguard Worker    src: ":system_ext_sepolicy_and_mapping.sha256_gen",
635*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
636*e4a36f41SAndroid Build Coastguard Worker}
637*e4a36f41SAndroid Build Coastguard Worker
638*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
639*e4a36f41SAndroid Build Coastguard Worker// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against
640*e4a36f41SAndroid Build Coastguard Worker// which precompiled_policy was built.
641*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
642*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
643*e4a36f41SAndroid Build Coastguard Worker    defaults: ["precompiled_sepolicy_prebuilts"],
644*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
645*e4a36f41SAndroid Build Coastguard Worker    filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
646*e4a36f41SAndroid Build Coastguard Worker    src: ":product_sepolicy_and_mapping.sha256_gen",
647*e4a36f41SAndroid Build Coastguard Worker    relative_install_path: "selinux",
648*e4a36f41SAndroid Build Coastguard Worker}
649*e4a36f41SAndroid Build Coastguard Worker
650*e4a36f41SAndroid Build Coastguard Workersoong_config_module_type {
651*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_se_policy_binary",
652*e4a36f41SAndroid Build Coastguard Worker    module_type: "se_policy_binary",
653*e4a36f41SAndroid Build Coastguard Worker    config_namespace: "ANDROID",
654*e4a36f41SAndroid Build Coastguard Worker    bool_variables: ["BOARD_USES_ODMIMAGE"],
655*e4a36f41SAndroid Build Coastguard Worker    properties: [
656*e4a36f41SAndroid Build Coastguard Worker        "vendor",
657*e4a36f41SAndroid Build Coastguard Worker        "device_specific",
658*e4a36f41SAndroid Build Coastguard Worker    ],
659*e4a36f41SAndroid Build Coastguard Worker}
660*e4a36f41SAndroid Build Coastguard Worker
661*e4a36f41SAndroid Build Coastguard Workerfilegroup {
662*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy_srcs",
663*e4a36f41SAndroid Build Coastguard Worker    device_common_srcs: [
664*e4a36f41SAndroid Build Coastguard Worker        ":plat_sepolicy.cil",
665*e4a36f41SAndroid Build Coastguard Worker        ":plat_pub_versioned.cil",
666*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_sepolicy.cil",
667*e4a36f41SAndroid Build Coastguard Worker        ":product_sepolicy.cil",
668*e4a36f41SAndroid Build Coastguard Worker        ":vendor_sepolicy.cil",
669*e4a36f41SAndroid Build Coastguard Worker        ":odm_sepolicy.cil",
670*e4a36f41SAndroid Build Coastguard Worker        ":plat_mapping_file",
671*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_mapping_file",
672*e4a36f41SAndroid Build Coastguard Worker        ":product_mapping_file",
673*e4a36f41SAndroid Build Coastguard Worker    ],
674*e4a36f41SAndroid Build Coastguard Worker    device_first_srcs: select(soong_config_variable("ANDROID", "BOARD_GENFS_LABELS_VERSION"), {
675*e4a36f41SAndroid Build Coastguard Worker        "202504": [":plat_sepolicy_genfs_202504.cil"],
676*e4a36f41SAndroid Build Coastguard Worker        default: [],
677*e4a36f41SAndroid Build Coastguard Worker    }),
678*e4a36f41SAndroid Build Coastguard Worker    // Make precompiled_sepolicy_srcs as public so that OEMs have access to them.
679*e4a36f41SAndroid Build Coastguard Worker    // Useful when some partitions need to be bind mounted across VM boundaries.
680*e4a36f41SAndroid Build Coastguard Worker    visibility: ["//visibility:public"],
681*e4a36f41SAndroid Build Coastguard Worker}
682*e4a36f41SAndroid Build Coastguard Worker
683*e4a36f41SAndroid Build Coastguard Workerprecompiled_se_policy_binary {
684*e4a36f41SAndroid Build Coastguard Worker    name: "precompiled_sepolicy",
685*e4a36f41SAndroid Build Coastguard Worker    srcs: [
686*e4a36f41SAndroid Build Coastguard Worker        ":precompiled_sepolicy_srcs",
687*e4a36f41SAndroid Build Coastguard Worker    ],
688*e4a36f41SAndroid Build Coastguard Worker    soong_config_variables: {
689*e4a36f41SAndroid Build Coastguard Worker        BOARD_USES_ODMIMAGE: {
690*e4a36f41SAndroid Build Coastguard Worker            device_specific: true,
691*e4a36f41SAndroid Build Coastguard Worker            conditions_default: {
692*e4a36f41SAndroid Build Coastguard Worker                vendor: true,
693*e4a36f41SAndroid Build Coastguard Worker            },
694*e4a36f41SAndroid Build Coastguard Worker        },
695*e4a36f41SAndroid Build Coastguard Worker    },
696*e4a36f41SAndroid Build Coastguard Worker    required: [
697*e4a36f41SAndroid Build Coastguard Worker        "sepolicy_neverallows",
698*e4a36f41SAndroid Build Coastguard Worker    ],
699*e4a36f41SAndroid Build Coastguard Worker    dist: {
700*e4a36f41SAndroid Build Coastguard Worker        targets: ["base-sepolicy-files-for-mapping"],
701*e4a36f41SAndroid Build Coastguard Worker    },
702*e4a36f41SAndroid Build Coastguard Worker}
703*e4a36f41SAndroid Build Coastguard Worker
704*e4a36f41SAndroid Build Coastguard Worker// policy for recovery
705*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
706*e4a36f41SAndroid Build Coastguard Worker    name: "recovery_sepolicy.conf",
707*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
708*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
709*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy +
710*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
711*e4a36f41SAndroid Build Coastguard Worker        system_ext_private_policy +
712*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
713*e4a36f41SAndroid Build Coastguard Worker        product_private_policy + [
714*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.plat_vendor}",
715*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.vendor}",
716*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.odm}",
717*e4a36f41SAndroid Build Coastguard Worker        ],
718*e4a36f41SAndroid Build Coastguard Worker    target_recovery: true,
719*e4a36f41SAndroid Build Coastguard Worker    installable: false,
720*e4a36f41SAndroid Build Coastguard Worker    recovery: true,
721*e4a36f41SAndroid Build Coastguard Worker}
722*e4a36f41SAndroid Build Coastguard Worker
723*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
724*e4a36f41SAndroid Build Coastguard Worker    name: "recovery_sepolicy.cil",
725*e4a36f41SAndroid Build Coastguard Worker    src: ":recovery_sepolicy.conf",
726*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false, // will be done in se_policy_binary module
727*e4a36f41SAndroid Build Coastguard Worker    installable: false,
728*e4a36f41SAndroid Build Coastguard Worker    recovery: true,
729*e4a36f41SAndroid Build Coastguard Worker}
730*e4a36f41SAndroid Build Coastguard Worker
731*e4a36f41SAndroid Build Coastguard Workerse_policy_binary {
732*e4a36f41SAndroid Build Coastguard Worker    name: "sepolicy.recovery",
733*e4a36f41SAndroid Build Coastguard Worker    srcs: [":recovery_sepolicy.cil"],
734*e4a36f41SAndroid Build Coastguard Worker    stem: "sepolicy",
735*e4a36f41SAndroid Build Coastguard Worker    recovery: true,
736*e4a36f41SAndroid Build Coastguard Worker}
737*e4a36f41SAndroid Build Coastguard Worker
738*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
739*e4a36f41SAndroid Build Coastguard Worker// SELinux policy embedded into CTS.
740*e4a36f41SAndroid Build Coastguard Worker// CTS checks neverallow rules of this policy against the policy of the device under test.
741*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
742*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
743*e4a36f41SAndroid Build Coastguard Worker    name: "general_sepolicy.conf",
744*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
745*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
746*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy,
747*e4a36f41SAndroid Build Coastguard Worker    build_variant: "user",
748*e4a36f41SAndroid Build Coastguard Worker    cts: true,
749*e4a36f41SAndroid Build Coastguard Worker    exclude_build_test: true,
750*e4a36f41SAndroid Build Coastguard Worker    dist: {
751*e4a36f41SAndroid Build Coastguard Worker        targets: ["sepolicy_finalize"],
752*e4a36f41SAndroid Build Coastguard Worker    },
753*e4a36f41SAndroid Build Coastguard Worker}
754*e4a36f41SAndroid Build Coastguard Worker
755*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
756*e4a36f41SAndroid Build Coastguard Worker// Base system policy for treble sepolicy tests.
757*e4a36f41SAndroid Build Coastguard Worker// If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ
758*e4a36f41SAndroid Build Coastguard Worker// with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case,
759*e4a36f41SAndroid Build Coastguard Worker// BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil.
760*e4a36f41SAndroid Build Coastguard Worker// See treble_sepolicy_tests_for_release.mk for more details.
761*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
762*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
763*e4a36f41SAndroid Build Coastguard Worker    name: "base_plat_sepolicy.conf",
764*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
765*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
766*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy,
767*e4a36f41SAndroid Build Coastguard Worker    build_variant: "user",
768*e4a36f41SAndroid Build Coastguard Worker    installable: false,
769*e4a36f41SAndroid Build Coastguard Worker}
770*e4a36f41SAndroid Build Coastguard Worker
771*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
772*e4a36f41SAndroid Build Coastguard Worker    name: "base_plat_sepolicy.cil",
773*e4a36f41SAndroid Build Coastguard Worker    src: ":base_plat_sepolicy.conf",
774*e4a36f41SAndroid Build Coastguard Worker    additional_cil_files: ["private/technical_debt.cil"],
775*e4a36f41SAndroid Build Coastguard Worker    installable: false,
776*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false, // done by se_policy_binary
777*e4a36f41SAndroid Build Coastguard Worker}
778*e4a36f41SAndroid Build Coastguard Worker
779*e4a36f41SAndroid Build Coastguard Workerse_policy_binary {
780*e4a36f41SAndroid Build Coastguard Worker    name: "base_plat_sepolicy",
781*e4a36f41SAndroid Build Coastguard Worker    srcs: [":base_plat_sepolicy.cil"],
782*e4a36f41SAndroid Build Coastguard Worker    installable: false,
783*e4a36f41SAndroid Build Coastguard Worker    dist: {
784*e4a36f41SAndroid Build Coastguard Worker        targets: ["base-sepolicy-files-for-mapping"],
785*e4a36f41SAndroid Build Coastguard Worker    },
786*e4a36f41SAndroid Build Coastguard Worker}
787*e4a36f41SAndroid Build Coastguard Worker
788*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
789*e4a36f41SAndroid Build Coastguard Worker    name: "base_product_sepolicy.conf",
790*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
791*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
792*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy +
793*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
794*e4a36f41SAndroid Build Coastguard Worker        system_ext_private_policy +
795*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
796*e4a36f41SAndroid Build Coastguard Worker        product_private_policy,
797*e4a36f41SAndroid Build Coastguard Worker    build_variant: "user",
798*e4a36f41SAndroid Build Coastguard Worker    installable: false,
799*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
800*e4a36f41SAndroid Build Coastguard Worker}
801*e4a36f41SAndroid Build Coastguard Worker
802*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
803*e4a36f41SAndroid Build Coastguard Worker    name: "base_product_sepolicy.cil",
804*e4a36f41SAndroid Build Coastguard Worker    src: ":base_product_sepolicy.conf",
805*e4a36f41SAndroid Build Coastguard Worker    additional_cil_files: ["private/technical_debt.cil"],
806*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
807*e4a36f41SAndroid Build Coastguard Worker    installable: false,
808*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false, // done by se_policy_binary
809*e4a36f41SAndroid Build Coastguard Worker}
810*e4a36f41SAndroid Build Coastguard Worker
811*e4a36f41SAndroid Build Coastguard Workerse_policy_binary {
812*e4a36f41SAndroid Build Coastguard Worker    name: "base_product_sepolicy",
813*e4a36f41SAndroid Build Coastguard Worker    srcs: [":base_product_sepolicy.cil"],
814*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
815*e4a36f41SAndroid Build Coastguard Worker    installable: false,
816*e4a36f41SAndroid Build Coastguard Worker}
817*e4a36f41SAndroid Build Coastguard Worker
818*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
819*e4a36f41SAndroid Build Coastguard Worker    name: "base_plat_pub_policy.conf",
820*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
821*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
822*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy,
823*e4a36f41SAndroid Build Coastguard Worker    build_variant: "user",
824*e4a36f41SAndroid Build Coastguard Worker    installable: false,
825*e4a36f41SAndroid Build Coastguard Worker}
826*e4a36f41SAndroid Build Coastguard Worker
827*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
828*e4a36f41SAndroid Build Coastguard Worker    name: "base_plat_pub_policy.cil",
829*e4a36f41SAndroid Build Coastguard Worker    src: ":base_plat_pub_policy.conf",
830*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
831*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
832*e4a36f41SAndroid Build Coastguard Worker    installable: false,
833*e4a36f41SAndroid Build Coastguard Worker    dist: {
834*e4a36f41SAndroid Build Coastguard Worker        targets: ["base-sepolicy-files-for-mapping"],
835*e4a36f41SAndroid Build Coastguard Worker    },
836*e4a36f41SAndroid Build Coastguard Worker}
837*e4a36f41SAndroid Build Coastguard Worker
838*e4a36f41SAndroid Build Coastguard Workerse_policy_conf {
839*e4a36f41SAndroid Build Coastguard Worker    name: "base_product_pub_policy.conf",
840*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
841*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
842*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
843*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
844*e4a36f41SAndroid Build Coastguard Worker        reqd_mask_policy,
845*e4a36f41SAndroid Build Coastguard Worker    build_variant: "user",
846*e4a36f41SAndroid Build Coastguard Worker    installable: false,
847*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
848*e4a36f41SAndroid Build Coastguard Worker}
849*e4a36f41SAndroid Build Coastguard Worker
850*e4a36f41SAndroid Build Coastguard Workerse_policy_cil {
851*e4a36f41SAndroid Build Coastguard Worker    name: "base_product_pub_policy.cil",
852*e4a36f41SAndroid Build Coastguard Worker    src: ":base_product_pub_policy.conf",
853*e4a36f41SAndroid Build Coastguard Worker    filter_out: [":reqd_policy_mask.cil"],
854*e4a36f41SAndroid Build Coastguard Worker    secilc_check: false,
855*e4a36f41SAndroid Build Coastguard Worker    installable: false,
856*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
857*e4a36f41SAndroid Build Coastguard Worker}
858*e4a36f41SAndroid Build Coastguard Worker
859*e4a36f41SAndroid Build Coastguard Worker// bug_map - Bug tracking information for selinux denials loaded by auditd.
860*e4a36f41SAndroid Build Coastguard Workerse_build_files {
861*e4a36f41SAndroid Build Coastguard Worker    name: "bug_map_files",
862*e4a36f41SAndroid Build Coastguard Worker    srcs: ["bug_map"],
863*e4a36f41SAndroid Build Coastguard Worker}
864*e4a36f41SAndroid Build Coastguard Worker
865*e4a36f41SAndroid Build Coastguard Workerse_bug_map {
866*e4a36f41SAndroid Build Coastguard Worker    name: "plat_bug_map",
867*e4a36f41SAndroid Build Coastguard Worker    srcs: [":bug_map_files{.plat_private}"],
868*e4a36f41SAndroid Build Coastguard Worker    stem: "bug_map",
869*e4a36f41SAndroid Build Coastguard Worker}
870*e4a36f41SAndroid Build Coastguard Worker
871*e4a36f41SAndroid Build Coastguard Workerse_bug_map {
872*e4a36f41SAndroid Build Coastguard Worker    name: "system_ext_bug_map",
873*e4a36f41SAndroid Build Coastguard Worker    srcs: [":bug_map_files{.system_ext_private}"],
874*e4a36f41SAndroid Build Coastguard Worker    stem: "bug_map",
875*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
876*e4a36f41SAndroid Build Coastguard Worker}
877*e4a36f41SAndroid Build Coastguard Worker
878*e4a36f41SAndroid Build Coastguard Workerse_bug_map {
879*e4a36f41SAndroid Build Coastguard Worker    name: "vendor_bug_map",
880*e4a36f41SAndroid Build Coastguard Worker    srcs: [
881*e4a36f41SAndroid Build Coastguard Worker        ":bug_map_files{.vendor}",
882*e4a36f41SAndroid Build Coastguard Worker        ":bug_map_files{.plat_vendor}",
883*e4a36f41SAndroid Build Coastguard Worker    ],
884*e4a36f41SAndroid Build Coastguard Worker    // Legacy file name of the vendor partition bug_map.
885*e4a36f41SAndroid Build Coastguard Worker    stem: "selinux_denial_metadata",
886*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
887*e4a36f41SAndroid Build Coastguard Worker}
888*e4a36f41SAndroid Build Coastguard Worker
889*e4a36f41SAndroid Build Coastguard Workerse_neverallow_test {
890*e4a36f41SAndroid Build Coastguard Worker    name: "sepolicy_neverallows",
891*e4a36f41SAndroid Build Coastguard Worker    defaults: ["se_policy_conf_flags_defaults"],
892*e4a36f41SAndroid Build Coastguard Worker    srcs: plat_public_policy +
893*e4a36f41SAndroid Build Coastguard Worker        plat_private_policy +
894*e4a36f41SAndroid Build Coastguard Worker        system_ext_public_policy +
895*e4a36f41SAndroid Build Coastguard Worker        system_ext_private_policy +
896*e4a36f41SAndroid Build Coastguard Worker        product_public_policy +
897*e4a36f41SAndroid Build Coastguard Worker        product_private_policy + [
898*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.plat_vendor}",
899*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.vendor}",
900*e4a36f41SAndroid Build Coastguard Worker            ":se_build_files{.odm}",
901*e4a36f41SAndroid Build Coastguard Worker        ],
902*e4a36f41SAndroid Build Coastguard Worker}
903*e4a36f41SAndroid Build Coastguard Worker
904*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
905*e4a36f41SAndroid Build Coastguard Worker// se_freeze_test compares the plat sepolicy with the prebuilt sepolicy
906*e4a36f41SAndroid Build Coastguard Worker// Additional directories can be specified via Makefile variables:
907*e4a36f41SAndroid Build Coastguard Worker// SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS.
908*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
909*e4a36f41SAndroid Build Coastguard Workerse_freeze_test {
910*e4a36f41SAndroid Build Coastguard Worker    name: "se_freeze_test",
911*e4a36f41SAndroid Build Coastguard Worker}
912*e4a36f41SAndroid Build Coastguard Worker
913*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
914*e4a36f41SAndroid Build Coastguard Worker// sepolicy_test checks various types of violations, which can't be easily done
915*e4a36f41SAndroid Build Coastguard Worker// by CIL itself. Refer tests/sepolicy_tests.py for more detail.
916*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
917*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
918*e4a36f41SAndroid Build Coastguard Worker    name: "sepolicy_test",
919*e4a36f41SAndroid Build Coastguard Worker    srcs: [
920*e4a36f41SAndroid Build Coastguard Worker        ":plat_file_contexts",
921*e4a36f41SAndroid Build Coastguard Worker        ":vendor_file_contexts",
922*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_file_contexts",
923*e4a36f41SAndroid Build Coastguard Worker        ":product_file_contexts",
924*e4a36f41SAndroid Build Coastguard Worker        ":odm_file_contexts",
925*e4a36f41SAndroid Build Coastguard Worker        ":precompiled_sepolicy",
926*e4a36f41SAndroid Build Coastguard Worker    ],
927*e4a36f41SAndroid Build Coastguard Worker    tools: ["sepolicy_tests"],
928*e4a36f41SAndroid Build Coastguard Worker    out: ["sepolicy_test"],
929*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location sepolicy_tests) " +
930*e4a36f41SAndroid Build Coastguard Worker        "-f $(location :plat_file_contexts) " +
931*e4a36f41SAndroid Build Coastguard Worker        "-f $(location :vendor_file_contexts) " +
932*e4a36f41SAndroid Build Coastguard Worker        "-f $(location :system_ext_file_contexts) " +
933*e4a36f41SAndroid Build Coastguard Worker        "-f $(location :product_file_contexts) " +
934*e4a36f41SAndroid Build Coastguard Worker        "-f $(location :odm_file_contexts) " +
935*e4a36f41SAndroid Build Coastguard Worker        "-p $(location :precompiled_sepolicy) && " +
936*e4a36f41SAndroid Build Coastguard Worker        "touch $(out)",
937*e4a36f41SAndroid Build Coastguard Worker}
938*e4a36f41SAndroid Build Coastguard Worker
939*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
940*e4a36f41SAndroid Build Coastguard Worker// TestDevTypeViolations can't run on old devices (V or before)
941*e4a36f41SAndroid Build Coastguard Worker//////////////////////////////////
942*e4a36f41SAndroid Build Coastguard Worker
943*e4a36f41SAndroid Build Coastguard Workersoong_config_module_type {
944*e4a36f41SAndroid Build Coastguard Worker    name: "dev_type_test_genrule",
945*e4a36f41SAndroid Build Coastguard Worker    module_type: "java_genrule",
946*e4a36f41SAndroid Build Coastguard Worker    config_namespace: "ANDROID",
947*e4a36f41SAndroid Build Coastguard Worker    bool_variables: ["CHECK_DEV_TYPE_VIOLATIONS"],
948*e4a36f41SAndroid Build Coastguard Worker    properties: ["cmd"],
949*e4a36f41SAndroid Build Coastguard Worker}
950*e4a36f41SAndroid Build Coastguard Worker
951*e4a36f41SAndroid Build Coastguard Workerdev_type_test_genrule {
952*e4a36f41SAndroid Build Coastguard Worker    name: "sepolicy_dev_type_test",
953*e4a36f41SAndroid Build Coastguard Worker    srcs: [
954*e4a36f41SAndroid Build Coastguard Worker        ":plat_file_contexts",
955*e4a36f41SAndroid Build Coastguard Worker        ":vendor_file_contexts",
956*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_file_contexts",
957*e4a36f41SAndroid Build Coastguard Worker        ":product_file_contexts",
958*e4a36f41SAndroid Build Coastguard Worker        ":odm_file_contexts",
959*e4a36f41SAndroid Build Coastguard Worker        ":precompiled_sepolicy",
960*e4a36f41SAndroid Build Coastguard Worker    ],
961*e4a36f41SAndroid Build Coastguard Worker    tools: ["sepolicy_tests"],
962*e4a36f41SAndroid Build Coastguard Worker    out: ["sepolicy_dev_type_test"],
963*e4a36f41SAndroid Build Coastguard Worker    soong_config_variables: {
964*e4a36f41SAndroid Build Coastguard Worker        CHECK_DEV_TYPE_VIOLATIONS: {
965*e4a36f41SAndroid Build Coastguard Worker            cmd: "$(location sepolicy_tests) " +
966*e4a36f41SAndroid Build Coastguard Worker                "-f $(location :plat_file_contexts) " +
967*e4a36f41SAndroid Build Coastguard Worker                "-f $(location :vendor_file_contexts) " +
968*e4a36f41SAndroid Build Coastguard Worker                "-f $(location :system_ext_file_contexts) " +
969*e4a36f41SAndroid Build Coastguard Worker                "-f $(location :product_file_contexts) " +
970*e4a36f41SAndroid Build Coastguard Worker                "-f $(location :odm_file_contexts) " +
971*e4a36f41SAndroid Build Coastguard Worker                "-p $(location :precompiled_sepolicy) " +
972*e4a36f41SAndroid Build Coastguard Worker                "-t TestDevTypeViolations && " +
973*e4a36f41SAndroid Build Coastguard Worker                "touch $(out)",
974*e4a36f41SAndroid Build Coastguard Worker            conditions_default: {
975*e4a36f41SAndroid Build Coastguard Worker                cmd: "touch $(out)",
976*e4a36f41SAndroid Build Coastguard Worker            },
977*e4a36f41SAndroid Build Coastguard Worker        },
978*e4a36f41SAndroid Build Coastguard Worker    },
979*e4a36f41SAndroid Build Coastguard Worker}
980*e4a36f41SAndroid Build Coastguard Worker
981*e4a36f41SAndroid Build Coastguard Workerphony {
982*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_system_ext",
983*e4a36f41SAndroid Build Coastguard Worker    required: [
984*e4a36f41SAndroid Build Coastguard Worker        //"ifdef HAS_SYSTEM_EXT_PUBLIC_SEPOLICY" check included in system_ext_pub_policy.cil
985*e4a36f41SAndroid Build Coastguard Worker        "system_ext_mapping_file",
986*e4a36f41SAndroid Build Coastguard Worker        //"ifdef HAS_SYSTEM_EXT_SEPOLICY" check included in .cil
987*e4a36f41SAndroid Build Coastguard Worker        "system_ext_sepolicy.cil",
988*e4a36f41SAndroid Build Coastguard Worker    ] + [
989*e4a36f41SAndroid Build Coastguard Worker        //"ifdef HAS_SYSTEM_EXT_SEPOLICY" check included in .cil
990*e4a36f41SAndroid Build Coastguard Worker        "system_ext_29.0.cil",
991*e4a36f41SAndroid Build Coastguard Worker        "system_ext_30.0.cil",
992*e4a36f41SAndroid Build Coastguard Worker        "system_ext_31.0.cil",
993*e4a36f41SAndroid Build Coastguard Worker        "system_ext_32.0.cil",
994*e4a36f41SAndroid Build Coastguard Worker        "system_ext_33.0.cil",
995*e4a36f41SAndroid Build Coastguard Worker        "system_ext_34.0.cil",
996*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
997*e4a36f41SAndroid Build Coastguard Worker        "202404": [],
998*e4a36f41SAndroid Build Coastguard Worker        default: [
999*e4a36f41SAndroid Build Coastguard Worker            "system_ext_202404.cil",
1000*e4a36f41SAndroid Build Coastguard Worker        ],
1001*e4a36f41SAndroid Build Coastguard Worker    }) +
1002*e4a36f41SAndroid Build Coastguard Worker    select(soong_config_variable("ANDROID", "PRODUCT_PRECOMPILED_SEPOLICY"), {
1003*e4a36f41SAndroid Build Coastguard Worker        true: ["system_ext_sepolicy_and_mapping.sha256"],
1004*e4a36f41SAndroid Build Coastguard Worker        default: [],
1005*e4a36f41SAndroid Build Coastguard Worker    }) + [
1006*e4a36f41SAndroid Build Coastguard Worker        "system_ext_file_contexts",
1007*e4a36f41SAndroid Build Coastguard Worker        "system_ext_file_contexts_test",
1008*e4a36f41SAndroid Build Coastguard Worker        "system_ext_keystore2_key_contexts",
1009*e4a36f41SAndroid Build Coastguard Worker        "system_ext_hwservice_contexts",
1010*e4a36f41SAndroid Build Coastguard Worker        "system_ext_hwservice_contexts_test",
1011*e4a36f41SAndroid Build Coastguard Worker        "system_ext_property_contexts",
1012*e4a36f41SAndroid Build Coastguard Worker        "system_ext_property_contexts_test",
1013*e4a36f41SAndroid Build Coastguard Worker        "system_ext_seapp_contexts",
1014*e4a36f41SAndroid Build Coastguard Worker        "system_ext_service_contexts",
1015*e4a36f41SAndroid Build Coastguard Worker        "system_ext_service_contexts_test",
1016*e4a36f41SAndroid Build Coastguard Worker        "system_ext_mac_permissions.xml",
1017*e4a36f41SAndroid Build Coastguard Worker        "system_ext_bug_map",
1018*e4a36f41SAndroid Build Coastguard Worker        // $(addprefix system_ext_,$(addsuffix .compat.cil,$(PLATFORM_SEPOLICY_COMPAT_VERSIONS))) \
1019*e4a36f41SAndroid Build Coastguard Worker        "system_ext_29.0.compat.cil",
1020*e4a36f41SAndroid Build Coastguard Worker        "system_ext_30.0.compat.cil",
1021*e4a36f41SAndroid Build Coastguard Worker        "system_ext_31.0.compat.cil",
1022*e4a36f41SAndroid Build Coastguard Worker        "system_ext_32.0.compat.cil",
1023*e4a36f41SAndroid Build Coastguard Worker        "system_ext_33.0.compat.cil",
1024*e4a36f41SAndroid Build Coastguard Worker        "system_ext_34.0.compat.cil",
1025*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
1026*e4a36f41SAndroid Build Coastguard Worker        "202404": [],
1027*e4a36f41SAndroid Build Coastguard Worker        default: [
1028*e4a36f41SAndroid Build Coastguard Worker            "system_ext_202404.compat.cil",
1029*e4a36f41SAndroid Build Coastguard Worker        ],
1030*e4a36f41SAndroid Build Coastguard Worker    }) + select(release_flag("RELEASE_AVF_ENABLE_VM_TO_TEE_SERVICES_ALLOWLIST"), {
1031*e4a36f41SAndroid Build Coastguard Worker        true: ["system_ext_tee_service_contexts"],
1032*e4a36f41SAndroid Build Coastguard Worker        default: [],
1033*e4a36f41SAndroid Build Coastguard Worker    }),
1034*e4a36f41SAndroid Build Coastguard Worker    system_ext_specific: true,
1035*e4a36f41SAndroid Build Coastguard Worker}
1036*e4a36f41SAndroid Build Coastguard Worker
1037*e4a36f41SAndroid Build Coastguard Workerphony {
1038*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_product",
1039*e4a36f41SAndroid Build Coastguard Worker    required: [
1040*e4a36f41SAndroid Build Coastguard Worker        "product_mapping_file",
1041*e4a36f41SAndroid Build Coastguard Worker        "product_sepolicy.cil",
1042*e4a36f41SAndroid Build Coastguard Worker        // "ifdef HAS_PRODUCT_PUBLIC_SEPOLICY" check included in .cil
1043*e4a36f41SAndroid Build Coastguard Worker        "product_29.0.cil",
1044*e4a36f41SAndroid Build Coastguard Worker        "product_30.0.cil",
1045*e4a36f41SAndroid Build Coastguard Worker        "product_31.0.cil",
1046*e4a36f41SAndroid Build Coastguard Worker        "product_32.0.cil",
1047*e4a36f41SAndroid Build Coastguard Worker        "product_33.0.cil",
1048*e4a36f41SAndroid Build Coastguard Worker        "product_34.0.cil",
1049*e4a36f41SAndroid Build Coastguard Worker        "product_file_contexts",
1050*e4a36f41SAndroid Build Coastguard Worker        // "ifdef HAS_PRODUCT_SEPOLICY_DIR" in Android.mk can be ignored.
1051*e4a36f41SAndroid Build Coastguard Worker        "product_file_contexts_test",
1052*e4a36f41SAndroid Build Coastguard Worker        "product_keystore2_key_contexts",
1053*e4a36f41SAndroid Build Coastguard Worker        "product_hwservice_contexts",
1054*e4a36f41SAndroid Build Coastguard Worker        "product_hwservice_contexts_test",
1055*e4a36f41SAndroid Build Coastguard Worker        "product_property_contexts",
1056*e4a36f41SAndroid Build Coastguard Worker        "product_property_contexts_test",
1057*e4a36f41SAndroid Build Coastguard Worker        "product_seapp_contexts",
1058*e4a36f41SAndroid Build Coastguard Worker        "product_service_contexts",
1059*e4a36f41SAndroid Build Coastguard Worker        "product_service_contexts_test",
1060*e4a36f41SAndroid Build Coastguard Worker        "product_mac_permissions.xml",
1061*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PRODUCT_PRECOMPILED_SEPOLICY"), {
1062*e4a36f41SAndroid Build Coastguard Worker        true: ["product_sepolicy_and_mapping.sha256"],
1063*e4a36f41SAndroid Build Coastguard Worker        default: [],
1064*e4a36f41SAndroid Build Coastguard Worker    }) + select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
1065*e4a36f41SAndroid Build Coastguard Worker        "202404": [],
1066*e4a36f41SAndroid Build Coastguard Worker        default: [
1067*e4a36f41SAndroid Build Coastguard Worker            "product_202404.cil",
1068*e4a36f41SAndroid Build Coastguard Worker        ],
1069*e4a36f41SAndroid Build Coastguard Worker    }) + select(release_flag("RELEASE_AVF_ENABLE_VM_TO_TEE_SERVICES_ALLOWLIST"), {
1070*e4a36f41SAndroid Build Coastguard Worker        true: ["product_tee_service_contexts"],
1071*e4a36f41SAndroid Build Coastguard Worker        default: [],
1072*e4a36f41SAndroid Build Coastguard Worker    }),
1073*e4a36f41SAndroid Build Coastguard Worker    product_specific: true,
1074*e4a36f41SAndroid Build Coastguard Worker}
1075*e4a36f41SAndroid Build Coastguard Worker
1076*e4a36f41SAndroid Build Coastguard Workerphony {
1077*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_nonsystem",
1078*e4a36f41SAndroid Build Coastguard Worker    required: [
1079*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_system_ext",
1080*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_product",
1081*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_vendor",
1082*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_odm",
1083*e4a36f41SAndroid Build Coastguard Worker        // Builds an additional userdebug sepolicy into the debug ramdisk.
1084*e4a36f41SAndroid Build Coastguard Worker        "userdebug_plat_sepolicy.cil",
1085*e4a36f41SAndroid Build Coastguard Worker    ],
1086*e4a36f41SAndroid Build Coastguard Worker}
1087*e4a36f41SAndroid Build Coastguard Worker
1088*e4a36f41SAndroid Build Coastguard Workerphony {
1089*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_vendor",
1090*e4a36f41SAndroid Build Coastguard Worker    required: [
1091*e4a36f41SAndroid Build Coastguard Worker        "genfs_labels_version.txt",
1092*e4a36f41SAndroid Build Coastguard Worker        "plat_pub_versioned.cil",
1093*e4a36f41SAndroid Build Coastguard Worker        "vendor_sepolicy.cil",
1094*e4a36f41SAndroid Build Coastguard Worker        "plat_sepolicy_vers.txt",
1095*e4a36f41SAndroid Build Coastguard Worker        "vendor_file_contexts",
1096*e4a36f41SAndroid Build Coastguard Worker        "vendor_file_contexts_test",
1097*e4a36f41SAndroid Build Coastguard Worker        "vendor_keystore2_key_contexts",
1098*e4a36f41SAndroid Build Coastguard Worker        "vendor_mac_permissions.xml",
1099*e4a36f41SAndroid Build Coastguard Worker        "vendor_property_contexts",
1100*e4a36f41SAndroid Build Coastguard Worker        "vendor_property_contexts_test",
1101*e4a36f41SAndroid Build Coastguard Worker        "vendor_seapp_contexts",
1102*e4a36f41SAndroid Build Coastguard Worker        "vendor_service_contexts",
1103*e4a36f41SAndroid Build Coastguard Worker        "vendor_service_contexts_test",
1104*e4a36f41SAndroid Build Coastguard Worker        "vendor_hwservice_contexts",
1105*e4a36f41SAndroid Build Coastguard Worker        "vendor_hwservice_contexts_test",
1106*e4a36f41SAndroid Build Coastguard Worker        "vendor_bug_map",
1107*e4a36f41SAndroid Build Coastguard Worker        "vndservice_contexts",
1108*e4a36f41SAndroid Build Coastguard Worker        "vndservice_contexts_test",
1109*e4a36f41SAndroid Build Coastguard Worker    ] + select(release_flag("RELEASE_AVF_ENABLE_VM_TO_TEE_SERVICES_ALLOWLIST"), {
1110*e4a36f41SAndroid Build Coastguard Worker        true: ["vendor_tee_service_contexts"],
1111*e4a36f41SAndroid Build Coastguard Worker        default: [],
1112*e4a36f41SAndroid Build Coastguard Worker    }),
1113*e4a36f41SAndroid Build Coastguard Worker    vendor: true,
1114*e4a36f41SAndroid Build Coastguard Worker}
1115*e4a36f41SAndroid Build Coastguard Worker
1116*e4a36f41SAndroid Build Coastguard Workerphony {
1117*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_odm",
1118*e4a36f41SAndroid Build Coastguard Worker    required: [
1119*e4a36f41SAndroid Build Coastguard Worker        "odm_sepolicy.cil",
1120*e4a36f41SAndroid Build Coastguard Worker        "odm_file_contexts",
1121*e4a36f41SAndroid Build Coastguard Worker        "odm_file_contexts_test",
1122*e4a36f41SAndroid Build Coastguard Worker        "odm_seapp_contexts",
1123*e4a36f41SAndroid Build Coastguard Worker        "odm_property_contexts",
1124*e4a36f41SAndroid Build Coastguard Worker        "odm_property_contexts_test",
1125*e4a36f41SAndroid Build Coastguard Worker        "odm_service_contexts",
1126*e4a36f41SAndroid Build Coastguard Worker        "odm_service_contexts_test",
1127*e4a36f41SAndroid Build Coastguard Worker        "odm_hwservice_contexts",
1128*e4a36f41SAndroid Build Coastguard Worker        "odm_hwservice_contexts_test",
1129*e4a36f41SAndroid Build Coastguard Worker        "odm_mac_permissions.xml",
1130*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PRODUCT_PRECOMPILED_SEPOLICY"), {
1131*e4a36f41SAndroid Build Coastguard Worker        true: [
1132*e4a36f41SAndroid Build Coastguard Worker            "precompiled_sepolicy",
1133*e4a36f41SAndroid Build Coastguard Worker            "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",
1134*e4a36f41SAndroid Build Coastguard Worker            "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256",
1135*e4a36f41SAndroid Build Coastguard Worker            "precompiled_sepolicy.product_sepolicy_and_mapping.sha256",
1136*e4a36f41SAndroid Build Coastguard Worker        ],
1137*e4a36f41SAndroid Build Coastguard Worker        default: [],
1138*e4a36f41SAndroid Build Coastguard Worker    }),
1139*e4a36f41SAndroid Build Coastguard Worker    device_specific: true,
1140*e4a36f41SAndroid Build Coastguard Worker}
1141*e4a36f41SAndroid Build Coastguard Worker
1142*e4a36f41SAndroid Build Coastguard Workerphony {
1143*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy_system",
1144*e4a36f41SAndroid Build Coastguard Worker    required: [
1145*e4a36f41SAndroid Build Coastguard Worker        "29.0.compat.cil",
1146*e4a36f41SAndroid Build Coastguard Worker        "30.0.compat.cil",
1147*e4a36f41SAndroid Build Coastguard Worker        "31.0.compat.cil",
1148*e4a36f41SAndroid Build Coastguard Worker        "32.0.compat.cil",
1149*e4a36f41SAndroid Build Coastguard Worker        "33.0.compat.cil",
1150*e4a36f41SAndroid Build Coastguard Worker        "34.0.compat.cil",
1151*e4a36f41SAndroid Build Coastguard Worker        "build_sepolicy",
1152*e4a36f41SAndroid Build Coastguard Worker        "fuzzer_bindings_test",
1153*e4a36f41SAndroid Build Coastguard Worker        "plat_29.0.cil",
1154*e4a36f41SAndroid Build Coastguard Worker        "plat_30.0.cil",
1155*e4a36f41SAndroid Build Coastguard Worker        "plat_31.0.cil",
1156*e4a36f41SAndroid Build Coastguard Worker        "plat_32.0.cil",
1157*e4a36f41SAndroid Build Coastguard Worker        "plat_33.0.cil",
1158*e4a36f41SAndroid Build Coastguard Worker        "plat_34.0.cil",
1159*e4a36f41SAndroid Build Coastguard Worker        "plat_bug_map",
1160*e4a36f41SAndroid Build Coastguard Worker        "plat_file_contexts",
1161*e4a36f41SAndroid Build Coastguard Worker        "plat_file_contexts_data_test",
1162*e4a36f41SAndroid Build Coastguard Worker        "plat_file_contexts_test",
1163*e4a36f41SAndroid Build Coastguard Worker        "plat_hwservice_contexts",
1164*e4a36f41SAndroid Build Coastguard Worker        "plat_hwservice_contexts_test",
1165*e4a36f41SAndroid Build Coastguard Worker        "plat_keystore2_key_contexts",
1166*e4a36f41SAndroid Build Coastguard Worker        "plat_mac_permissions.xml",
1167*e4a36f41SAndroid Build Coastguard Worker        "plat_mapping_file",
1168*e4a36f41SAndroid Build Coastguard Worker        "plat_property_contexts",
1169*e4a36f41SAndroid Build Coastguard Worker        "plat_property_contexts_test",
1170*e4a36f41SAndroid Build Coastguard Worker        "plat_seapp_contexts",
1171*e4a36f41SAndroid Build Coastguard Worker        "plat_sepolicy.cil",
1172*e4a36f41SAndroid Build Coastguard Worker        "plat_sepolicy_genfs_202504.cil",
1173*e4a36f41SAndroid Build Coastguard Worker        "plat_service_contexts",
1174*e4a36f41SAndroid Build Coastguard Worker        "plat_service_contexts_test",
1175*e4a36f41SAndroid Build Coastguard Worker        "searchpolicy",
1176*e4a36f41SAndroid Build Coastguard Worker        "secilc",
1177*e4a36f41SAndroid Build Coastguard Worker    ] + select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
1178*e4a36f41SAndroid Build Coastguard Worker        "202404": [],
1179*e4a36f41SAndroid Build Coastguard Worker        default: [
1180*e4a36f41SAndroid Build Coastguard Worker            "202404.compat.cil",
1181*e4a36f41SAndroid Build Coastguard Worker            "plat_202404.cil",
1182*e4a36f41SAndroid Build Coastguard Worker        ],
1183*e4a36f41SAndroid Build Coastguard Worker    }) + select(soong_config_variable("ANDROID", "PRODUCT_PRECOMPILED_SEPOLICY"), {
1184*e4a36f41SAndroid Build Coastguard Worker        true: ["plat_sepolicy_and_mapping.sha256"],
1185*e4a36f41SAndroid Build Coastguard Worker        default: [],
1186*e4a36f41SAndroid Build Coastguard Worker    }) + select((
1187*e4a36f41SAndroid Build Coastguard Worker        soong_config_variable("ANDROID", "ASAN_ENABLED"),
1188*e4a36f41SAndroid Build Coastguard Worker        product_variable("selinux_ignore_neverallows"),
1189*e4a36f41SAndroid Build Coastguard Worker    ), {
1190*e4a36f41SAndroid Build Coastguard Worker        (true, true): [
1191*e4a36f41SAndroid Build Coastguard Worker        ],
1192*e4a36f41SAndroid Build Coastguard Worker        (default, default): [
1193*e4a36f41SAndroid Build Coastguard Worker            "sepolicy_compat_test",
1194*e4a36f41SAndroid Build Coastguard Worker            "sepolicy_test",
1195*e4a36f41SAndroid Build Coastguard Worker            "sepolicy_dev_type_test",
1196*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_29.0",
1197*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_30.0",
1198*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_31.0",
1199*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_32.0",
1200*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_33.0",
1201*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_34.0",
1202*e4a36f41SAndroid Build Coastguard Worker        ],
1203*e4a36f41SAndroid Build Coastguard Worker    }) + select((
1204*e4a36f41SAndroid Build Coastguard Worker        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
1205*e4a36f41SAndroid Build Coastguard Worker        soong_config_variable("ANDROID", "ASAN_ENABLED"),
1206*e4a36f41SAndroid Build Coastguard Worker        product_variable("selinux_ignore_neverallows"),
1207*e4a36f41SAndroid Build Coastguard Worker    ), {
1208*e4a36f41SAndroid Build Coastguard Worker        ("202404", true, true): [],
1209*e4a36f41SAndroid Build Coastguard Worker        (default, true, true): [],
1210*e4a36f41SAndroid Build Coastguard Worker        (default, default, default): [
1211*e4a36f41SAndroid Build Coastguard Worker            "treble_sepolicy_tests_202404",
1212*e4a36f41SAndroid Build Coastguard Worker        ],
1213*e4a36f41SAndroid Build Coastguard Worker    }) + select(soong_config_variable("ANDROID", "RELEASE_BOARD_API_LEVEL_FROZEN"), {
1214*e4a36f41SAndroid Build Coastguard Worker        true: ["se_freeze_test"],
1215*e4a36f41SAndroid Build Coastguard Worker        default: [],
1216*e4a36f41SAndroid Build Coastguard Worker    }) + select(release_flag("RELEASE_AVF_ENABLE_VM_TO_TEE_SERVICES_ALLOWLIST"), {
1217*e4a36f41SAndroid Build Coastguard Worker        true: ["plat_tee_service_contexts"],
1218*e4a36f41SAndroid Build Coastguard Worker        default: [],
1219*e4a36f41SAndroid Build Coastguard Worker    }),
1220*e4a36f41SAndroid Build Coastguard Worker}
1221*e4a36f41SAndroid Build Coastguard Worker
1222*e4a36f41SAndroid Build Coastguard Workerphony {
1223*e4a36f41SAndroid Build Coastguard Worker    name: "selinux_policy",
1224*e4a36f41SAndroid Build Coastguard Worker    required: [
1225*e4a36f41SAndroid Build Coastguard Worker        // Runs checkfc against merged service_contexts files
1226*e4a36f41SAndroid Build Coastguard Worker        "merged_hwservice_contexts_test",
1227*e4a36f41SAndroid Build Coastguard Worker        "merged_service_contexts_test",
1228*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_nonsystem",
1229*e4a36f41SAndroid Build Coastguard Worker        "selinux_policy_system",
1230*e4a36f41SAndroid Build Coastguard Worker    ],
1231*e4a36f41SAndroid Build Coastguard Worker}
1232*e4a36f41SAndroid Build Coastguard Worker
1233*e4a36f41SAndroid Build Coastguard Worker// selinux_policy is a main goal and triggers lots of tests.
1234*e4a36f41SAndroid Build Coastguard Worker// Most tests are FAKE modules, so aren'triggered on normal builds. (e.g. 'm')
1235*e4a36f41SAndroid Build Coastguard Worker// By setting as droidcore's dependency, tests will run on normal builds.
1236*e4a36f41SAndroid Build Coastguard Workerphony_rule {
1237*e4a36f41SAndroid Build Coastguard Worker    name: "droidcore",
1238*e4a36f41SAndroid Build Coastguard Worker    phony_deps: ["selinux_policy"],
1239*e4a36f41SAndroid Build Coastguard Worker}
1240*e4a36f41SAndroid Build Coastguard Worker
1241*e4a36f41SAndroid Build Coastguard Worker//-----------------------------------------------------------------------------
1242*e4a36f41SAndroid Build Coastguard Worker// TODO - remove this.   Keep around until we get the filesystem creation stuff
1243*e4a36f41SAndroid Build Coastguard Worker// taken care of.
1244*e4a36f41SAndroid Build Coastguard Worker//
1245*e4a36f41SAndroid Build Coastguard Worker// The file_contexts.bin is built in the following way:
1246*e4a36f41SAndroid Build Coastguard Worker// 1. Collect all file_contexts files in THIS repository and process them with
1247*e4a36f41SAndroid Build Coastguard Worker//    m4 into a tmp file called file_contexts.local.tmp.
1248*e4a36f41SAndroid Build Coastguard Worker// 2. Collect all device specific file_contexts files and process them with m4
1249*e4a36f41SAndroid Build Coastguard Worker//    into a tmp file called file_contexts.device.tmp.
1250*e4a36f41SAndroid Build Coastguard Worker// 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
1251*e4a36f41SAndroid Build Coastguard Worker//    file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
1252*e4a36f41SAndroid Build Coastguard Worker// 4. Concatenate file_contexts.local.tmp and  file_contexts.device.sorted.tmp
1253*e4a36f41SAndroid Build Coastguard Worker//    into file_contexts.concat.tmp.
1254*e4a36f41SAndroid Build Coastguard Worker// 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
1255*e4a36f41SAndroid Build Coastguard Worker//    file_contexts.bin.
1256*e4a36f41SAndroid Build Coastguard Worker//
1257*e4a36f41SAndroid Build Coastguard Worker//  Note: That a newline file is placed between each file_context file found to
1258*e4a36f41SAndroid Build Coastguard Worker//        ensure a proper build when an fc file is missing an ending newline.
1259*e4a36f41SAndroid Build Coastguard Worker//---
1260*e4a36f41SAndroid Build Coastguard Worker// 1. Collect all file_contexts files in THIS repository and process them with
1261*e4a36f41SAndroid Build Coastguard Worker//    m4 into a tmp file called file_contexts.local.tmp.
1262*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
1263*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts.local.tmp",
1264*e4a36f41SAndroid Build Coastguard Worker    srcs: [
1265*e4a36f41SAndroid Build Coastguard Worker        ":plat_file_contexts",
1266*e4a36f41SAndroid Build Coastguard Worker        ":system_ext_file_contexts",
1267*e4a36f41SAndroid Build Coastguard Worker        ":product_file_contexts",
1268*e4a36f41SAndroid Build Coastguard Worker    ],
1269*e4a36f41SAndroid Build Coastguard Worker    tools: [
1270*e4a36f41SAndroid Build Coastguard Worker        "m4",
1271*e4a36f41SAndroid Build Coastguard Worker    ],
1272*e4a36f41SAndroid Build Coastguard Worker    out: ["file_contexts.local.tmp"],
1273*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location m4) --fatal-warnings " +
1274*e4a36f41SAndroid Build Coastguard Worker        "-s $(in) > $(out)",
1275*e4a36f41SAndroid Build Coastguard Worker}
1276*e4a36f41SAndroid Build Coastguard Worker
1277*e4a36f41SAndroid Build Coastguard Worker// 2. Collect all device specific file_contexts files and process them with m4
1278*e4a36f41SAndroid Build Coastguard Worker//    into a tmp file called file_contexts.device.tmp.
1279*e4a36f41SAndroid Build Coastguard WorkerPRIVATE_ADDITIONAL_M4DEFS = select(soong_config_variable("ANDROID", "ADDITIONAL_M4DEFS"), {
1280*e4a36f41SAndroid Build Coastguard Worker    any @ m4defs: m4defs,
1281*e4a36f41SAndroid Build Coastguard Worker    default: "",
1282*e4a36f41SAndroid Build Coastguard Worker})
1283*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
1284*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts.device.tmp",
1285*e4a36f41SAndroid Build Coastguard Worker    srcs: [
1286*e4a36f41SAndroid Build Coastguard Worker        ":vendor_file_contexts",
1287*e4a36f41SAndroid Build Coastguard Worker        ":odm_file_contexts",
1288*e4a36f41SAndroid Build Coastguard Worker    ],
1289*e4a36f41SAndroid Build Coastguard Worker    tools: [
1290*e4a36f41SAndroid Build Coastguard Worker        "m4",
1291*e4a36f41SAndroid Build Coastguard Worker    ],
1292*e4a36f41SAndroid Build Coastguard Worker    out: ["file_contexts.device.tmp"],
1293*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location m4) --fatal-warnings " +
1294*e4a36f41SAndroid Build Coastguard Worker        "-s " + PRIVATE_ADDITIONAL_M4DEFS +
1295*e4a36f41SAndroid Build Coastguard Worker        " $(in) > $(out)",
1296*e4a36f41SAndroid Build Coastguard Worker}
1297*e4a36f41SAndroid Build Coastguard Worker
1298*e4a36f41SAndroid Build Coastguard Worker// 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
1299*e4a36f41SAndroid Build Coastguard Worker//    file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
1300*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
1301*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts.device.sorted.tmp",
1302*e4a36f41SAndroid Build Coastguard Worker    srcs: [
1303*e4a36f41SAndroid Build Coastguard Worker        ":file_contexts.device.tmp",
1304*e4a36f41SAndroid Build Coastguard Worker        ":precompiled_sepolicy",
1305*e4a36f41SAndroid Build Coastguard Worker    ],
1306*e4a36f41SAndroid Build Coastguard Worker    tools: [
1307*e4a36f41SAndroid Build Coastguard Worker        "checkfc",
1308*e4a36f41SAndroid Build Coastguard Worker        "fc_sort",
1309*e4a36f41SAndroid Build Coastguard Worker    ],
1310*e4a36f41SAndroid Build Coastguard Worker    out: ["file_contexts.device.sorted.tmp"],
1311*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location checkfc) " +
1312*e4a36f41SAndroid Build Coastguard Worker        "-e $(location :precompiled_sepolicy) " +
1313*e4a36f41SAndroid Build Coastguard Worker        "$(location :file_contexts.device.tmp) && " +
1314*e4a36f41SAndroid Build Coastguard Worker        "$(location fc_sort) " +
1315*e4a36f41SAndroid Build Coastguard Worker        "-i $(location :file_contexts.device.tmp) " +
1316*e4a36f41SAndroid Build Coastguard Worker        "-o $(out)",
1317*e4a36f41SAndroid Build Coastguard Worker}
1318*e4a36f41SAndroid Build Coastguard Worker
1319*e4a36f41SAndroid Build Coastguard Worker// 4. Concatenate file_contexts.local.tmp and  file_contexts.device.sorted.tmp
1320*e4a36f41SAndroid Build Coastguard Worker//    into file_contexts.concat.tmp.
1321*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
1322*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts.concat.tmp",
1323*e4a36f41SAndroid Build Coastguard Worker    srcs: [
1324*e4a36f41SAndroid Build Coastguard Worker        ":file_contexts.local.tmp",
1325*e4a36f41SAndroid Build Coastguard Worker        ":file_contexts.device.sorted.tmp",
1326*e4a36f41SAndroid Build Coastguard Worker    ],
1327*e4a36f41SAndroid Build Coastguard Worker    tools: [
1328*e4a36f41SAndroid Build Coastguard Worker        "m4",
1329*e4a36f41SAndroid Build Coastguard Worker    ],
1330*e4a36f41SAndroid Build Coastguard Worker    out: ["file_contexts.concat.tmp"],
1331*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location m4) --fatal-warnings " +
1332*e4a36f41SAndroid Build Coastguard Worker        "-s $(location :file_contexts.local.tmp) " +
1333*e4a36f41SAndroid Build Coastguard Worker        "$(location :file_contexts.device.sorted.tmp) > $(out)",
1334*e4a36f41SAndroid Build Coastguard Worker}
1335*e4a36f41SAndroid Build Coastguard Worker
1336*e4a36f41SAndroid Build Coastguard Worker// 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
1337*e4a36f41SAndroid Build Coastguard Worker//    file_contexts.bin.
1338*e4a36f41SAndroid Build Coastguard Workerjava_genrule {
1339*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts_bin_gen",
1340*e4a36f41SAndroid Build Coastguard Worker    srcs: [
1341*e4a36f41SAndroid Build Coastguard Worker        ":file_contexts.concat.tmp",
1342*e4a36f41SAndroid Build Coastguard Worker        ":precompiled_sepolicy",
1343*e4a36f41SAndroid Build Coastguard Worker    ],
1344*e4a36f41SAndroid Build Coastguard Worker    tools: [
1345*e4a36f41SAndroid Build Coastguard Worker        "checkfc",
1346*e4a36f41SAndroid Build Coastguard Worker        "sefcontext_compile",
1347*e4a36f41SAndroid Build Coastguard Worker    ],
1348*e4a36f41SAndroid Build Coastguard Worker    out: ["file_contexts.bin"],
1349*e4a36f41SAndroid Build Coastguard Worker    cmd: "$(location checkfc) " +
1350*e4a36f41SAndroid Build Coastguard Worker        "$(location :precompiled_sepolicy) " +
1351*e4a36f41SAndroid Build Coastguard Worker        "$(location :file_contexts.concat.tmp) && " +
1352*e4a36f41SAndroid Build Coastguard Worker        "$(location sefcontext_compile) " +
1353*e4a36f41SAndroid Build Coastguard Worker        "-o $(out) $(location :file_contexts.concat.tmp)",
1354*e4a36f41SAndroid Build Coastguard Worker}
1355*e4a36f41SAndroid Build Coastguard Worker
1356*e4a36f41SAndroid Build Coastguard Workerprebuilt_etc {
1357*e4a36f41SAndroid Build Coastguard Worker    name: "file_contexts.bin",
1358*e4a36f41SAndroid Build Coastguard Worker    src: ":file_contexts_bin_gen",
1359*e4a36f41SAndroid Build Coastguard Worker}
1360