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