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