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 | |
Jeff Vander Stoep | ecd288f | 2019-02-15 12:18:15 -0800 | [diff] [blame] | 45 | cc_defaults { name: "selinux_policy_version", cflags: ["-DSEPOLICY_VERSION=30"], } |
| 46 | |
yangbill | 3e34537 | 2020-04-15 13:55:47 +0800 | [diff] [blame] | 47 | // For vts_treble_sys_prop_test |
| 48 | filegroup { |
| 49 | name: "private_property_contexts", |
| 50 | srcs: ["private/property_contexts"], |
| 51 | visibility: [ |
| 52 | "//test/vts-testcase/security/system_property", |
| 53 | ], |
| 54 | } |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 55 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 56 | se_build_files { |
| 57 | name: "se_build_files", |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 58 | srcs: [ |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 59 | "security_classes", |
| 60 | "initial_sids", |
| 61 | "access_vectors", |
| 62 | "global_macros", |
| 63 | "neverallow_macros", |
| 64 | "mls_macros", |
| 65 | "mls_decl", |
| 66 | "mls", |
| 67 | "policy_capabilities", |
| 68 | "te_macros", |
| 69 | "attributes", |
| 70 | "ioctl_defines", |
| 71 | "ioctl_macros", |
| 72 | "*.te", |
| 73 | "roles_decl", |
| 74 | "roles", |
| 75 | "users", |
| 76 | "initial_sid_contexts", |
| 77 | "fs_use", |
| 78 | "genfs_contexts", |
| 79 | "port_contexts", |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 80 | ], |
| 81 | } |
| 82 | |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 83 | se_build_files { |
| 84 | name: "sepolicy_technical_debt", |
| 85 | srcs: ["technical_debt.cil"], |
| 86 | } |
| 87 | |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 88 | reqd_mask_policy = [":se_build_files{.reqd_mask}"] |
| 89 | plat_public_policy = [":se_build_files{.plat_public}"] |
| 90 | plat_private_policy = [":se_build_files{.plat_private}"] |
| 91 | system_ext_public_policy = [":se_build_files{.system_ext_public}"] |
| 92 | system_ext_private_policy = [":se_build_files{.system_ext_private}"] |
| 93 | product_public_policy = [":se_build_files{.product_public}"] |
| 94 | product_private_policy = [":se_build_files{.product_private}"] |
| 95 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 96 | // reqd_policy_mask - a policy.conf file which contains only the bare minimum |
| 97 | // policy necessary to use checkpolicy. |
| 98 | // |
| 99 | // This bare-minimum policy needs to be present in all policy.conf files, but |
| 100 | // should not necessarily be exported as part of the public policy. |
| 101 | // |
| 102 | // The rules generated by reqd_policy_mask will allow the compilation of public |
| 103 | // policy and subsequent removal of CIL policy that should not be exported. |
| 104 | se_policy_conf { |
| 105 | name: "reqd_policy_mask.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 106 | srcs: reqd_mask_policy, |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 107 | installable: false, |
| 108 | } |
| 109 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 110 | se_policy_cil { |
| 111 | name: "reqd_policy_mask.cil", |
| 112 | src: ":reqd_policy_mask.conf", |
| 113 | secilc_check: false, |
| 114 | installable: false, |
Inseob Kim | e35b49b | 2021-02-18 19:15:41 +0900 | [diff] [blame] | 115 | } |
| 116 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 117 | // pub_policy - policy that will be exported to be a part of non-platform |
| 118 | // policy corresponding to this platform version. |
| 119 | // |
| 120 | // This is a limited subset of policy that would not compile in checkpolicy on |
| 121 | // its own. |
| 122 | // |
| 123 | // To get around this limitation, add only the required files from private |
| 124 | // policy, which will generate CIL policy that will then be filtered out by the |
| 125 | // reqd_policy_mask. |
| 126 | // |
| 127 | // There are three pub_policy.cil files below: |
| 128 | // - pub_policy.cil: exported 'product', 'system_ext' and 'system' policy. |
| 129 | // - system_ext_pub_policy.cil: exported 'system_ext' and 'system' policy. |
| 130 | // - plat_pub_policy.cil: exported 'system' policy. |
| 131 | // |
| 132 | // Those above files will in turn be used to generate the following versioned cil files: |
| 133 | // - product_mapping_file: the versioned, exported 'product' policy in product partition. |
| 134 | // - system_ext_mapping_file: the versioned, exported 'system_ext' policy in system_ext partition. |
| 135 | // - plat_mapping_file: the versioned, exported 'system' policy in system partition. |
| 136 | // - plat_pub_versioned.cil: the versioned, exported 'product', 'system_ext' and 'system' policy |
| 137 | // in vendor partition. |
| 138 | // |
| 139 | se_policy_conf { |
| 140 | name: "pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 141 | srcs: plat_public_policy + |
| 142 | system_ext_public_policy + |
| 143 | product_public_policy + |
| 144 | reqd_mask_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 145 | vendor: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 146 | installable: false, |
| 147 | } |
| 148 | |
| 149 | se_policy_cil { |
| 150 | name: "pub_policy.cil", |
| 151 | src: ":pub_policy.conf", |
| 152 | filter_out: [":reqd_policy_mask.cil"], |
| 153 | secilc_check: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 154 | vendor: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 155 | installable: false, |
| 156 | } |
| 157 | |
| 158 | se_policy_conf { |
| 159 | name: "system_ext_pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 160 | srcs: plat_public_policy + |
| 161 | system_ext_public_policy + |
| 162 | reqd_mask_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 163 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 164 | installable: false, |
| 165 | } |
| 166 | |
| 167 | se_policy_cil { |
| 168 | name: "system_ext_pub_policy.cil", |
| 169 | src: ":system_ext_pub_policy.conf", |
| 170 | filter_out: [":reqd_policy_mask.cil"], |
| 171 | secilc_check: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 172 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 173 | installable: false, |
| 174 | } |
| 175 | |
| 176 | se_policy_conf { |
| 177 | name: "plat_pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 178 | srcs: plat_public_policy + |
| 179 | reqd_mask_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 180 | installable: false, |
| 181 | } |
| 182 | |
| 183 | se_policy_cil { |
| 184 | name: "plat_pub_policy.cil", |
| 185 | src: ":plat_pub_policy.conf", |
| 186 | filter_out: [":reqd_policy_mask.cil"], |
| 187 | secilc_check: false, |
| 188 | installable: false, |
| 189 | } |
| 190 | |
| 191 | // plat_policy.conf - A combination of the private and public platform policy |
| 192 | // which will ship with the device. |
| 193 | // |
| 194 | // The platform will always reflect the most recent platform version and is not |
| 195 | // currently being attributized. |
| 196 | se_policy_conf { |
| 197 | name: "plat_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 198 | srcs: plat_public_policy + |
| 199 | plat_private_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 200 | installable: false, |
| 201 | } |
| 202 | |
| 203 | se_policy_cil { |
| 204 | name: "plat_sepolicy.cil", |
| 205 | src: ":plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 206 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 207 | } |
| 208 | |
Lokesh Gidra | 1269a17 | 2022-08-01 17:20:38 +0000 | [diff] [blame] | 209 | |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 210 | se_policy_conf { |
| 211 | name: "apex_sepolicy-33.conf", |
Lokesh Gidra | 1269a17 | 2022-08-01 17:20:38 +0000 | [diff] [blame] | 212 | srcs: plat_public_policy + plat_private_policy + ["com.android.sepolicy/33/*.te"], |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 213 | installable: false, |
| 214 | } |
| 215 | |
| 216 | se_policy_cil { |
| 217 | name: "apex_sepolicy-33.cil", |
| 218 | src: ":apex_sepolicy-33.conf", |
Lokesh Gidra | 1269a17 | 2022-08-01 17:20:38 +0000 | [diff] [blame] | 219 | filter_out: [":plat_sepolicy.cil"], |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 220 | installable: false, |
| 221 | stem: "apex_sepolicy.cil", |
| 222 | } |
| 223 | |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 224 | se_policy_cil { |
| 225 | name: "decompiled_sepolicy-without_apex.cil", |
| 226 | src: ":precompiled_sepolicy-without_apex", |
| 227 | decompile_binary: true, |
| 228 | } |
| 229 | |
| 230 | se_policy_cil { |
Sandro | 3f5c18c | 2022-09-01 16:07:28 +0000 | [diff] [blame] | 231 | name: "apex_sepolicy-33.decompiled.cil", |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 232 | src: ":precompiled_sepolicy", |
| 233 | decompile_binary: true, |
| 234 | filter_out: [":decompiled_sepolicy-without_apex.cil"], |
| 235 | additional_cil_files: ["com.android.sepolicy/33/definitions/definitions.cil"], |
| 236 | secilc_check: false, |
Sandro | 3f5c18c | 2022-09-01 16:07:28 +0000 | [diff] [blame] | 237 | stem: "apex_sepolicy.decompiled.cil", |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 240 | // userdebug_plat_policy.conf - the userdebug version plat_sepolicy.cil |
| 241 | se_policy_conf { |
| 242 | name: "userdebug_plat_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 243 | srcs: plat_public_policy + |
| 244 | plat_private_policy, |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 245 | build_variant: "userdebug", |
| 246 | installable: false, |
| 247 | } |
| 248 | |
| 249 | se_policy_cil { |
| 250 | name: "userdebug_plat_sepolicy.cil", |
| 251 | src: ":userdebug_plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 252 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 253 | debug_ramdisk: true, |
Yi-Yo Chiang | 68478b1 | 2021-10-16 03:23:05 +0800 | [diff] [blame] | 254 | dist: { |
| 255 | targets: ["droidcore"], |
| 256 | }, |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Yi-Yo Chiang | 857ffc4 | 2021-09-23 14:14:16 +0000 | [diff] [blame] | 259 | // A copy of the userdebug_plat_policy in GSI. |
| 260 | soong_config_module_type { |
| 261 | name: "gsi_se_policy_cil", |
| 262 | module_type: "se_policy_cil", |
| 263 | config_namespace: "ANDROID", |
| 264 | bool_variables: [ |
| 265 | "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT", |
| 266 | ], |
| 267 | properties: [ |
| 268 | "enabled", |
| 269 | "installable", |
| 270 | ], |
| 271 | } |
| 272 | |
| 273 | gsi_se_policy_cil { |
| 274 | name: "system_ext_userdebug_plat_sepolicy.cil", |
| 275 | stem: "userdebug_plat_sepolicy.cil", |
| 276 | src: ":userdebug_plat_sepolicy.conf", |
Inseob Kim | 7cb2081 | 2021-12-16 16:52:14 +0900 | [diff] [blame] | 277 | additional_cil_files: [":sepolicy_technical_debt{.plat_private}"], |
Yi-Yo Chiang | 857ffc4 | 2021-09-23 14:14:16 +0000 | [diff] [blame] | 278 | system_ext_specific: true, |
| 279 | enabled: false, |
| 280 | installable: false, |
| 281 | soong_config_variables: { |
| 282 | PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: { |
| 283 | enabled: true, |
| 284 | installable: true, |
| 285 | }, |
| 286 | }, |
| 287 | } |
| 288 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 289 | // system_ext_policy.conf - A combination of the private and public system_ext |
| 290 | // policy which will ship with the device. System_ext policy is not attributized |
| 291 | se_policy_conf { |
| 292 | name: "system_ext_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 293 | srcs: plat_public_policy + |
| 294 | plat_private_policy + |
| 295 | system_ext_public_policy + |
| 296 | system_ext_private_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 297 | system_ext_specific: true, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 298 | installable: false, |
| 299 | } |
| 300 | |
| 301 | se_policy_cil { |
| 302 | name: "system_ext_sepolicy.cil", |
| 303 | src: ":system_ext_sepolicy.conf", |
| 304 | system_ext_specific: true, |
| 305 | filter_out: [":plat_sepolicy.cil"], |
| 306 | remove_line_marker: true, |
| 307 | } |
| 308 | |
| 309 | // product_policy.conf - A combination of the private and public product policy |
| 310 | // which will ship with the device. Product policy is not attributized |
| 311 | se_policy_conf { |
| 312 | name: "product_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 313 | srcs: plat_public_policy + |
| 314 | plat_private_policy + |
| 315 | system_ext_public_policy + |
| 316 | system_ext_private_policy + |
| 317 | product_public_policy + |
| 318 | product_private_policy, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 319 | product_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: "product_sepolicy.cil", |
| 325 | src: ":product_sepolicy.conf", |
| 326 | product_specific: true, |
| 327 | filter_out: [":plat_sepolicy.cil", ":system_ext_sepolicy.cil"], |
| 328 | remove_line_marker: true, |
| 329 | } |
| 330 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 331 | // policy mapping files |
| 332 | // auto-generate the mapping file for current platform policy, since it needs to |
| 333 | // track platform policy development |
| 334 | se_versioned_policy { |
| 335 | name: "plat_mapping_file", |
| 336 | base: ":plat_pub_policy.cil", |
| 337 | mapping: true, |
| 338 | version: "current", |
| 339 | relative_install_path: "mapping", // install to /system/etc/selinux/mapping |
| 340 | } |
| 341 | |
| 342 | se_versioned_policy { |
| 343 | name: "system_ext_mapping_file", |
| 344 | base: ":system_ext_pub_policy.cil", |
| 345 | mapping: true, |
| 346 | version: "current", |
| 347 | filter_out: [":plat_mapping_file"], |
| 348 | relative_install_path: "mapping", // install to /system_ext/etc/selinux/mapping |
| 349 | system_ext_specific: true, |
| 350 | } |
| 351 | |
| 352 | se_versioned_policy { |
| 353 | name: "product_mapping_file", |
| 354 | base: ":pub_policy.cil", |
| 355 | mapping: true, |
| 356 | version: "current", |
| 357 | filter_out: [":plat_mapping_file", ":system_ext_mapping_file"], |
| 358 | relative_install_path: "mapping", // install to /product/etc/selinux/mapping |
| 359 | product_specific: true, |
| 360 | } |
| 361 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 362 | // vendor/odm sepolicy |
| 363 | // |
| 364 | // If BOARD_SEPOLICY_VERS is set to a value other than PLATFORM_SEPOLICY_VERSION, |
| 365 | // policy files of platform (system, system_ext, product) can't be mixed with |
| 366 | // policy files of vendor (vendor, odm). If it's the case, platform policies and |
| 367 | // vendor policies are separately built. More specifically, |
| 368 | // |
| 369 | // - Platform policy files needed to build vendor policies, such as plat_policy, |
| 370 | // plat_mapping_cil, plat_pub_policy, reqd_policy_mask, are built from the |
| 371 | // prebuilts (copy of platform policy files of version BOARD_SEPOLICY_VERS). |
| 372 | // |
| 373 | // - sepolicy_neverallows only checks platform policies, and a new module |
| 374 | // sepolicy_neverallows_vendor checks vendor policies. |
| 375 | // |
| 376 | // - neverallow checks are turned off while compiling precompiled_sepolicy |
| 377 | // module and sepolicy module. |
| 378 | // |
| 379 | // - Vendor policies are not checked on the compat test (compat.mk). |
| 380 | // |
| 381 | // In such scenario, we can grab platform policy files from the prebuilts/api |
| 382 | // directory. But we need more than that: prebuilts of system_ext, product, |
| 383 | // system/sepolicy/reqd_mask, and system/sepolicy/vendor. The following |
| 384 | // variables are introduced to specify such prebuilts. |
| 385 | // |
| 386 | // - BOARD_REQD_MASK_POLICY (prebuilt of system/sepolicy/reqd_mask) |
| 387 | // - BOARD_PLAT_VENDOR_POLICY (prebuilt of system/sepolicy/vendor) |
| 388 | // - BOARD_SYSTEM_EXT_PUBLIC_PREBUILT_DIRS (prebuilt of system_ext public) |
| 389 | // - BOARD_SYSTEM_EXT_PRIVATE_PREBUILT_DIRS (prebuilt of system_ext private) |
| 390 | // - BOARD_PRODUCT_PUBLIC_PREBUILT_DIRS (prebuilt of product public) |
| 391 | // - BOARD_PRODUCT_PRIVATE_PREBUILT_DIRS (prebuilt of product private) |
| 392 | // |
| 393 | // Vendors are responsible for copying policy files from the old version of the |
| 394 | // source tree as prebuilts, and for setting BOARD_*_POLICY variables so they |
| 395 | // can be used to build vendor policies. |
| 396 | // |
| 397 | // To support both mixed build and normal build, platform policy files are |
| 398 | // indirectly referred as {.(partition)_(scope)_for_vendor}. They will be equal |
| 399 | // to {.(partition)_scope)} if BOARD_SEPOLICY_VERS == PLATFORM_SEPOLICY_VERSION. |
| 400 | // Otherwise, they will be equal to the Makefile variables above. |
| 401 | |
| 402 | plat_public_policies_for_vendor = [ |
| 403 | ":se_build_files{.plat_public_for_vendor}", |
| 404 | ":se_build_files{.system_ext_public_for_vendor}", |
| 405 | ":se_build_files{.product_public_for_vendor}", |
| 406 | ":se_build_files{.reqd_mask_for_vendor}", |
| 407 | ] |
| 408 | |
| 409 | plat_policies_for_vendor = [ |
| 410 | ":se_build_files{.plat_public_for_vendor}", |
| 411 | ":se_build_files{.plat_private_for_vendor}", |
| 412 | ":se_build_files{.system_ext_public_for_vendor}", |
| 413 | ":se_build_files{.system_ext_private_for_vendor}", |
| 414 | ":se_build_files{.product_public_for_vendor}", |
| 415 | ":se_build_files{.product_private_for_vendor}", |
| 416 | ] |
| 417 | |
| 418 | se_policy_conf { |
| 419 | name: "plat_policy_for_vendor.conf", |
| 420 | srcs: plat_policies_for_vendor, |
| 421 | installable: false, |
| 422 | } |
| 423 | |
| 424 | se_policy_cil { |
| 425 | name: "plat_policy_for_vendor.cil", |
| 426 | src: ":plat_policy_for_vendor.conf", |
| 427 | additional_cil_files: [":sepolicy_technical_debt{.plat_private_for_vendor}"], |
| 428 | installable: false, |
| 429 | } |
| 430 | |
| 431 | se_policy_conf { |
| 432 | name: "reqd_policy_mask_for_vendor.conf", |
| 433 | srcs: [":se_build_files{.reqd_mask_for_vendor}"], |
| 434 | installable: false, |
| 435 | } |
| 436 | |
| 437 | se_policy_cil { |
| 438 | name: "reqd_policy_mask_for_vendor.cil", |
| 439 | src: ":reqd_policy_mask_for_vendor.conf", |
| 440 | secilc_check: false, |
| 441 | installable: false, |
| 442 | } |
| 443 | |
| 444 | se_policy_conf { |
| 445 | name: "pub_policy_for_vendor.conf", |
| 446 | srcs: plat_public_policies_for_vendor, |
| 447 | installable: false, |
| 448 | } |
| 449 | |
| 450 | se_policy_cil { |
| 451 | name: "pub_policy_for_vendor.cil", |
| 452 | src: ":pub_policy_for_vendor.conf", |
| 453 | filter_out: [":reqd_policy_mask_for_vendor.cil"], |
| 454 | secilc_check: false, |
| 455 | installable: false, |
| 456 | } |
| 457 | |
| 458 | se_versioned_policy { |
| 459 | name: "plat_mapping_file_for_vendor", |
| 460 | base: ":pub_policy_for_vendor.cil", |
| 461 | mapping: true, |
| 462 | version: "vendor", |
| 463 | installable: false, |
| 464 | } |
| 465 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 466 | // plat_pub_versioned.cil - the exported platform policy associated with the version |
| 467 | // that non-platform policy targets. |
| 468 | se_versioned_policy { |
| 469 | name: "plat_pub_versioned.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 470 | base: ":pub_policy_for_vendor.cil", |
| 471 | target_policy: ":pub_policy_for_vendor.cil", |
| 472 | version: "vendor", |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 473 | vendor: true, |
| 474 | } |
| 475 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 476 | // vendor_policy.cil - the vendor sepolicy. This needs attributization and to be combined |
| 477 | // with the platform-provided policy. It makes use of the reqd_policy_mask files from private |
| 478 | // policy and the platform public policy files in order to use checkpolicy. |
| 479 | se_policy_conf { |
| 480 | name: "vendor_sepolicy.conf", |
| 481 | srcs: plat_public_policies_for_vendor + [ |
| 482 | ":se_build_files{.plat_vendor_for_vendor}", |
| 483 | ":se_build_files{.vendor}", |
| 484 | ], |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 485 | vendor: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 486 | installable: false, |
| 487 | } |
| 488 | |
| 489 | se_policy_cil { |
| 490 | name: "vendor_sepolicy.cil.raw", |
| 491 | src: ":vendor_sepolicy.conf", |
| 492 | filter_out: [":reqd_policy_mask_for_vendor.cil"], |
| 493 | secilc_check: false, // will be done in se_versioned_policy module |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 494 | vendor: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 495 | installable: false, |
| 496 | } |
| 497 | |
| 498 | se_versioned_policy { |
| 499 | name: "vendor_sepolicy.cil", |
| 500 | base: ":pub_policy_for_vendor.cil", |
| 501 | target_policy: ":vendor_sepolicy.cil.raw", |
| 502 | version: "vendor", |
| 503 | dependent_cils: [ |
| 504 | ":plat_policy_for_vendor.cil", |
| 505 | ":plat_pub_versioned.cil", |
| 506 | ":plat_mapping_file_for_vendor", |
| 507 | ], |
| 508 | filter_out: [":plat_pub_versioned.cil"], |
| 509 | vendor: true, |
| 510 | } |
| 511 | |
| 512 | // odm_policy.cil - the odl sepolicy. This needs attributization and to be combined |
| 513 | // with the platform-provided policy. It makes use of the reqd_policy_mask files from private |
| 514 | // policy and the platform public policy files in order to use checkpolicy. |
| 515 | se_policy_conf { |
| 516 | name: "odm_sepolicy.conf", |
| 517 | srcs: plat_public_policies_for_vendor + [ |
| 518 | ":se_build_files{.plat_vendor_for_vendor}", |
| 519 | ":se_build_files{.vendor}", |
| 520 | ":se_build_files{.odm}", |
| 521 | ], |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 522 | device_specific: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 523 | installable: false, |
| 524 | } |
| 525 | |
| 526 | se_policy_cil { |
| 527 | name: "odm_sepolicy.cil.raw", |
| 528 | src: ":odm_sepolicy.conf", |
| 529 | filter_out: [ |
| 530 | ":reqd_policy_mask_for_vendor.cil", |
| 531 | ":vendor_sepolicy.cil", |
| 532 | ], |
| 533 | secilc_check: false, // will be done in se_versioned_policy module |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 534 | device_specific: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 535 | installable: false, |
| 536 | } |
| 537 | |
| 538 | se_versioned_policy { |
| 539 | name: "odm_sepolicy.cil", |
| 540 | base: ":pub_policy_for_vendor.cil", |
| 541 | target_policy: ":odm_sepolicy.cil.raw", |
| 542 | version: "vendor", |
| 543 | dependent_cils: [ |
| 544 | ":plat_policy_for_vendor.cil", |
| 545 | ":plat_pub_versioned.cil", |
| 546 | ":plat_mapping_file_for_vendor", |
| 547 | ":vendor_sepolicy.cil", |
| 548 | ], |
| 549 | filter_out: [":plat_pub_versioned.cil", ":vendor_sepolicy.cil"], |
| 550 | device_specific: true, |
| 551 | } |
| 552 | |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 553 | ////////////////////////////////// |
| 554 | // Precompiled sepolicy is loaded if and only if: |
| 555 | // - plat_sepolicy_and_mapping.sha256 equals |
| 556 | // precompiled_sepolicy.plat_sepolicy_and_mapping.sha256 |
| 557 | // AND |
| 558 | // - system_ext_sepolicy_and_mapping.sha256 equals |
| 559 | // precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256 |
| 560 | // AND |
| 561 | // - product_sepolicy_and_mapping.sha256 equals |
| 562 | // precompiled_sepolicy.product_sepolicy_and_mapping.sha256 |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 563 | // AND |
| 564 | // - apex_sepolicy.sha256 equals |
| 565 | // precompiled_sepolicy.apex_sepolicy.sha256 |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 566 | // See system/core/init/selinux.cpp for details. |
| 567 | ////////////////////////////////// |
| 568 | genrule { |
| 569 | name: "plat_sepolicy_and_mapping.sha256_gen", |
| 570 | srcs: [":plat_sepolicy.cil", ":plat_mapping_file"], |
| 571 | out: ["plat_sepolicy_and_mapping.sha256"], |
| 572 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 573 | } |
| 574 | |
| 575 | prebuilt_etc { |
| 576 | name: "plat_sepolicy_and_mapping.sha256", |
| 577 | filename: "plat_sepolicy_and_mapping.sha256", |
| 578 | src: ":plat_sepolicy_and_mapping.sha256_gen", |
| 579 | relative_install_path: "selinux", |
| 580 | } |
| 581 | |
| 582 | genrule { |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 583 | name: "apex_sepolicy.sha256_gen", |
| 584 | srcs: [":apex_sepolicy-33.cil"], |
| 585 | out: ["apex_sepolicy.sha256"], |
| 586 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 587 | } |
| 588 | |
| 589 | prebuilt_etc { |
| 590 | name: "apex_sepolicy.sha256", |
| 591 | filename: "apex_sepolicy.sha256", |
| 592 | src: ":apex_sepolicy.sha256_gen", |
| 593 | installable: false, |
| 594 | } |
| 595 | |
| 596 | genrule { |
Inseob Kim | 039175b | 2021-03-25 15:37:34 +0900 | [diff] [blame] | 597 | name: "system_ext_sepolicy_and_mapping.sha256_gen", |
| 598 | srcs: [":system_ext_sepolicy.cil", ":system_ext_mapping_file"], |
| 599 | out: ["system_ext_sepolicy_and_mapping.sha256"], |
| 600 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 601 | } |
| 602 | |
| 603 | prebuilt_etc { |
| 604 | name: "system_ext_sepolicy_and_mapping.sha256", |
| 605 | filename: "system_ext_sepolicy_and_mapping.sha256", |
| 606 | src: ":system_ext_sepolicy_and_mapping.sha256_gen", |
| 607 | relative_install_path: "selinux", |
| 608 | system_ext_specific: true, |
| 609 | } |
| 610 | |
| 611 | genrule { |
| 612 | name: "product_sepolicy_and_mapping.sha256_gen", |
| 613 | srcs: [":product_sepolicy.cil", ":product_mapping_file"], |
| 614 | out: ["product_sepolicy_and_mapping.sha256"], |
| 615 | cmd: "cat $(in) | sha256sum | cut -d' ' -f1 > $(out)", |
| 616 | } |
| 617 | |
| 618 | prebuilt_etc { |
| 619 | name: "product_sepolicy_and_mapping.sha256", |
| 620 | filename: "product_sepolicy_and_mapping.sha256", |
| 621 | src: ":product_sepolicy_and_mapping.sha256_gen", |
| 622 | relative_install_path: "selinux", |
| 623 | product_specific: true, |
| 624 | } |
| 625 | |
Inseob Kim | 1c056b1 | 2021-04-30 00:11:43 +0900 | [diff] [blame] | 626 | sepolicy_vers { |
| 627 | name: "plat_sepolicy_vers.txt", |
| 628 | version: "vendor", |
| 629 | vendor: true, |
| 630 | } |
| 631 | |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 632 | soong_config_module_type { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 633 | name: "precompiled_sepolicy_prebuilts_defaults", |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 634 | module_type: "prebuilt_defaults", |
| 635 | config_namespace: "ANDROID", |
| 636 | bool_variables: ["BOARD_USES_ODMIMAGE"], |
| 637 | properties: ["vendor", "device_specific"], |
| 638 | } |
| 639 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 640 | precompiled_sepolicy_prebuilts_defaults { |
| 641 | name: "precompiled_sepolicy_prebuilts", |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 642 | soong_config_variables: { |
| 643 | BOARD_USES_ODMIMAGE: { |
| 644 | device_specific: true, |
| 645 | conditions_default: { |
| 646 | vendor: true, |
| 647 | }, |
| 648 | }, |
| 649 | }, |
| 650 | } |
| 651 | |
| 652 | ////////////////////////////////// |
| 653 | // SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against |
| 654 | // which precompiled_policy was built. |
| 655 | ////////////////////////////////// |
| 656 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 657 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 658 | name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", |
| 659 | filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", |
| 660 | src: ":plat_sepolicy_and_mapping.sha256_gen", |
| 661 | relative_install_path: "selinux", |
| 662 | } |
| 663 | |
| 664 | ////////////////////////////////// |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 665 | // SHA-256 digest of the apex_sepolicy.cil against which precompiled_policy |
| 666 | // was built. |
| 667 | ////////////////////////////////// |
| 668 | prebuilt_etc { |
| 669 | defaults: ["precompiled_sepolicy_prebuilts"], |
| 670 | name: "precompiled_sepolicy.apex_sepolicy.sha256", |
| 671 | filename: "precompiled_sepolicy.apex_sepolicy.sha256", |
| 672 | src: ":apex_sepolicy.sha256_gen", |
| 673 | relative_install_path: "selinux", |
| 674 | } |
| 675 | |
| 676 | ////////////////////////////////// |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 677 | // SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against |
| 678 | // which precompiled_policy was built. |
| 679 | ////////////////////////////////// |
| 680 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 681 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 682 | name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", |
| 683 | filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", |
| 684 | src: ":system_ext_sepolicy_and_mapping.sha256_gen", |
| 685 | relative_install_path: "selinux", |
| 686 | } |
| 687 | |
| 688 | ////////////////////////////////// |
| 689 | // SHA-256 digest of the product_sepolicy.cil and product_mapping_file against |
| 690 | // which precompiled_policy was built. |
| 691 | ////////////////////////////////// |
| 692 | prebuilt_etc { |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 693 | defaults: ["precompiled_sepolicy_prebuilts"], |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 694 | name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", |
| 695 | filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", |
| 696 | src: ":product_sepolicy_and_mapping.sha256_gen", |
| 697 | relative_install_path: "selinux", |
| 698 | } |
| 699 | |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 700 | soong_config_module_type { |
| 701 | name: "precompiled_se_policy_binary", |
| 702 | module_type: "se_policy_binary", |
| 703 | config_namespace: "ANDROID", |
| 704 | bool_variables: ["BOARD_USES_ODMIMAGE", "IS_TARGET_MIXED_SEPOLICY"], |
| 705 | value_variables: ["MIXED_SEPOLICY_VERSION"], |
| 706 | properties: ["vendor", "device_specific", "srcs", "ignore_neverallow"], |
| 707 | } |
| 708 | |
| 709 | precompiled_se_policy_binary { |
| 710 | name: "precompiled_sepolicy", |
| 711 | srcs: [ |
| 712 | ":plat_sepolicy.cil", |
Jeff Vander Stoep | f9348b5 | 2021-12-14 13:32:12 +0100 | [diff] [blame] | 713 | ":apex_sepolicy-33.cil", |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 714 | ":plat_pub_versioned.cil", |
| 715 | ":system_ext_sepolicy.cil", |
| 716 | ":product_sepolicy.cil", |
| 717 | ":vendor_sepolicy.cil", |
| 718 | ":odm_sepolicy.cil", |
| 719 | ], |
| 720 | soong_config_variables: { |
| 721 | BOARD_USES_ODMIMAGE: { |
| 722 | device_specific: true, |
| 723 | conditions_default: { |
| 724 | vendor: true, |
| 725 | }, |
| 726 | }, |
| 727 | IS_TARGET_MIXED_SEPOLICY: { |
| 728 | ignore_neverallow: true, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 729 | }, |
| 730 | MIXED_SEPOLICY_VERSION: { |
| 731 | srcs: [ |
| 732 | ":plat_%s.cil", |
| 733 | ":system_ext_%s.cil", |
| 734 | ":product_%s.cil", |
| 735 | ], |
| 736 | conditions_default: { |
| 737 | srcs: [ |
| 738 | ":plat_mapping_file", |
| 739 | ":system_ext_mapping_file", |
| 740 | ":product_mapping_file", |
| 741 | ], |
| 742 | }, |
| 743 | }, |
| 744 | }, |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 745 | required: [ |
| 746 | "sepolicy_neverallows", |
| 747 | "sepolicy_neverallows_vendor", |
| 748 | ], |
Inseob Kim | eec3919 | 2022-01-21 11:47:54 +0900 | [diff] [blame] | 749 | dist: { |
| 750 | targets: ["base-sepolicy-files-for-mapping"], |
| 751 | }, |
Inseob Kim | 3ac62fe | 2021-12-16 19:00:03 +0900 | [diff] [blame] | 752 | } |
Inseob Kim | 731182a | 2021-05-06 11:44:37 +0000 | [diff] [blame] | 753 | |
Sandro | 143988d | 2022-08-05 11:38:56 +0000 | [diff] [blame] | 754 | precompiled_se_policy_binary { |
| 755 | name: "precompiled_sepolicy-without_apex", |
| 756 | srcs: [ |
| 757 | ":plat_sepolicy.cil", |
| 758 | ":plat_pub_versioned.cil", |
| 759 | ":system_ext_sepolicy.cil", |
| 760 | ":product_sepolicy.cil", |
| 761 | ":vendor_sepolicy.cil", |
| 762 | ":odm_sepolicy.cil", |
| 763 | ], |
| 764 | soong_config_variables: { |
| 765 | BOARD_USES_ODMIMAGE: { |
| 766 | device_specific: true, |
| 767 | conditions_default: { |
| 768 | vendor: true, |
| 769 | }, |
| 770 | }, |
| 771 | IS_TARGET_MIXED_SEPOLICY: { |
| 772 | ignore_neverallow: true, |
| 773 | }, |
| 774 | MIXED_SEPOLICY_VERSION: { |
| 775 | srcs: [ |
| 776 | ":plat_%s.cil", |
| 777 | ":system_ext_%s.cil", |
| 778 | ":product_%s.cil", |
| 779 | ], |
| 780 | conditions_default: { |
| 781 | srcs: [ |
| 782 | ":plat_mapping_file", |
| 783 | ":system_ext_mapping_file", |
| 784 | ":product_mapping_file", |
| 785 | ], |
| 786 | }, |
| 787 | }, |
| 788 | }, |
| 789 | required: [ |
| 790 | "sepolicy_neverallows", |
| 791 | "sepolicy_neverallows_vendor", |
| 792 | ], |
| 793 | dist: { |
| 794 | targets: ["base-sepolicy-files-for-mapping"], |
| 795 | }, |
| 796 | } |
| 797 | |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 798 | // policy for recovery |
| 799 | se_policy_conf { |
| 800 | name: "recovery_sepolicy.conf", |
| 801 | srcs: plat_policies_for_vendor + [ |
| 802 | ":se_build_files{.plat_vendor_for_vendor}", |
| 803 | ":se_build_files{.vendor}", |
| 804 | ":se_build_files{.odm}", |
| 805 | ], |
| 806 | target_recovery: true, |
| 807 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 808 | recovery: true, |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | se_policy_cil { |
| 812 | name: "recovery_sepolicy.cil", |
| 813 | src: ":recovery_sepolicy.conf", |
| 814 | secilc_check: false, // will be done in se_policy_binary module |
| 815 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 816 | recovery: true, |
Inseob Kim | 5bbcd68 | 2021-12-28 14:57:03 +0900 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | se_policy_binary { |
| 820 | name: "sepolicy.recovery", |
| 821 | srcs: [":recovery_sepolicy.cil"], |
| 822 | stem: "sepolicy", |
| 823 | recovery: true, |
| 824 | } |
| 825 | |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 826 | ////////////////////////////////// |
| 827 | // SELinux policy embedded into CTS. |
| 828 | // CTS checks neverallow rules of this policy against the policy of the device under test. |
| 829 | ////////////////////////////////// |
| 830 | se_policy_conf { |
| 831 | name: "general_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 832 | srcs: plat_public_policy + |
| 833 | plat_private_policy, |
Inseob Kim | a49e724 | 2021-03-22 10:26:13 +0900 | [diff] [blame] | 834 | build_variant: "user", |
| 835 | cts: true, |
| 836 | exclude_build_test: true, |
| 837 | } |
Inseob Kim | d581661 | 2021-09-15 03:01:05 +0000 | [diff] [blame] | 838 | |
| 839 | ////////////////////////////////// |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 840 | // Base system policy for treble sepolicy tests. |
| 841 | // If system sepolicy is extended (e.g. by SoC vendors), their plat_pub_versioned.cil may differ |
| 842 | // with system/sepolicy/prebuilts/api/{version}/plat_pub_versioned.cil. In that case, |
| 843 | // BOARD_PLAT_PUB_VERSIONED_POLICY can be used to specify extended plat_pub_versioned.cil. |
| 844 | // See treble_sepolicy_tests_for_release.mk for more details. |
| 845 | ////////////////////////////////// |
| 846 | se_policy_conf { |
| 847 | name: "base_plat_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 848 | srcs: plat_public_policy + |
| 849 | plat_private_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 850 | build_variant: "user", |
| 851 | installable: false, |
| 852 | } |
| 853 | |
| 854 | se_policy_cil { |
| 855 | name: "base_plat_sepolicy.cil", |
| 856 | src: ":base_plat_sepolicy.conf", |
| 857 | additional_cil_files: ["private/technical_debt.cil"], |
| 858 | installable: false, |
| 859 | secilc_check: false, // done by se_policy_binary |
| 860 | } |
| 861 | |
| 862 | se_policy_binary { |
| 863 | name: "base_plat_sepolicy", |
| 864 | srcs: [":base_plat_sepolicy.cil"], |
| 865 | installable: false, |
Inseob Kim | eec3919 | 2022-01-21 11:47:54 +0900 | [diff] [blame] | 866 | dist: { |
| 867 | targets: ["base-sepolicy-files-for-mapping"], |
| 868 | }, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | se_policy_conf { |
| 872 | name: "base_system_ext_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 873 | srcs: plat_public_policy + |
| 874 | plat_private_policy + |
| 875 | system_ext_public_policy + |
| 876 | system_ext_private_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 877 | build_variant: "user", |
| 878 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 879 | system_ext_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | se_policy_cil { |
| 883 | name: "base_system_ext_sepolicy.cil", |
| 884 | src: ":base_system_ext_sepolicy.conf", |
| 885 | additional_cil_files: ["private/technical_debt.cil"], |
| 886 | system_ext_specific: true, |
| 887 | installable: false, |
| 888 | secilc_check: false, // done by se_policy_binary |
| 889 | } |
| 890 | |
| 891 | se_policy_binary { |
| 892 | name: "base_system_ext_sepolicy", |
| 893 | srcs: [":base_system_ext_sepolicy.cil"], |
| 894 | system_ext_specific: true, |
| 895 | installable: false, |
| 896 | } |
| 897 | |
| 898 | se_policy_conf { |
| 899 | name: "base_product_sepolicy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +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 + |
| 905 | product_private_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 906 | build_variant: "user", |
| 907 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 908 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | se_policy_cil { |
| 912 | name: "base_product_sepolicy.cil", |
| 913 | src: ":base_product_sepolicy.conf", |
| 914 | additional_cil_files: ["private/technical_debt.cil"], |
| 915 | product_specific: true, |
| 916 | installable: false, |
| 917 | secilc_check: false, // done by se_policy_binary |
| 918 | } |
| 919 | |
| 920 | se_policy_binary { |
| 921 | name: "base_product_sepolicy", |
| 922 | srcs: [":base_product_sepolicy.cil"], |
| 923 | product_specific: true, |
| 924 | installable: false, |
| 925 | } |
| 926 | |
| 927 | se_policy_conf { |
| 928 | name: "base_plat_pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 929 | srcs: plat_public_policy + |
| 930 | reqd_mask_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 931 | build_variant: "user", |
| 932 | installable: false, |
| 933 | } |
| 934 | |
| 935 | se_policy_cil { |
| 936 | name: "base_plat_pub_policy.cil", |
| 937 | src: ":base_plat_pub_policy.conf", |
| 938 | filter_out: [":reqd_policy_mask.cil"], |
| 939 | secilc_check: false, |
| 940 | installable: false, |
Inseob Kim | eec3919 | 2022-01-21 11:47:54 +0900 | [diff] [blame] | 941 | dist: { |
| 942 | targets: ["base-sepolicy-files-for-mapping"], |
| 943 | }, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | se_policy_conf { |
| 947 | name: "base_system_ext_pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 948 | srcs: plat_public_policy + |
| 949 | system_ext_public_policy + |
| 950 | reqd_mask_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 951 | build_variant: "user", |
| 952 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 953 | system_ext_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | se_policy_cil { |
| 957 | name: "base_system_ext_pub_policy.cil", |
| 958 | src: ":base_system_ext_pub_policy.conf", |
| 959 | filter_out: [":reqd_policy_mask.cil"], |
| 960 | secilc_check: false, |
| 961 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 962 | system_ext_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | se_policy_conf { |
| 966 | name: "base_product_pub_policy.conf", |
Inseob Kim | 0a707fa | 2021-12-09 23:35:11 +0900 | [diff] [blame] | 967 | srcs: plat_public_policy + |
| 968 | system_ext_public_policy + |
| 969 | product_public_policy + |
| 970 | reqd_mask_policy, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 971 | build_variant: "user", |
| 972 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 973 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | se_policy_cil { |
| 977 | name: "base_product_pub_policy.cil", |
| 978 | src: ":base_product_pub_policy.conf", |
| 979 | filter_out: [":reqd_policy_mask.cil"], |
| 980 | secilc_check: false, |
| 981 | installable: false, |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 982 | product_specific: true, |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 983 | } |
| 984 | |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 985 | // bug_map - Bug tracking information for selinux denials loaded by auditd. |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 986 | se_build_files { |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 987 | name: "bug_map_files", |
| 988 | srcs: ["bug_map"], |
| 989 | } |
| 990 | |
| 991 | se_bug_map { |
| 992 | name: "plat_bug_map", |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 993 | srcs: [":bug_map_files{.plat_private}"], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 994 | stem: "bug_map", |
| 995 | } |
| 996 | |
| 997 | se_bug_map { |
| 998 | name: "system_ext_bug_map", |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 999 | srcs: [":bug_map_files{.system_ext_private}"], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 1000 | stem: "bug_map", |
| 1001 | system_ext_specific: true, |
| 1002 | } |
| 1003 | |
| 1004 | se_bug_map { |
| 1005 | name: "vendor_bug_map", |
Inseob Kim | 4196403 | 2022-04-22 07:50:22 +0900 | [diff] [blame] | 1006 | srcs: [":bug_map_files{.vendor}", ":bug_map_files{.plat_vendor_for_vendor}"], |
Yi-Yo Chiang | 2c18965 | 2021-11-08 19:30:04 +0800 | [diff] [blame] | 1007 | // Legacy file name of the vendor partition bug_map. |
| 1008 | stem: "selinux_denial_metadata", |
| 1009 | vendor: true, |
| 1010 | } |
| 1011 | |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 1012 | se_neverallow_test { |
| 1013 | name: "sepolicy_neverallows", |
| 1014 | srcs: plat_public_policy + |
| 1015 | plat_private_policy + |
| 1016 | system_ext_public_policy + |
| 1017 | system_ext_private_policy + |
| 1018 | product_public_policy + |
| 1019 | product_private_policy, |
| 1020 | } |
| 1021 | |
| 1022 | se_neverallow_test { |
| 1023 | name: "sepolicy_neverallows_vendor", |
| 1024 | srcs: plat_policies_for_vendor + [ |
| 1025 | ":se_build_files{.plat_vendor_for_vendor}", |
| 1026 | ":se_build_files{.vendor}", |
| 1027 | ":se_build_files{.odm}", |
| 1028 | ], |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 1029 | vendor: true, |
Inseob Kim | 0de7fcc | 2021-12-22 23:06:53 +0900 | [diff] [blame] | 1030 | } |
| 1031 | |
Inseob Kim | 4d90b7e | 2021-09-27 13:43:01 +0000 | [diff] [blame] | 1032 | ////////////////////////////////// |
Inseob Kim | d581661 | 2021-09-15 03:01:05 +0000 | [diff] [blame] | 1033 | // se_freeze_test compares the plat sepolicy with the prebuilt sepolicy |
| 1034 | // Additional directories can be specified via Makefile variables: |
| 1035 | // SEPOLICY_FREEZE_TEST_EXTRA_DIRS and SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS. |
| 1036 | ////////////////////////////////// |
| 1037 | se_freeze_test { |
| 1038 | name: "sepolicy_freeze_test", |
| 1039 | } |
Inseob Kim | 61257ca | 2022-02-25 11:26:16 +0900 | [diff] [blame] | 1040 | |
| 1041 | ////////////////////////////////// |
| 1042 | // sepolicy_test checks various types of violations, which can't be easily done |
| 1043 | // by CIL itself. Refer tests/sepolicy_tests.py for more detail. |
| 1044 | ////////////////////////////////// |
| 1045 | genrule { |
| 1046 | name: "sepolicy_test", |
| 1047 | srcs: [ |
| 1048 | ":plat_file_contexts", |
| 1049 | ":vendor_file_contexts", |
| 1050 | ":system_ext_file_contexts", |
| 1051 | ":product_file_contexts", |
| 1052 | ":odm_file_contexts", |
| 1053 | ":precompiled_sepolicy", |
| 1054 | ], |
| 1055 | tools: ["sepolicy_tests"], |
| 1056 | out: ["sepolicy_test"], |
| 1057 | cmd: "$(location sepolicy_tests) " + |
| 1058 | "-f $(location :plat_file_contexts) " + |
| 1059 | "-f $(location :vendor_file_contexts) " + |
| 1060 | "-f $(location :system_ext_file_contexts) " + |
| 1061 | "-f $(location :product_file_contexts) " + |
| 1062 | "-f $(location :odm_file_contexts) " + |
| 1063 | "-p $(location :precompiled_sepolicy) && " + |
| 1064 | "touch $(out)", |
| 1065 | } |