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 | |
Inseob Kim | 151562f | 2024-04-12 10:53:34 +0900 | [diff] [blame^] | 91 | soong_config_module_type { |
| 92 | name: "se_phony", |
| 93 | module_type: "phony", |
| 94 | config_namespace: "ANDROID", |
| 95 | bool_variables: ["PRODUCT_PRECOMPILED_SEPOLICY"], |
| 96 | list_variables: ["PLATFORM_SEPOLICY_COMPAT_VERSIONS"], |
| 97 | properties: ["required"], |
| 98 | } |
| 99 | |
| 100 | se_phony { |
| 101 | // Currently used only for aosp_cf_system_x86_64 |
| 102 | // TODO(b/329208946): migrate selinux_policy_system to Soong |
| 103 | name: "selinux_policy_system_soong", |
| 104 | required: [ |
| 105 | "plat_bug_map", |
| 106 | "plat_file_contexts", |
| 107 | "plat_hwservice_contexts", |
| 108 | "plat_keystore2_key_contexts", |
| 109 | "plat_mac_permissions.xml", |
| 110 | "plat_mapping_file", |
| 111 | "plat_property_contexts", |
| 112 | "plat_seapp_contexts", |
| 113 | "plat_sepolicy.cil", |
| 114 | "plat_service_contexts", |
| 115 | "secilc", |
| 116 | ], |
| 117 | soong_config_variables: { |
| 118 | PLATFORM_SEPOLICY_COMPAT_VERSIONS: { |
| 119 | required: [ |
| 120 | "plat_%s.cil", |
| 121 | "%s.compat.cil", |
| 122 | ], |
| 123 | }, |
| 124 | PRODUCT_PRECOMPILED_SEPOLICY: { |
| 125 | required: ["plat_sepolicy_and_mapping.sha256"], |
| 126 | }, |
| 127 | }, |
| 128 | } |
| 129 | |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 130 | reqd_mask_policy = [":se_build_files{.reqd_mask}"] |
| 131 | plat_public_policy = [":se_build_files{.plat_public}"] |
| 132 | plat_private_policy = [":se_build_files{.plat_private}"] |
| 133 | system_ext_public_policy = [":se_build_files{.system_ext_public}"] |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 134 | system_ext_private_policy = [":se_build_files{.system_ext_private}"] |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 135 | product_public_policy = [":se_build_files{.product_public}"] |
| 136 | product_private_policy = [":se_build_files{.product_private}"] |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 137 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 138 | // reqd_policy_mask - a policy.conf file which contains only the bare minimum |
| 139 | // policy necessary to use checkpolicy. |
| 140 | // |
| 141 | // This bare-minimum policy needs to be present in all policy.conf files, but |
| 142 | // should not necessarily be exported as part of the public policy. |
| 143 | // |
| 144 | // The rules generated by reqd_policy_mask will allow the compilation of public |
| 145 | // policy and subsequent removal of CIL policy that should not be exported. |
| 146 | se_policy_conf { |
| 147 | name: "reqd_policy_mask.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 148 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 149 | srcs: reqd_mask_policy, |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 150 | installable: false, |
| 151 | } |
| 152 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 153 | se_policy_cil { |
| 154 | name: "reqd_policy_mask.cil", |
| 155 | src: ":reqd_policy_mask.conf", |
| 156 | secilc_check: false, |
| 157 | installable: false, |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 158 | } |
| 159 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 160 | // pub_policy - policy that will be exported to be a part of non-platform |
| 161 | // policy corresponding to this platform version. |
| 162 | // |
| 163 | // This is a limited subset of policy that would not compile in checkpolicy on |
| 164 | // its own. |
| 165 | // |
| 166 | // To get around this limitation, add only the required files from private |
| 167 | // policy, which will generate CIL policy that will then be filtered out by the |
| 168 | // reqd_policy_mask. |
| 169 | // |
| 170 | // There are three pub_policy.cil files below: |
| 171 | // - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy. |
| 172 | // - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy. |
| 173 | // - plat_pub_policy.cil: exported 'system' policy. |
| 174 | // |
| 175 | // Those above files will in turn be used to generate the following versioned cil files: |
| 176 | // - product_mapping_file: the versioned, exported 'product' policy in product partition. |
| 177 | // - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition. |
| 178 | // - plat_mapping_file: the versioned, exported 'system' policy in system partition. |
| 179 | // - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy |
| 180 | // in vendor partition. |
| 181 | // |
| 182 | se_policy_conf { |
| 183 | name: "pub_policy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 184 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 185 | srcs: plat_public_policy + |
| 186 | system_ext_public_policy + |
| 187 | product_public_policy + |
| 188 | reqd_mask_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 189 | vendor: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 190 | installable: false, |
| 191 | } |
| 192 | |
| 193 | se_policy_cil { |
| 194 | name: "pub_policy.cil", |
| 195 | src: ":pub_policy.conf", |
| 196 | filter_out: [":reqd_policy_mask.cil"], |
| 197 | secilc_check: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 198 | vendor: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 199 | installable: false, |
| 200 | } |
| 201 | |
| 202 | se_policy_conf { |
| 203 | name: "system_ext_pub_policy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 204 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 205 | srcs: plat_public_policy + |
| 206 | system_ext_public_policy + |
| 207 | reqd_mask_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 208 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 209 | installable: false, |
| 210 | } |
| 211 | |
| 212 | se_policy_cil { |
| 213 | name: "system_ext_pub_policy.cil", |
| 214 | src: ":system_ext_pub_policy.conf", |
| 215 | filter_out: [":reqd_policy_mask.cil"], |
| 216 | secilc_check: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 217 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 218 | installable: false, |
| 219 | } |
| 220 | |
| 221 | se_policy_conf { |
| 222 | name: "plat_pub_policy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 223 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 224 | srcs: plat_public_policy + |
| 225 | reqd_mask_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 226 | installable: false, |
| 227 | } |
| 228 | |
| 229 | se_policy_cil { |
| 230 | name: "plat_pub_policy.cil", |
| 231 | src: ":plat_pub_policy.conf", |
| 232 | filter_out: [":reqd_policy_mask.cil"], |
| 233 | secilc_check: false, |
| 234 | installable: false, |
| 235 | } |
| 236 | |
| 237 | // plat_policy.conf - A combination of the private and public platform policy |
| 238 | // which will ship with the device. |
| 239 | // |
| 240 | // The platform will always reflect the most recent platform version and is not |
| 241 | // currently being attributized. |
| 242 | se_policy_conf { |
| 243 | name: "plat_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 244 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 245 | srcs: plat_public_policy + |
| 246 | plat_private_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 247 | installable: false, |
| 248 | } |
| 249 | |
| 250 | se_policy_cil { |
| 251 | name: "plat_sepolicy.cil", |
| 252 | src: ":plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 253 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Inseob Kim | 4b9929e | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 254 | dist: { |
| 255 | targets: ["sepolicy_finalize"], |
| 256 | }, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 257 | } |
| 258 | |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 259 | // userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil |
| 260 | se_policy_conf { |
| 261 | name: "userdebug_plat_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 262 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 263 | srcs: plat_public_policy + |
| 264 | plat_private_policy, |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 265 | build_variant: "userdebug", |
| 266 | installable: false, |
| 267 | } |
| 268 | |
| 269 | se_policy_cil { |
| 270 | name: "userdebug_plat_sepolicy.cil", |
| 271 | src: ":userdebug_plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 272 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 273 | debug_ramdisk: true, |
Yi-Yo Chiang | 68478b1 | 2021-10-16 03:23:05 +0800 | [diff] [blame] | 274 | dist: { |
| 275 | targets: ["droidcore"], |
| 276 | }, |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Yi-Yo Chiang | 857ffc4 | 2021-09-23 14:14:16 +0000 | [diff] [blame] | 279 | // A copy of the userdebug_plat_policy in GSI. |
| 280 | soong_config_module_type { |
| 281 | name: "gsi_se_policy_cil", |
| 282 | module_type: "se_policy_cil", |
| 283 | config_namespace: "ANDROID", |
| 284 | bool_variables: [ |
| 285 | "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT", |
| 286 | ], |
| 287 | properties: [ |
| 288 | "enabled", |
| 289 | "installable", |
| 290 | ], |
| 291 | } |
| 292 | |
| 293 | gsi_se_policy_cil { |
| 294 | name: "system_ext_userdebug_plat_sepolicy.cil", |
| 295 | stem: "userdebug_plat_sepolicy.cil", |
| 296 | src: ":userdebug_plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 297 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Yi-Yo Chiang | 857ffc4 | 2021-09-23 14:14:16 +0000 | [diff] [blame] | 298 | system_ext_specific: true, |
| 299 | enabled: false, |
| 300 | installable: false, |
| 301 | soong_config_variables: { |
| 302 | PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: { |
| 303 | enabled: true, |
| 304 | installable: true, |
| 305 | }, |
| 306 | }, |
| 307 | } |
| 308 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 309 | // system_ext_policy.conf - A combination of the private and public system_ext |
| 310 | // policy which will ship with the device. System_ext policy is not attributized |
| 311 | se_policy_conf { |
| 312 | name: "system_ext_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 313 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 314 | srcs: plat_public_policy + |
| 315 | plat_private_policy + |
| 316 | system_ext_public_policy + |
| 317 | system_ext_private_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 318 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 319 | installable: false, |
| 320 | } |
| 321 | |
| 322 | se_policy_cil { |
| 323 | name: "system_ext_sepolicy.cil", |
| 324 | src: ":system_ext_sepolicy.conf", |
| 325 | system_ext_specific: true, |
| 326 | filter_out: [":plat_sepolicy.cil"], |
| 327 | remove_line_marker: true, |
| 328 | } |
| 329 | |
| 330 | // product_policy.conf - A combination of the private and public product policy |
| 331 | // which will ship with the device. Product policy is not attributized |
| 332 | se_policy_conf { |
| 333 | name: "product_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 334 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 335 | srcs: plat_public_policy + |
| 336 | plat_private_policy + |
| 337 | system_ext_public_policy + |
| 338 | system_ext_private_policy + |
| 339 | product_public_policy + |
| 340 | product_private_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 341 | product_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 342 | installable: false, |
| 343 | } |
| 344 | |
| 345 | se_policy_cil { |
| 346 | name: "product_sepolicy.cil", |
| 347 | src: ":product_sepolicy.conf", |
| 348 | product_specific: true, |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 349 | filter_out: [ |
| 350 | ":plat_sepolicy.cil", |
| 351 | ":system_ext_sepolicy.cil", |
| 352 | ], |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 353 | remove_line_marker: true, |
| 354 | } |
| 355 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 356 | // policy mapping files |
| 357 | // auto-generate the mapping file for current platform policy, since it needs to |
| 358 | // track platform policy development |
| 359 | se_versioned_policy { |
| 360 | name: "plat_mapping_file", |
| 361 | base: ":plat_pub_policy.cil", |
| 362 | mapping: true, |
| 363 | version: "current", |
| 364 | relative_install_path: "mapping", // install to /system/etc/selinux/mapping |
Inseob Kim | 4b9929e | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 365 | dist: { |
| 366 | targets: ["sepolicy_finalize"], |
| 367 | }, |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | se_versioned_policy { |
| 371 | name: "system_ext_mapping_file", |
| 372 | base: ":system_ext_pub_policy.cil", |
| 373 | mapping: true, |
| 374 | version: "current", |
| 375 | filter_out: [":plat_mapping_file"], |
| 376 | relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping |
| 377 | system_ext_specific: true, |
| 378 | } |
| 379 | |
| 380 | se_versioned_policy { |
| 381 | name: "product_mapping_file", |
| 382 | base: ":pub_policy.cil", |
| 383 | mapping: true, |
| 384 | version: "current", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 385 | filter_out: [ |
| 386 | ":plat_mapping_file", |
| 387 | ":system_ext_mapping_file", |
| 388 | ], |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 389 | relative_install_path: "mapping", // install to /product/etc/selinux/mapping |
| 390 | product_specific: true, |
| 391 | } |
| 392 | |
Inseob Kim | e41e95e | 2024-02-13 02:19:24 +0000 | [diff] [blame] | 393 | // HACK to support vendor blobs using 1000000.0 |
| 394 | // TODO(b/314010177): remove after new ToT (202404) fully propagates |
| 395 | se_versioned_policy { |
| 396 | name: "plat_mapping_file_1000000.0", |
| 397 | base: ":plat_pub_policy.cil", |
| 398 | mapping: true, |
| 399 | version: "1000000.0", |
| 400 | relative_install_path: "mapping", // install to /system/etc/selinux/mapping |
| 401 | } |
| 402 | |
| 403 | se_versioned_policy { |
| 404 | name: "system_ext_mapping_file_1000000.0", |
| 405 | base: ":system_ext_pub_policy.cil", |
| 406 | mapping: true, |
| 407 | version: "1000000.0", |
| 408 | filter_out: [":plat_mapping_file"], |
| 409 | relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping |
| 410 | system_ext_specific: true, |
| 411 | } |
| 412 | |
| 413 | se_versioned_policy { |
| 414 | name: "product_mapping_file_1000000.0", |
| 415 | base: ":pub_policy.cil", |
| 416 | mapping: true, |
| 417 | version: "1000000.0", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 418 | filter_out: [ |
| 419 | ":plat_mapping_file", |
| 420 | ":system_ext_mapping_file", |
| 421 | ], |
Inseob Kim | e41e95e | 2024-02-13 02:19:24 +0000 | [diff] [blame] | 422 | relative_install_path: "mapping", // install to /product/etc/selinux/mapping |
| 423 | product_specific: true, |
| 424 | } |
| 425 | |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 426 | ////////////////////////////////// |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 427 | // vendor/odm sepolicy |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 428 | ////////////////////////////////// |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 429 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 430 | // plat_pub_versioned.cil - the exported platform policy associated with the version |
| 431 | // that non-platform policy targets. |
| 432 | se_versioned_policy { |
| 433 | name: "plat_pub_versioned.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 434 | base: ":pub_policy.cil", |
| 435 | target_policy: ":pub_policy.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 436 | version: "vendor", |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 437 | vendor: true, |
| 438 | } |
| 439 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 440 | // vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined |
| 441 | // with the platform-provided policy. It makes use of the reqd_policy_mask files from private |
| 442 | // policy and the platform public policy files in order to use checkpolicy. |
| 443 | se_policy_conf { |
| 444 | name: "vendor_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 445 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 446 | srcs: plat_public_policy + |
| 447 | system_ext_public_policy + |
| 448 | product_public_policy + |
| 449 | reqd_mask_policy + [ |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 450 | ":se_build_files{.plat_vendor}", |
| 451 | ":se_build_files{.vendor}", |
| 452 | ], |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 453 | vendor: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 454 | installable: false, |
| 455 | } |
| 456 | |
| 457 | se_policy_cil { |
| 458 | name: "vendor_sepolicy.cil.raw", |
| 459 | src: ":vendor_sepolicy.conf", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 460 | filter_out: [":reqd_policy_mask.cil"], |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 461 | secilc_check: false, // will be done in se_versioned_policy module |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 462 | vendor: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 463 | installable: false, |
| 464 | } |
| 465 | |
| 466 | se_versioned_policy { |
| 467 | name: "vendor_sepolicy.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 468 | base: ":pub_policy.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 469 | target_policy: ":vendor_sepolicy.cil.raw", |
| 470 | version: "vendor", |
| 471 | dependent_cils: [ |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 472 | ":plat_sepolicy.cil", |
| 473 | ":system_ext_sepolicy.cil", |
| 474 | ":product_sepolicy.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 475 | ":plat_pub_versioned.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 476 | ":plat_mapping_file", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 477 | ], |
| 478 | filter_out: [":plat_pub_versioned.cil"], |
| 479 | vendor: true, |
| 480 | } |
| 481 | |
| 482 | // odm_policy.cil - the odl sepolicy. This needs attributization and to be combined |
| 483 | // with the platform-provided policy. It makes use of the reqd_policy_mask files from private |
| 484 | // policy and the platform public policy files in order to use checkpolicy. |
| 485 | se_policy_conf { |
| 486 | name: "odm_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 487 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 488 | srcs: plat_public_policy + |
| 489 | system_ext_public_policy + |
| 490 | product_public_policy + |
| 491 | reqd_mask_policy + [ |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 492 | ":se_build_files{.plat_vendor}", |
| 493 | ":se_build_files{.vendor}", |
| 494 | ":se_build_files{.odm}", |
| 495 | ], |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 496 | device_specific: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 497 | installable: false, |
| 498 | } |
| 499 | |
| 500 | se_policy_cil { |
| 501 | name: "odm_sepolicy.cil.raw", |
| 502 | src: ":odm_sepolicy.conf", |
| 503 | filter_out: [ |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 504 | ":reqd_policy_mask.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 505 | ":vendor_sepolicy.cil", |
| 506 | ], |
| 507 | secilc_check: false, // will be done in se_versioned_policy module |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 508 | device_specific: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 509 | installable: false, |
| 510 | } |
| 511 | |
| 512 | se_versioned_policy { |
| 513 | name: "odm_sepolicy.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 514 | base: ":pub_policy.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 515 | target_policy: ":odm_sepolicy.cil.raw", |
| 516 | version: "vendor", |
| 517 | dependent_cils: [ |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 518 | ":plat_sepolicy.cil", |
| 519 | ":system_ext_sepolicy.cil", |
| 520 | ":product_sepolicy.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 521 | ":plat_pub_versioned.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 522 | ":plat_mapping_file", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 523 | ":vendor_sepolicy.cil", |
| 524 | ], |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 525 | filter_out: [ |
| 526 | ":plat_pub_versioned.cil", |
| 527 | ":vendor_sepolicy.cil", |
| 528 | ], |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 529 | device_specific: true, |
| 530 | } |
| 531 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 532 | ////////////////////////////////// |
| 533 | // Precompiled sepolicy is loaded if and only if: |
| 534 | // - plat_sepolicy_and_mapping.sha256 equals |
| 535 | // precompiled_sepolicy.plat_sepolicy_and_mapping.sha256 |
| 536 | // AND |
| 537 | // - system_ext_sepolicy_and_mapping.sha256 equals |
| 538 | // precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256 |
| 539 | // AND |
| 540 | // - product_sepolicy_and_mapping.sha256 equals |
| 541 | // precompiled_sepolicy.product_sepolicy_and_mapping.sha256 |
| 542 | // See system/core/init/selinux.cpp for details. |
| 543 | ////////////////////////////////// |
| 544 | genrule { |
| 545 | name: "plat_sepolicy_and_mapping.sha256_gen", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 546 | srcs: [ |
| 547 | ":plat_sepolicy.cil", |
| 548 | ":plat_mapping_file", |
| 549 | ], |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 550 | out: ["plat_sepolicy_and_mapping.sha256"], |
| 551 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 552 | } |
| 553 | |
| 554 | prebuilt_etc { |
| 555 | name: "plat_sepolicy_and_mapping.sha256", |
| 556 | filename: "plat_sepolicy_and_mapping.sha256", |
| 557 | src: ":plat_sepolicy_and_mapping.sha256_gen", |
| 558 | relative_install_path: "selinux", |
| 559 | } |
| 560 | |
| 561 | genrule { |
| 562 | name: "system_ext_sepolicy_and_mapping.sha256_gen", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 563 | srcs: [ |
| 564 | ":system_ext_sepolicy.cil", |
| 565 | ":system_ext_mapping_file", |
| 566 | ], |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 567 | out: ["system_ext_sepolicy_and_mapping.sha256"], |
| 568 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 569 | } |
| 570 | |
| 571 | prebuilt_etc { |
| 572 | name: "system_ext_sepolicy_and_mapping.sha256", |
| 573 | filename: "system_ext_sepolicy_and_mapping.sha256", |
| 574 | src: ":system_ext_sepolicy_and_mapping.sha256_gen", |
| 575 | relative_install_path: "selinux", |
| 576 | system_ext_specific: true, |
| 577 | } |
| 578 | |
| 579 | genrule { |
| 580 | name: "product_sepolicy_and_mapping.sha256_gen", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 581 | srcs: [ |
| 582 | ":product_sepolicy.cil", |
| 583 | ":product_mapping_file", |
| 584 | ], |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 585 | out: ["product_sepolicy_and_mapping.sha256"], |
| 586 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 587 | } |
| 588 | |
| 589 | prebuilt_etc { |
| 590 | name: "product_sepolicy_and_mapping.sha256", |
| 591 | filename: "product_sepolicy_and_mapping.sha256", |
| 592 | src: ":product_sepolicy_and_mapping.sha256_gen", |
| 593 | relative_install_path: "selinux", |
| 594 | product_specific: true, |
| 595 | } |
| 596 | |
Inseob Kim | 1c056b1 | 2021-04-30 00:11:43 +0900 | [diff] [blame] | 597 | sepolicy_vers { |
| 598 | name: "plat_sepolicy_vers.txt", |
| 599 | version: "vendor", |
| 600 | vendor: true, |
| 601 | } |
| 602 | |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 603 | soong_config_module_type { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 604 | name: "precompiled_sepolicy_prebuilts_defaults", |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 605 | module_type: "prebuilt_defaults", |
| 606 | config_namespace: "ANDROID", |
| 607 | bool_variables: ["BOARD_USES_ODMIMAGE"], |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 608 | properties: [ |
| 609 | "vendor", |
| 610 | "device_specific", |
| 611 | ], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 612 | } |
| 613 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 614 | precompiled_sepolicy_prebuilts_defaults { |
| 615 | name: "precompiled_sepolicy_prebuilts", |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 616 | soong_config_variables: { |
| 617 | BOARD_USES_ODMIMAGE: { |
| 618 | device_specific: true, |
| 619 | conditions_default: { |
| 620 | vendor: true, |
| 621 | }, |
| 622 | }, |
| 623 | }, |
| 624 | } |
| 625 | |
| 626 | ////////////////////////////////// |
| 627 | // SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against |
| 628 | // which precompiled_policy was built. |
| 629 | ////////////////////////////////// |
| 630 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 631 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 632 | name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", |
| 633 | filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", |
| 634 | src: ":plat_sepolicy_and_mapping.sha256_gen", |
| 635 | relative_install_path: "selinux", |
| 636 | } |
| 637 | |
| 638 | ////////////////////////////////// |
| 639 | // SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against |
| 640 | // which precompiled_policy was built. |
| 641 | ////////////////////////////////// |
| 642 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 643 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 644 | name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", |
| 645 | filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", |
| 646 | src: ":system_ext_sepolicy_and_mapping.sha256_gen", |
| 647 | relative_install_path: "selinux", |
| 648 | } |
| 649 | |
| 650 | ////////////////////////////////// |
| 651 | // SHA-256 digest of the product_sepolicy.cil and product_mapping_file against |
| 652 | // which precompiled_policy was built. |
| 653 | ////////////////////////////////// |
| 654 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 655 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 656 | name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", |
| 657 | filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", |
| 658 | src: ":product_sepolicy_and_mapping.sha256_gen", |
| 659 | relative_install_path: "selinux", |
| 660 | } |
| 661 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 662 | soong_config_module_type { |
| 663 | name: "precompiled_se_policy_binary", |
| 664 | module_type: "se_policy_binary", |
| 665 | config_namespace: "ANDROID", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 666 | bool_variables: ["BOARD_USES_ODMIMAGE"], |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 667 | properties: [ |
| 668 | "vendor", |
| 669 | "device_specific", |
| 670 | ], |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 671 | } |
| 672 | |
Garfield Tan | d8c51f2 | 2023-10-02 14:17:04 -0700 | [diff] [blame] | 673 | filegroup { |
| 674 | name: "precompiled_sepolicy_srcs", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 675 | srcs: [ |
| 676 | ":plat_sepolicy.cil", |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 677 | ":plat_pub_versioned.cil", |
| 678 | ":system_ext_sepolicy.cil", |
| 679 | ":product_sepolicy.cil", |
| 680 | ":vendor_sepolicy.cil", |
| 681 | ":odm_sepolicy.cil", |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 682 | ":plat_mapping_file", |
| 683 | ":system_ext_mapping_file", |
| 684 | ":product_mapping_file", |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 685 | ], |
Garfield Tan | d8c51f2 | 2023-10-02 14:17:04 -0700 | [diff] [blame] | 686 | // Make precompiled_sepolicy_srcs as public so that OEMs have access to them. |
| 687 | // Useful when some partitions need to be bind mounted across VM boundaries. |
| 688 | visibility: ["//visibility:public"], |
| 689 | } |
| 690 | |
| 691 | precompiled_se_policy_binary { |
| 692 | name: "precompiled_sepolicy", |
| 693 | srcs: [ |
| 694 | ":precompiled_sepolicy_srcs", |
| 695 | ], |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 696 | soong_config_variables: { |
| 697 | BOARD_USES_ODMIMAGE: { |
| 698 | device_specific: true, |
| 699 | conditions_default: { |
| 700 | vendor: true, |
| 701 | }, |
| 702 | }, |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 703 | }, |
| 704 | required: [ |
| 705 | "sepolicy_neverallows", |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 706 | ], |
| 707 | dist: { |
| 708 | targets: ["base-sepolicy-files-for-mapping"], |
| 709 | }, |
| 710 | } |
| 711 | |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 712 | // policy for recovery |
| 713 | se_policy_conf { |
| 714 | name: "recovery_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 715 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 716 | srcs: plat_public_policy + |
| 717 | plat_private_policy + |
| 718 | system_ext_public_policy + |
| 719 | system_ext_private_policy + |
| 720 | product_public_policy + |
| 721 | product_private_policy + [ |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 722 | ":se_build_files{.plat_vendor}", |
| 723 | ":se_build_files{.vendor}", |
| 724 | ":se_build_files{.odm}", |
| 725 | ], |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 726 | target_recovery: true, |
| 727 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 728 | recovery: true, |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | se_policy_cil { |
| 732 | name: "recovery_sepolicy.cil", |
| 733 | src: ":recovery_sepolicy.conf", |
| 734 | secilc_check: false, // will be done in se_policy_binary module |
| 735 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 736 | recovery: true, |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | se_policy_binary { |
| 740 | name: "sepolicy.recovery", |
| 741 | srcs: [":recovery_sepolicy.cil"], |
| 742 | stem: "sepolicy", |
| 743 | recovery: true, |
| 744 | } |
| 745 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 746 | ////////////////////////////////// |
| 747 | // SELinux policy embedded into CTS. |
| 748 | // CTS checks neverallow rules of this policy against the policy of the device under test. |
| 749 | ////////////////////////////////// |
| 750 | se_policy_conf { |
| 751 | name: "general_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 752 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 753 | srcs: plat_public_policy + |
| 754 | plat_private_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 755 | build_variant: "user", |
| 756 | cts: true, |
| 757 | exclude_build_test: true, |
Inseob Kim | 4b9929e | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 758 | dist: { |
| 759 | targets: ["sepolicy_finalize"], |
| 760 | }, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 761 | } |
Inseob Kim | d581661 | 2021-09-15 03:01:05 +0000 | [diff] [blame] | 762 | |
| 763 | ////////////////////////////////// |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 764 | // Base system policy for treble sepolicy tests. |
| 765 | // If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ |
| 766 | // with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case, |
| 767 | // BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil. |
| 768 | // See treble_sepolicy_tests_for_release.mk for more details. |
| 769 | ////////////////////////////////// |
| 770 | se_policy_conf { |
| 771 | name: "base_plat_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 772 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 773 | srcs: plat_public_policy + |
| 774 | plat_private_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 775 | build_variant: "user", |
| 776 | installable: false, |
| 777 | } |
| 778 | |
| 779 | se_policy_cil { |
| 780 | name: "base_plat_sepolicy.cil", |
| 781 | src: ":base_plat_sepolicy.conf", |
| 782 | additional_cil_files: ["private/technical_debt.cil"], |
| 783 | installable: false, |
| 784 | secilc_check: false, // done by se_policy_binary |
| 785 | } |
| 786 | |
| 787 | se_policy_binary { |
| 788 | name: "base_plat_sepolicy", |
| 789 | srcs: [":base_plat_sepolicy.cil"], |
| 790 | installable: false, |
Inseob Kim | eec3919 | 2022-01-21 11:47:54 +0900 | [diff] [blame] | 791 | dist: { |
| 792 | targets: ["base-sepolicy-files-for-mapping"], |
| 793 | }, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | se_policy_conf { |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 797 | name: "base_product_sepolicy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 798 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 799 | srcs: plat_public_policy + |
| 800 | plat_private_policy + |
| 801 | system_ext_public_policy + |
| 802 | system_ext_private_policy + |
| 803 | product_public_policy + |
| 804 | product_private_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 805 | build_variant: "user", |
| 806 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 807 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | se_policy_cil { |
| 811 | name: "base_product_sepolicy.cil", |
| 812 | src: ":base_product_sepolicy.conf", |
| 813 | additional_cil_files: ["private/technical_debt.cil"], |
| 814 | product_specific: true, |
| 815 | installable: false, |
| 816 | secilc_check: false, // done by se_policy_binary |
| 817 | } |
| 818 | |
| 819 | se_policy_binary { |
| 820 | name: "base_product_sepolicy", |
| 821 | srcs: [":base_product_sepolicy.cil"], |
| 822 | product_specific: true, |
| 823 | installable: false, |
| 824 | } |
| 825 | |
| 826 | se_policy_conf { |
| 827 | name: "base_plat_pub_policy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 828 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 829 | srcs: plat_public_policy + |
| 830 | reqd_mask_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 831 | build_variant: "user", |
| 832 | installable: false, |
| 833 | } |
| 834 | |
| 835 | se_policy_cil { |
| 836 | name: "base_plat_pub_policy.cil", |
| 837 | src: ":base_plat_pub_policy.conf", |
| 838 | filter_out: [":reqd_policy_mask.cil"], |
| 839 | secilc_check: false, |
| 840 | installable: false, |
Inseob Kim | eec3919 | 2022-01-21 11:47:54 +0900 | [diff] [blame] | 841 | dist: { |
| 842 | targets: ["base-sepolicy-files-for-mapping"], |
| 843 | }, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | se_policy_conf { |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 847 | name: "base_product_pub_policy.conf", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 848 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 849 | srcs: plat_public_policy + |
| 850 | system_ext_public_policy + |
| 851 | product_public_policy + |
| 852 | reqd_mask_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 853 | build_variant: "user", |
| 854 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 855 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | se_policy_cil { |
| 859 | name: "base_product_pub_policy.cil", |
| 860 | src: ":base_product_pub_policy.conf", |
| 861 | filter_out: [":reqd_policy_mask.cil"], |
| 862 | secilc_check: false, |
| 863 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 864 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 865 | } |
| 866 | |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 867 | // bug_map - Bug tracking information for selinux denials loaded by auditd. |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 868 | se_build_files { |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 869 | name: "bug_map_files", |
| 870 | srcs: ["bug_map"], |
| 871 | } |
| 872 | |
| 873 | se_bug_map { |
| 874 | name: "plat_bug_map", |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 875 | srcs: [":bug_map_files{.plat_private}"], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 876 | stem: "bug_map", |
| 877 | } |
| 878 | |
| 879 | se_bug_map { |
| 880 | name: "system_ext_bug_map", |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 881 | srcs: [":bug_map_files{.system_ext_private}"], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 882 | stem: "bug_map", |
| 883 | system_ext_specific: true, |
| 884 | } |
| 885 | |
| 886 | se_bug_map { |
| 887 | name: "vendor_bug_map", |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 888 | srcs: [ |
| 889 | ":bug_map_files{.vendor}", |
| 890 | ":bug_map_files{.plat_vendor}", |
| 891 | ], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 892 | // Legacy file name of the vendor partition bug_map. |
| 893 | stem: "selinux_denial_metadata", |
| 894 | vendor: true, |
| 895 | } |
| 896 | |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 897 | se_neverallow_test { |
| 898 | name: "sepolicy_neverallows", |
Inseob Kim | 085f22f | 2023-11-09 11:13:01 +0900 | [diff] [blame] | 899 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 900 | srcs: plat_public_policy + |
| 901 | plat_private_policy + |
| 902 | system_ext_public_policy + |
| 903 | system_ext_private_policy + |
| 904 | product_public_policy + |
Inseob Kim | 6c6aa01 | 2023-08-31 16:47:38 +0900 | [diff] [blame] | 905 | product_private_policy + [ |
Inseob Kim | ff2018f | 2024-04-17 09:48:43 +0900 | [diff] [blame] | 906 | ":se_build_files{.plat_vendor}", |
| 907 | ":se_build_files{.vendor}", |
| 908 | ":se_build_files{.odm}", |
| 909 | ], |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 910 | } |
| 911 | |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 912 | ////////////////////////////////// |
Inseob Kim | d581661 | 2021-09-15 03:01:05 +0000 | [diff] [blame] | 913 | // se_freeze_test compares the plat sepolicy with the prebuilt sepolicy |
| 914 | // Additional directories can be specified via Makefile variables: |
| 915 | // SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS. |
| 916 | ////////////////////////////////// |
| 917 | se_freeze_test { |
Inseob Kim | 36d9d39 | 2023-09-04 17:40:03 +0900 | [diff] [blame] | 918 | name: "se_freeze_test", |
Inseob Kim | d581661 | 2021-09-15 03:01:05 +0000 | [diff] [blame] | 919 | } |
Inseob Kim | 61257ca | 2022-02-25 11:26:16 +0900 | [diff] [blame] | 920 | |
| 921 | ////////////////////////////////// |
| 922 | // sepolicy_test checks various types of violations, which can't be easily done |
| 923 | // by CIL itself. Refer tests/sepolicy_tests.py for more detail. |
| 924 | ////////////////////////////////// |
| 925 | genrule { |
| 926 | name: "sepolicy_test", |
| 927 | srcs: [ |
| 928 | ":plat_file_contexts", |
| 929 | ":vendor_file_contexts", |
| 930 | ":system_ext_file_contexts", |
| 931 | ":product_file_contexts", |
| 932 | ":odm_file_contexts", |
| 933 | ":precompiled_sepolicy", |
| 934 | ], |
| 935 | tools: ["sepolicy_tests"], |
| 936 | out: ["sepolicy_test"], |
| 937 | cmd: "$(location sepolicy_tests) " + |
| 938 | "-f $(location :plat_file_contexts) " + |
| 939 | "-f $(location :vendor_file_contexts) " + |
| 940 | "-f $(location :system_ext_file_contexts) " + |
| 941 | "-f $(location :product_file_contexts) " + |
| 942 | "-f $(location :odm_file_contexts) " + |
| 943 | "-p $(location :precompiled_sepolicy) && " + |
| 944 | "touch $(out)", |
| 945 | } |
Inseob Kim | 3a9d91c | 2023-09-27 17:39:07 +0900 | [diff] [blame] | 946 | |
| 947 | ////////////////////////////////// |
| 948 | // TestDevTypeViolations can't run on old devices (V or before) |
| 949 | ////////////////////////////////// |
| 950 | |
| 951 | soong_config_module_type { |
| 952 | name: "dev_type_test_genrule", |
| 953 | module_type: "genrule", |
| 954 | config_namespace: "ANDROID", |
| 955 | bool_variables: ["CHECK_DEV_TYPE_VIOLATIONS"], |
| 956 | properties: ["cmd"], |
| 957 | } |
| 958 | |
| 959 | dev_type_test_genrule { |
| 960 | name: "sepolicy_dev_type_test", |
| 961 | srcs: [ |
| 962 | ":plat_file_contexts", |
| 963 | ":vendor_file_contexts", |
| 964 | ":system_ext_file_contexts", |
| 965 | ":product_file_contexts", |
| 966 | ":odm_file_contexts", |
| 967 | ":precompiled_sepolicy", |
| 968 | ], |
| 969 | tools: ["sepolicy_tests"], |
| 970 | out: ["sepolicy_dev_type_test"], |
| 971 | soong_config_variables: { |
| 972 | CHECK_DEV_TYPE_VIOLATIONS: { |
| 973 | cmd: "$(location sepolicy_tests) " + |
| 974 | "-f $(location :plat_file_contexts) " + |
| 975 | "-f $(location :vendor_file_contexts) " + |
| 976 | "-f $(location :system_ext_file_contexts) " + |
| 977 | "-f $(location :product_file_contexts) " + |
| 978 | "-f $(location :odm_file_contexts) " + |
| 979 | "-p $(location :precompiled_sepolicy) " + |
| 980 | "-t TestDevTypeViolations && " + |
| 981 | "touch $(out)", |
| 982 | conditions_default: { |
| 983 | cmd: "touch $(out)", |
| 984 | }, |
| 985 | }, |
| 986 | }, |
| 987 | } |