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