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