Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 1 | version := $(version_under_treble_tests) |
| 2 | |
| 3 | include $(CLEAR_VARS) |
| 4 | # For Treble builds run tests verifying that processes are properly labeled and |
| 5 | # permissions granted do not violate the treble model. Also ensure that treble |
| 6 | # compatibility guarantees are upheld between SELinux version bumps. |
| 7 | LOCAL_MODULE := treble_sepolicy_tests_$(version) |
Bob Badour | 601ebb4 | 2021-02-03 23:07:40 -0800 | [diff] [blame] | 8 | LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 legacy_unencumbered |
| 9 | LOCAL_LICENSE_CONDITIONS := notice unencumbered |
| 10 | LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE |
Jooyung Han | 749cf93 | 2019-05-30 01:05:43 +0900 | [diff] [blame] | 11 | LOCAL_MODULE_CLASS := FAKE |
| 12 | LOCAL_MODULE_TAGS := optional |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 13 | |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 14 | # BOARD_SYSTEM_EXT_PREBUILT_DIR can be set as system_ext prebuilt dir in sepolicy |
| 15 | # make file of the system_ext partition. |
| 16 | SYSTEM_EXT_PREBUILT_POLICY := $(BOARD_SYSTEM_EXT_PREBUILT_DIR) |
| 17 | # BOARD_PRODUCT_PREBUILT_DIR can be set as product prebuilt dir in sepolicy |
| 18 | # make file of the product partition. |
| 19 | PRODUCT_PREBUILT_POLICY := $(BOARD_PRODUCT_PREBUILT_DIR) |
| 20 | # BOARD_PLAT_PUB_VERSIONED_POLICY - path_to_plat_pub_versioned_of_vendor |
| 21 | # plat_pub_versioned.cil should be in |
| 22 | # $(BOARD_PLAT_PUB_VERSIONED_POLICY)/prebuilts/api/$(version) dir. |
| 23 | # plat_pub_versioned.cil should have platform, system_ext and product sepolicies |
| 24 | # similar to system/sepolicy/prebuilts/api/$(version/plat_pub_verioned.cil file. |
| 25 | # In order to enable treble sepolicy tests for platform, system_ext and product |
| 26 | # sepolicies SYSTEM_EXT_PREBUILT_POLICY , PRODUCT_PREBUILT_POLICY and |
| 27 | # BOARD_PLAT_PUB_VERSIONED_POLICY should be set. |
| 28 | IS_TREBLE_TEST_ENABLED_PARTNER := false |
| 29 | ifeq ($(filter 26.0 27.0 28.0 29.0,$(version)),) |
| 30 | ifneq (,$(BOARD_PLAT_PUB_VERSIONED_POLICY)) |
| 31 | IS_TREBLE_TEST_ENABLED_PARTNER := true |
| 32 | endif # (,$(BOARD_PLAT_PUB_VERSIONED_POLICY)) |
| 33 | endif # ($(filter 26.0 27.0 28.0 29.0,$(version)),) |
| 34 | |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 35 | include $(BUILD_SYSTEM)/base_rules.mk |
| 36 | |
| 37 | # $(version)_plat - the platform policy shipped as part of the $(version) release. This is |
| 38 | # built to enable us to determine the diff between the current policy and the |
| 39 | # $(version) policy, which will be used in tests to make sure that compatibility has |
| 40 | # been maintained by our mapping files. |
| 41 | $(version)_PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/prebuilts/api/$(version)/public |
| 42 | $(version)_PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/prebuilts/api/$(version)/private |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 43 | ifeq ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
| 44 | ifneq (,$(SYSTEM_EXT_PREBUILT_POLICY)) |
| 45 | $(version)_PLAT_PUBLIC_POLICY += \ |
| 46 | $(SYSTEM_EXT_PREBUILT_POLICY)/prebuilts/api/$(version)/public |
| 47 | $(version)_PLAT_PRIVATE_POLICY += \ |
| 48 | $(SYSTEM_EXT_PREBUILT_POLICY)/prebuilts/api/$(version)/private |
| 49 | endif # (,$(SYSTEM_EXT_PREBUILT_POLICY)) |
| 50 | ifneq (,$(PRODUCT_PREBUILT_POLICY)) |
| 51 | $(version)_PLAT_PUBLIC_POLICY += \ |
| 52 | $(PRODUCT_PREBUILT_POLICY)/prebuilts/api/$(version)/public |
| 53 | $(version)_PLAT_PRIVATE_POLICY += \ |
| 54 | $(PRODUCT_PREBUILT_POLICY)/prebuilts/api/$(version)/private |
| 55 | endif # (,$(PRODUCT_PREBUILT_POLICY)) |
| 56 | endif # ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
Dan Willemsen | 3c3e59b | 2019-06-19 10:52:50 -0700 | [diff] [blame] | 57 | policy_files := $(call build_policy, $(sepolicy_build_files), $($(version)_PLAT_PUBLIC_POLICY) $($(version)_PLAT_PRIVATE_POLICY)) |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 58 | $(version)_plat_policy.conf := $(intermediates)/$(version)_plat_policy.conf |
| 59 | $($(version)_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS) |
| 60 | $($(version)_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS) |
Joel Galenson | c148621 | 2018-03-23 12:40:26 -0700 | [diff] [blame] | 61 | $($(version)_plat_policy.conf): PRIVATE_TARGET_BUILD_VARIANT := user |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 62 | $($(version)_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch) |
| 63 | $($(version)_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan) |
Pirama Arumuga Nainar | ce9c0c5 | 2019-06-13 15:05:15 -0700 | [diff] [blame] | 64 | $($(version)_plat_policy.conf): PRIVATE_TGT_WITH_NATIVE_COVERAGE := $(with_native_coverage) |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 65 | $($(version)_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS) |
| 66 | $($(version)_plat_policy.conf): PRIVATE_SEPOLICY_SPLIT := true |
Dan Willemsen | 3c3e59b | 2019-06-19 10:52:50 -0700 | [diff] [blame] | 67 | $($(version)_plat_policy.conf): PRIVATE_POLICY_FILES := $(policy_files) |
| 68 | $($(version)_plat_policy.conf): $(policy_files) $(M4) |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 69 | $(transform-policy-to-conf) |
| 70 | $(hide) sed '/dontaudit/d' $@ > $@.dontaudit |
| 71 | |
Dan Willemsen | 3c3e59b | 2019-06-19 10:52:50 -0700 | [diff] [blame] | 72 | policy_files := |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 73 | |
| 74 | built_$(version)_plat_sepolicy := $(intermediates)/built_$(version)_plat_sepolicy |
| 75 | $(built_$(version)_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \ |
| 76 | $(call build_policy, technical_debt.cil , $($(version)_PLAT_PRIVATE_POLICY)) |
| 77 | $(built_$(version)_plat_sepolicy): PRIVATE_NEVERALLOW_ARG := $(NEVERALLOW_ARG) |
| 78 | $(built_$(version)_plat_sepolicy): $($(version)_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \ |
| 79 | $(HOST_OUT_EXECUTABLES)/secilc \ |
| 80 | $(call build_policy, technical_debt.cil, $($(version)_PLAT_PRIVATE_POLICY)) \ |
| 81 | $(built_sepolicy_neverallows) |
| 82 | @mkdir -p $(dir $@) |
| 83 | $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \ |
| 84 | $(POLICYVERS) -o $@ $< |
| 85 | $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@ |
| 86 | $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) $(PRIVATE_NEVERALLOW_ARG) $@ -o $@ -f /dev/null |
| 87 | |
| 88 | $(version)_plat_policy.conf := |
| 89 | |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 90 | # $(version)_compat - the current plat_sepolicy.cil built with the compatibility file |
| 91 | # targeting the $(version) SELinux release. This ensures that our policy will build |
| 92 | # when used on a device that has non-platform policy targetting the $(version) release. |
| 93 | $(version)_compat := $(intermediates)/$(version)_compat |
Tri Vo | 6117855 | 2019-10-10 16:29:40 -0700 | [diff] [blame] | 94 | $(version)_mapping.cil := $(call intermediates-dir-for,ETC,plat_$(version).cil)/plat_$(version).cil |
Tri Vo | 438684b | 2018-09-29 17:47:10 -0700 | [diff] [blame] | 95 | $(version)_mapping.ignore.cil := \ |
| 96 | $(call intermediates-dir-for,ETC,$(version).ignore.cil)/$(version).ignore.cil |
Jae Shin | 1fa9634 | 2018-07-11 18:30:44 +0900 | [diff] [blame] | 97 | $(version)_prebuilts_dir := $(LOCAL_PATH)/prebuilts/api/$(version) |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 98 | ifeq ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
| 99 | ifneq (,$(SYSTEM_EXT_PREBUILT_POLICY)) |
| 100 | $(version)_mapping.cil += \ |
| 101 | $(call intermediates-dir-for,ETC,system_ext_$(version).cil)/system_ext_$(version).cil |
| 102 | $(version)_mapping.ignore.cil += \ |
| 103 | $(call intermediates-dir-for,ETC,system_ext_$(version).ignore.cil)/system_ext_$(version).ignore.cil |
| 104 | endif # (,$(SYSTEM_EXT_PREBUILT_POLICY)) |
| 105 | ifneq (,$(PRODUCT_PREBUILT_POLICY)) |
| 106 | $(version)_mapping.cil += \ |
| 107 | $(call intermediates-dir-for,ETC,product_$(version).cil)/product_$(version).cil |
| 108 | $(version)_mapping.ignore.cil += \ |
| 109 | $(call intermediates-dir-for,ETC,product_$(version).ignore.cil)/product_$(version).ignore.cil |
| 110 | endif # (,$(PRODUCT_PREBUILT_POLICY)) |
| 111 | $(version)_prebuilts_dir := $(BOARD_PLAT_PUB_VERSIONED_POLICY)/prebuilts/api/$(version) |
| 112 | endif #($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
Jae Shin | 1fa9634 | 2018-07-11 18:30:44 +0900 | [diff] [blame] | 113 | |
| 114 | # vendor_sepolicy.cil and plat_pub_versioned.cil are the new design to replace |
| 115 | # nonplat_sepolicy.cil. |
| 116 | $(version)_nonplat := $($(version)_prebuilts_dir)/vendor_sepolicy.cil \ |
| 117 | $($(version)_prebuilts_dir)/plat_pub_versioned.cil |
| 118 | ifeq (,$(wildcard $($(version)_nonplat))) |
| 119 | $(version)_nonplat := $($(version)_prebuilts_dir)/nonplat_sepolicy.cil |
| 120 | endif |
| 121 | |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 122 | cil_files := $(built_plat_cil) |
| 123 | ifeq ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
| 124 | ifneq (,$(SYSTEM_EXT_PREBUILT_POLICY) |
| 125 | cil_files += $(built_system_ext_cil) |
| 126 | endif # (,$(SYSTEM_EXT_PREBUILT_POLICY) |
| 127 | ifneq (,$(PRODUCT_PREBUILT_POLICY) |
| 128 | cil_files += $(built_product_cil) |
| 129 | endif # (,$(PRODUCT_PREBUILT_POLICY) |
| 130 | endif # ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
| 131 | cil_files += $($(version)_mapping.cil) $($(version)_nonplat) |
| 132 | $($(version)_compat): PRIVATE_CIL_FILES := $(cil_files) |
| 133 | $($(version)_compat): $(HOST_OUT_EXECUTABLES)/secilc $(cil_files) |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 134 | $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -N -c $(POLICYVERS) \ |
| 135 | $(PRIVATE_CIL_FILES) -o $@ -f /dev/null |
| 136 | |
| 137 | # $(version)_mapping.combined.cil - a combination of the mapping file used when |
| 138 | # combining the current platform policy with nonplatform policy based on the |
| 139 | # $(version) policy release and also a special ignored file that exists purely for |
| 140 | # these tests. |
| 141 | $(version)_mapping.combined.cil := $(intermediates)/$(version)_mapping.combined.cil |
| 142 | $($(version)_mapping.combined.cil): $($(version)_mapping.cil) $($(version)_mapping.ignore.cil) |
| 143 | mkdir -p $(dir $@) |
| 144 | cat $^ > $@ |
| 145 | |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 146 | ifeq ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
| 147 | built_sepolicy_files := $(built_product_sepolicy) |
| 148 | public_cil_files := $(base_product_pub_policy.cil) |
| 149 | else |
| 150 | built_sepolicy_files := $(built_plat_sepolicy) |
| 151 | public_cil_files := $(base_plat_pub_policy.cil) |
| 152 | endif # ($(IS_TREBLE_TEST_ENABLED_PARTNER),true) |
Jooyung Han | 749cf93 | 2019-05-30 01:05:43 +0900 | [diff] [blame] | 153 | $(LOCAL_BUILT_MODULE): ALL_FC_ARGS := $(all_fc_args) |
| 154 | $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy) |
| 155 | $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY_OLD := $(built_$(version)_plat_sepolicy) |
| 156 | $(LOCAL_BUILT_MODULE): PRIVATE_COMBINED_MAPPING := $($(version)_mapping.combined.cil) |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 157 | $(LOCAL_BUILT_MODULE): PRIVATE_PLAT_SEPOLICY := $(built_sepolicy_files) |
| 158 | $(LOCAL_BUILT_MODULE): PRIVATE_PLAT_PUB_SEPOLICY := $(public_cil_files) |
Jooyung Han | 749cf93 | 2019-05-30 01:05:43 +0900 | [diff] [blame] | 159 | $(LOCAL_BUILT_MODULE): PRIVATE_FAKE_TREBLE := |
Steven Moreland | c7670e5 | 2018-09-07 16:01:38 -0700 | [diff] [blame] | 160 | ifeq ($(PRODUCT_FULL_TREBLE_OVERRIDE),true) |
Steven Moreland | 1cb64c4 | 2019-09-20 11:16:29 -0700 | [diff] [blame] | 161 | # TODO(b/113124961): remove fake-treble |
Jooyung Han | 749cf93 | 2019-05-30 01:05:43 +0900 | [diff] [blame] | 162 | $(LOCAL_BUILT_MODULE): PRIVATE_FAKE_TREBLE := --fake-treble |
Steven Moreland | c7670e5 | 2018-09-07 16:01:38 -0700 | [diff] [blame] | 163 | endif # PRODUCT_FULL_TREBLE_OVERRIDE = true |
Jooyung Han | 749cf93 | 2019-05-30 01:05:43 +0900 | [diff] [blame] | 164 | $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests \ |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 165 | $(all_fc_files) $(built_sepolicy) \ |
| 166 | $(built_sepolicy_files) \ |
| 167 | $(public_cil_files) \ |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 168 | $(built_$(version)_plat_sepolicy) $($(version)_compat) $($(version)_mapping.combined.cil) |
| 169 | @mkdir -p $(dir $@) |
| 170 | $(hide) $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests -l \ |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 171 | $(HOST_OUT)/lib64/libsepolwrap.$(SHAREDLIB_EXT) $(ALL_FC_ARGS) \ |
| 172 | -b $(PRIVATE_PLAT_SEPOLICY) -m $(PRIVATE_COMBINED_MAPPING) \ |
| 173 | -o $(PRIVATE_SEPOLICY_OLD) -p $(PRIVATE_SEPOLICY) \ |
| 174 | -u $(PRIVATE_PLAT_PUB_SEPOLICY) \ |
| 175 | $(PRIVATE_FAKE_TREBLE) |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 176 | $(hide) touch $@ |
| 177 | |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 178 | $(version)_SYSTEM_EXT_PUBLIC_POLICY := |
| 179 | $(version)_SYSTEM_EXT_PRIVATE_POLICY := |
| 180 | $(version)_PRODUCT_PUBLIC_POLICY := |
| 181 | $(version)_PRODUCT_PRIVATE_POLICY := |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 182 | $(version)_PLAT_PUBLIC_POLICY := |
| 183 | $(version)_PLAT_PRIVATE_POLICY := |
P.Adarsh Reddy | cd05d74 | 2021-03-22 15:55:09 +0530 | [diff] [blame] | 184 | built_sepolicy_files := |
| 185 | public_cil_files := |
| 186 | cil_files := |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 187 | $(version)_compat := |
| 188 | $(version)_mapping.cil := |
| 189 | $(version)_mapping.combined.cil := |
| 190 | $(version)_mapping.ignore.cil := |
| 191 | $(version)_nonplat := |
Jae Shin | 1fa9634 | 2018-07-11 18:30:44 +0900 | [diff] [blame] | 192 | $(version)_prebuilts_dir := |
Tri Vo | 1406926 | 2018-01-31 16:22:35 -0800 | [diff] [blame] | 193 | built_$(version)_plat_sepolicy := |
| 194 | version := |
| 195 | version_under_treble_tests := |