treble_sepolicy_tests_for_release.mk 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. version := $(version_under_treble_tests)
  2. include $(CLEAR_VARS)
  3. # For Treble builds run tests verifying that processes are properly labeled and
  4. # permissions granted do not violate the treble model. Also ensure that treble
  5. # compatibility guarantees are upheld between SELinux version bumps.
  6. LOCAL_MODULE := treble_sepolicy_tests_$(version)
  7. LOCAL_MODULE_CLASS := ETC
  8. LOCAL_MODULE_TAGS := tests
  9. include $(BUILD_SYSTEM)/base_rules.mk
  10. # $(version)_plat - the platform policy shipped as part of the $(version) release. This is
  11. # built to enable us to determine the diff between the current policy and the
  12. # $(version) policy, which will be used in tests to make sure that compatibility has
  13. # been maintained by our mapping files.
  14. $(version)_PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/prebuilts/api/$(version)/public
  15. $(version)_PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/prebuilts/api/$(version)/private
  16. $(version)_plat_policy.conf := $(intermediates)/$(version)_plat_policy.conf
  17. $($(version)_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
  18. $($(version)_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
  19. $($(version)_plat_policy.conf): PRIVATE_TARGET_BUILD_VARIANT := user
  20. $($(version)_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
  21. $($(version)_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
  22. $($(version)_plat_policy.conf): PRIVATE_TGT_WITH_NATIVE_COVERAGE := $(with_native_coverage)
  23. $($(version)_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
  24. $($(version)_plat_policy.conf): PRIVATE_SEPOLICY_SPLIT := true
  25. $($(version)_plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
  26. $($(version)_PLAT_PUBLIC_POLICY) $($(version)_PLAT_PRIVATE_POLICY))
  27. $(transform-policy-to-conf)
  28. $(hide) sed '/dontaudit/d' $@ > [email protected]
  29. built_$(version)_plat_sepolicy := $(intermediates)/built_$(version)_plat_sepolicy
  30. $(built_$(version)_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \
  31. $(call build_policy, technical_debt.cil , $($(version)_PLAT_PRIVATE_POLICY))
  32. $(built_$(version)_plat_sepolicy): PRIVATE_NEVERALLOW_ARG := $(NEVERALLOW_ARG)
  33. $(built_$(version)_plat_sepolicy): $($(version)_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
  34. $(HOST_OUT_EXECUTABLES)/secilc \
  35. $(call build_policy, technical_debt.cil, $($(version)_PLAT_PRIVATE_POLICY)) \
  36. $(built_sepolicy_neverallows)
  37. @mkdir -p $(dir $@)
  38. $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
  39. $(POLICYVERS) -o $@ $<
  40. $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
  41. $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) $(PRIVATE_NEVERALLOW_ARG) $@ -o $@ -f /dev/null
  42. $(version)_plat_policy.conf :=
  43. # $(version)_compat - the current plat_sepolicy.cil built with the compatibility file
  44. # targeting the $(version) SELinux release. This ensures that our policy will build
  45. # when used on a device that has non-platform policy targetting the $(version) release.
  46. $(version)_compat := $(intermediates)/$(version)_compat
  47. $(version)_mapping.cil := $(call intermediates-dir-for,ETC,$(version).cil)/$(version).cil
  48. $(version)_mapping.ignore.cil := \
  49. $(call intermediates-dir-for,ETC,$(version).ignore.cil)/$(version).ignore.cil
  50. $(version)_prebuilts_dir := $(LOCAL_PATH)/prebuilts/api/$(version)
  51. # vendor_sepolicy.cil and plat_pub_versioned.cil are the new design to replace
  52. # nonplat_sepolicy.cil.
  53. $(version)_nonplat := $($(version)_prebuilts_dir)/vendor_sepolicy.cil \
  54. $($(version)_prebuilts_dir)/plat_pub_versioned.cil
  55. ifeq (,$(wildcard $($(version)_nonplat)))
  56. $(version)_nonplat := $($(version)_prebuilts_dir)/nonplat_sepolicy.cil
  57. endif
  58. $($(version)_compat): PRIVATE_CIL_FILES := \
  59. $(built_plat_cil) $($(version)_mapping.cil) $($(version)_nonplat)
  60. $($(version)_compat): $(HOST_OUT_EXECUTABLES)/secilc \
  61. $(built_plat_cil) $($(version)_mapping.cil) $($(version)_nonplat)
  62. $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -N -c $(POLICYVERS) \
  63. $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
  64. # $(version)_mapping.combined.cil - a combination of the mapping file used when
  65. # combining the current platform policy with nonplatform policy based on the
  66. # $(version) policy release and also a special ignored file that exists purely for
  67. # these tests.
  68. $(version)_mapping.combined.cil := $(intermediates)/$(version)_mapping.combined.cil
  69. $($(version)_mapping.combined.cil): $($(version)_mapping.cil) $($(version)_mapping.ignore.cil)
  70. mkdir -p $(dir $@)
  71. cat $^ > $@
  72. treble_sepolicy_tests_$(version) := $(intermediates)/treble_sepolicy_tests_$(version)
  73. $(treble_sepolicy_tests_$(version)): ALL_FC_ARGS := $(all_fc_args)
  74. $(treble_sepolicy_tests_$(version)): PRIVATE_SEPOLICY := $(built_sepolicy)
  75. $(treble_sepolicy_tests_$(version)): PRIVATE_SEPOLICY_OLD := $(built_$(version)_plat_sepolicy)
  76. $(treble_sepolicy_tests_$(version)): PRIVATE_COMBINED_MAPPING := $($(version)_mapping.combined.cil)
  77. $(treble_sepolicy_tests_$(version)): PRIVATE_PLAT_SEPOLICY := $(built_plat_sepolicy)
  78. $(treble_sepolicy_tests_$(version)): PRIVATE_PLAT_PUB_SEPOLICY := $(base_plat_pub_policy.cil)
  79. $(treble_sepolicy_tests_$(version)): PRIVATE_FAKE_TREBLE :=
  80. ifeq ($(PRODUCT_FULL_TREBLE_OVERRIDE),true)
  81. # TODO(b/113124961): account for PRODUCT_SHIPPING_API_LEVEL when determining
  82. # fake treble status once emulator is no longer fake treble.
  83. #ifdef PRODUCT_SHIPPING_API_LEVEL
  84. # These requirements were originally added in Android Oreo. Devices
  85. # launching after this should not distinguish between
  86. # PRODUCT_FULL_TREBLE and PRODUCT_FULL_TREBLE_OVERRIDE since this could
  87. # lead to release problems where they think they pass this test but
  88. # fail it when it actually gets runned for compliance.
  89. #ifeq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),26),)
  90. $(treble_sepolicy_tests_$(version)): PRIVATE_FAKE_TREBLE := --fake-treble
  91. #endif # if PRODUCT_SHIPPING_API_LEVEL < 26 (Android Oreo)
  92. #endif # PRODUCT_SHIPPING_API_LEVEL defined
  93. endif # PRODUCT_FULL_TREBLE_OVERRIDE = true
  94. $(treble_sepolicy_tests_$(version)): $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests \
  95. $(all_fc_files) $(built_sepolicy) $(built_plat_sepolicy) \
  96. $(base_plat_pub_policy.cil) \
  97. $(built_$(version)_plat_sepolicy) $($(version)_compat) $($(version)_mapping.combined.cil)
  98. @mkdir -p $(dir $@)
  99. $(hide) $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests -l \
  100. $(HOST_OUT)/lib64/libsepolwrap.$(SHAREDLIB_EXT) $(ALL_FC_ARGS) \
  101. -b $(PRIVATE_PLAT_SEPOLICY) -m $(PRIVATE_COMBINED_MAPPING) \
  102. -o $(PRIVATE_SEPOLICY_OLD) -p $(PRIVATE_SEPOLICY) \
  103. -u $(PRIVATE_PLAT_PUB_SEPOLICY) \
  104. $(PRIVATE_FAKE_TREBLE)
  105. $(hide) touch $@
  106. $(version)_PLAT_PUBLIC_POLICY :=
  107. $(version)_PLAT_PRIVATE_POLICY :=
  108. $(version)_compat :=
  109. $(version)_mapping.cil :=
  110. $(version)_mapping.combined.cil :=
  111. $(version)_mapping.ignore.cil :=
  112. $(version)_nonplat :=
  113. $(version)_prebuilts_dir :=
  114. built_$(version)_plat_sepolicy :=
  115. version :=
  116. version_under_treble_tests :=