Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 1 | LOCAL_PATH:= $(call my-dir) |
William Roberts | f0e0a94 | 2012-08-27 15:41:15 -0700 | [diff] [blame] | 2 | |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 3 | include $(CLEAR_VARS) |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 4 | |
Stephen Smalley | 8e0ca88 | 2015-04-01 10:14:56 -0400 | [diff] [blame] | 5 | ifdef BOARD_SEPOLICY_UNION |
| 6 | $(warning BOARD_SEPOLICY_UNION is no longer required - all files found in BOARD_SEPOLICY_DIRS are implicitly unioned; please remove from your BoardConfig.mk or other .mk file.) |
| 7 | endif |
Robert Craig | 6b0ff47 | 2014-01-29 13:10:58 -0500 | [diff] [blame] | 8 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 9 | # sepolicy is now divided into multiple portions: |
| 10 | # public - policy exported on which non-platform policy developers may write |
| 11 | # additional policy. types and attributes are versioned and included in |
| 12 | # delivered non-platform policy, which is to be combined with platform policy. |
| 13 | # private - platform-only policy required for platform functionality but which |
| 14 | # is not exported to vendor policy developers and as such may not be assumed |
| 15 | # to exist. |
Alex Klyubin | 5596172 | 2017-01-30 18:44:59 -0800 | [diff] [blame] | 16 | # vendor - vendor-only policy required for vendor functionality. This policy can |
| 17 | # reference the public policy but cannot reference the private policy. This |
| 18 | # policy is for components which are produced from the core/non-vendor tree and |
| 19 | # placed into a vendor partition. |
dcashman | 0779155 | 2016-12-07 11:27:47 -0800 | [diff] [blame] | 20 | # mapping - This contains policy statements which map the attributes |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 21 | # exposed in the public policy of previous versions to the concrete types used |
| 22 | # in this policy to ensure that policy targeting attributes from public |
| 23 | # policy from an older platform version continues to work. |
| 24 | |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 25 | # build process for device: |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 26 | # 1) convert policies to CIL: |
| 27 | # - private + public platform policy to CIL |
| 28 | # - mapping file to CIL (should already be in CIL form) |
| 29 | # - non-platform public policy to CIL |
| 30 | # - non-platform public + private policy to CIL |
| 31 | # 2) attributize policy |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 32 | # - run script which takes non-platform public and non-platform combined |
| 33 | # private + public policy and produces attributized and versioned |
| 34 | # non-platform policy |
| 35 | # 3) combine policy files |
| 36 | # - combine mapping, platform and non-platform policy. |
| 37 | # - compile output binary policy file |
| 38 | |
| 39 | PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public |
| 40 | PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private |
Alex Klyubin | 5596172 | 2017-01-30 18:44:59 -0800 | [diff] [blame] | 41 | PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 42 | REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask |
Felix | 8c53a33 | 2020-07-14 21:28:51 +0200 | [diff] [blame] | 43 | |
| 44 | SYSTEM_EXT_PUBLIC_POLICY := $(SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS) |
Felix | 8c53a33 | 2020-07-14 21:28:51 +0200 | [diff] [blame] | 45 | SYSTEM_EXT_PRIVATE_POLICY := $(SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS) |
Felix | 8c53a33 | 2020-07-14 21:28:51 +0200 | [diff] [blame] | 46 | |
Tri Vo | 9918f28 | 2019-02-01 11:41:08 -0800 | [diff] [blame] | 47 | PRODUCT_PUBLIC_POLICY := $(PRODUCT_PUBLIC_SEPOLICY_DIRS) |
| 48 | PRODUCT_PRIVATE_POLICY := $(PRODUCT_PRIVATE_SEPOLICY_DIRS) |
Tri Vo | 75887dd | 2018-12-14 14:30:56 -0800 | [diff] [blame] | 49 | |
Bowgo Tsai | 948934b | 2019-08-29 17:12:11 +0800 | [diff] [blame] | 50 | ifneq (,$(SYSTEM_EXT_PUBLIC_POLICY)$(SYSTEM_EXT_PRIVATE_POLICY)) |
Bowgo Tsai | ac38125 | 2019-10-04 14:34:18 +0800 | [diff] [blame] | 51 | HAS_SYSTEM_EXT_SEPOLICY_DIR := true |
Bowgo Tsai | 948934b | 2019-08-29 17:12:11 +0800 | [diff] [blame] | 52 | endif |
| 53 | |
Tri Vo | 75887dd | 2018-12-14 14:30:56 -0800 | [diff] [blame] | 54 | # TODO(b/119305624): Currently if the device doesn't have a product partition, |
| 55 | # we install product sepolicy into /system/product. We do that because bits of |
| 56 | # product sepolicy that's still in /system might depend on bits that have moved |
| 57 | # to /product. Once we finish migrating product sepolicy out of system, change |
| 58 | # it so that if no product partition is present, product sepolicy artifacts are |
| 59 | # not built and installed at all. |
| 60 | ifneq (,$(PRODUCT_PUBLIC_POLICY)$(PRODUCT_PRIVATE_POLICY)) |
Bowgo Tsai | 7c4150c | 2019-10-04 15:36:05 +0800 | [diff] [blame] | 61 | HAS_PRODUCT_SEPOLICY_DIR := true |
Tri Vo | 75887dd | 2018-12-14 14:30:56 -0800 | [diff] [blame] | 62 | endif |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 63 | |
Joel Galenson | 5988b56 | 2018-01-03 16:53:24 -0800 | [diff] [blame] | 64 | ifeq ($(SELINUX_IGNORE_NEVERALLOWS),true) |
| 65 | ifeq ($(TARGET_BUILD_VARIANT),user) |
| 66 | $(error SELINUX_IGNORE_NEVERALLOWS := true cannot be used in user builds) |
| 67 | endif |
| 68 | $(warning Be careful when using the SELINUX_IGNORE_NEVERALLOWS flag. \ |
| 69 | It does not work in user builds and using it will \ |
| 70 | not stop you from failing CTS.) |
Joel Galenson | 5988b56 | 2018-01-03 16:53:24 -0800 | [diff] [blame] | 71 | endif |
| 72 | |
Bowgo Tsai | 45457e3 | 2017-11-27 11:41:33 +0800 | [diff] [blame] | 73 | # BOARD_SEPOLICY_DIRS was used for vendor/odm sepolicy customization before. |
| 74 | # It has been replaced by BOARD_VENDOR_SEPOLICY_DIRS (mandatory) and |
| 75 | # BOARD_ODM_SEPOLICY_DIRS (optional). BOARD_SEPOLICY_DIRS is still allowed for |
| 76 | # backward compatibility, which will be merged into BOARD_VENDOR_SEPOLICY_DIRS. |
Bowgo Tsai | afbcf21 | 2018-02-05 17:34:52 +0800 | [diff] [blame] | 77 | ifdef BOARD_SEPOLICY_DIRS |
| 78 | BOARD_VENDOR_SEPOLICY_DIRS += $(BOARD_SEPOLICY_DIRS) |
| 79 | endif |
Dan Cashman | 4d24a77 | 2017-04-12 14:28:34 -0700 | [diff] [blame] | 80 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 81 | ########################################################### |
| 82 | # Compute policy files to be used in policy build. |
| 83 | # $(1): files to include |
| 84 | # $(2): directories in which to find files |
| 85 | ########################################################### |
| 86 | |
| 87 | define build_policy |
Cole Faust | 087d527 | 2021-09-30 15:48:34 -0700 | [diff] [blame] | 88 | $(strip $(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))) |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 89 | endef |
William Roberts | 29d1468 | 2016-01-04 12:20:57 -0800 | [diff] [blame] | 90 | |
dcashman | 704741a | 2014-07-25 19:11:52 -0700 | [diff] [blame] | 91 | sepolicy_build_files := security_classes \ |
| 92 | initial_sids \ |
| 93 | access_vectors \ |
| 94 | global_macros \ |
Nick Kralevich | a17a266 | 2014-11-05 15:30:41 -0800 | [diff] [blame] | 95 | neverallow_macros \ |
dcashman | 704741a | 2014-07-25 19:11:52 -0700 | [diff] [blame] | 96 | mls_macros \ |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 97 | mls_decl \ |
dcashman | 704741a | 2014-07-25 19:11:52 -0700 | [diff] [blame] | 98 | mls \ |
| 99 | policy_capabilities \ |
| 100 | te_macros \ |
| 101 | attributes \ |
Jeff Vander Stoep | cbaa2b7 | 2015-12-22 10:39:34 -0800 | [diff] [blame] | 102 | ioctl_defines \ |
Jeff Vander Stoep | de9b530 | 2015-06-05 15:28:55 -0700 | [diff] [blame] | 103 | ioctl_macros \ |
dcashman | 704741a | 2014-07-25 19:11:52 -0700 | [diff] [blame] | 104 | *.te \ |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 105 | roles_decl \ |
dcashman | 704741a | 2014-07-25 19:11:52 -0700 | [diff] [blame] | 106 | roles \ |
| 107 | users \ |
| 108 | initial_sid_contexts \ |
| 109 | fs_use \ |
| 110 | genfs_contexts \ |
| 111 | port_contexts |
| 112 | |
Chris Gross | 12c0b24 | 2020-09-21 15:32:16 -0700 | [diff] [blame] | 113 | sepolicy_compat_files := $(foreach ver, $(PLATFORM_SEPOLICY_COMPAT_VERSIONS), \ |
| 114 | $(addprefix compat/$(ver)/, $(addsuffix .cil, $(ver)))) |
| 115 | |
Tri Vo | 71f1239 | 2019-10-07 16:31:40 -0700 | [diff] [blame] | 116 | # Security classes and permissions defined outside of system/sepolicy. |
| 117 | security_class_extension_files := $(call build_policy, security_classes access_vectors, \ |
| 118 | $(SYSTEM_EXT_PUBLIC_POLICY) $(SYSTEM_EXT_PRIVATE_POLICY) \ |
| 119 | $(PRODUCT_PUBLIC_POLICY) $(PRODUCT_PRIVATE_POLICY) \ |
| 120 | $(BOARD_VENDOR_SEPOLICY_DIRS) $(BOARD_ODM_SEPOLICY_DIRS)) |
| 121 | |
| 122 | ifneq (,$(strip $(security_class_extension_files))) |
| 123 | $(error Only platform SELinux policy may define classes and permissions: $(strip $(security_class_extension_files))) |
| 124 | endif |
| 125 | |
Bowgo Tsai | ac38125 | 2019-10-04 14:34:18 +0800 | [diff] [blame] | 126 | ifdef HAS_SYSTEM_EXT_SEPOLICY_DIR |
| 127 | # Checks if there are public system_ext policy files. |
| 128 | policy_files := $(call build_policy, $(sepolicy_build_files), $(SYSTEM_EXT_PUBLIC_POLICY)) |
| 129 | ifneq (,$(strip $(policy_files))) |
| 130 | HAS_SYSTEM_EXT_PUBLIC_SEPOLICY := true |
| 131 | endif |
| 132 | # Checks if there are public/private system_ext policy files. |
| 133 | policy_files := $(call build_policy, $(sepolicy_build_files), $(SYSTEM_EXT_PUBLIC_POLICY) $(SYSTEM_EXT_PRIVATE_POLICY)) |
| 134 | ifneq (,$(strip $(policy_files))) |
| 135 | HAS_SYSTEM_EXT_SEPOLICY := true |
| 136 | endif |
| 137 | endif # ifdef HAS_SYSTEM_EXT_SEPOLICY_DIR |
| 138 | |
Bowgo Tsai | 7c4150c | 2019-10-04 15:36:05 +0800 | [diff] [blame] | 139 | ifdef HAS_PRODUCT_SEPOLICY_DIR |
| 140 | # Checks if there are public product policy files. |
| 141 | policy_files := $(call build_policy, $(sepolicy_build_files), $(PRODUCT_PUBLIC_POLICY)) |
| 142 | ifneq (,$(strip $(policy_files))) |
| 143 | HAS_PRODUCT_PUBLIC_SEPOLICY := true |
| 144 | endif |
| 145 | # Checks if there are public/private product policy files. |
| 146 | policy_files := $(call build_policy, $(sepolicy_build_files), $(PRODUCT_PUBLIC_POLICY) $(PRODUCT_PRIVATE_POLICY)) |
| 147 | ifneq (,$(strip $(policy_files))) |
| 148 | HAS_PRODUCT_SEPOLICY := true |
| 149 | endif |
| 150 | endif # ifdef HAS_PRODUCT_SEPOLICY_DIR |
| 151 | |
Jeff Vander Stoep | 7443484 | 2017-03-13 12:22:15 -0700 | [diff] [blame] | 152 | with_asan := false |
| 153 | ifneq (,$(filter address,$(SANITIZE_TARGET))) |
| 154 | with_asan := true |
| 155 | endif |
| 156 | |
Inseob Kim | d7b381c | 2023-08-23 02:07:40 +0000 | [diff] [blame] | 157 | ifeq ($(PRODUCT_SHIPPING_API_LEVEL),) |
| 158 | #$(warning no product shipping level defined) |
| 159 | else ifneq ($(call math_lt,29,$(PRODUCT_SHIPPING_API_LEVEL)),) |
| 160 | ifneq ($(BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW),) |
| 161 | $(error BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW cannot be set on a device shipping with R or later, and this is tested by CTS.) |
| 162 | endif |
| 163 | endif |
| 164 | |
Inseob Kim | d7b381c | 2023-08-23 02:07:40 +0000 | [diff] [blame] | 165 | ifeq ($(PRODUCT_SHIPPING_API_LEVEL),) |
Inseob Kim | afc0993 | 2020-09-28 13:32:43 +0900 | [diff] [blame] | 166 | #$(warning no product shipping level defined) |
Inseob Kim | d7b381c | 2023-08-23 02:07:40 +0000 | [diff] [blame] | 167 | else ifneq ($(call math_lt,30,$(PRODUCT_SHIPPING_API_LEVEL)),) |
| 168 | ifneq ($(BUILD_BROKEN_ENFORCE_SYSPROP_OWNER),) |
Inseob Kim | afc0993 | 2020-09-28 13:32:43 +0900 | [diff] [blame] | 169 | $(error BUILD_BROKEN_ENFORCE_SYSPROP_OWNER cannot be set on a device shipping with S or later, and this is tested by CTS.) |
| 170 | endif |
| 171 | endif |
| 172 | |
Jeff Vander Stoep | 1fc0682 | 2017-05-31 15:36:07 -0700 | [diff] [blame] | 173 | ################################# |
Tri Vo | 81198bb | 2018-03-15 11:38:08 -0700 | [diff] [blame] | 174 | |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 175 | |
Dan Cashman | 1c04027 | 2016-12-15 15:28:44 -0800 | [diff] [blame] | 176 | build_policy := |
Dan Cashman | 1c04027 | 2016-12-15 15:28:44 -0800 | [diff] [blame] | 177 | sepolicy_build_files := |
Jeff Vander Stoep | 7443484 | 2017-03-13 12:22:15 -0700 | [diff] [blame] | 178 | with_asan := |