From b0990300e98158e39aeb8cbe9c91bbea30b72fc4 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 18 Oct 2023 22:50:26 +0000 Subject: [PATCH] Revert^2 "Enable genrule sandboxing by default" 50cd6b2a18e16e3bd45ed87e690ea0e2afbc9f61 Change-Id: Ie0be9331481eb1e9b96034b155efb76a8be9596a --- Changes.md | 9 +++++++++ core/board_config.mk | 1 + core/soong_config.mk | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index 6c0cf7020e..fc15e601b6 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,14 @@ # Build System Changes for Android.mk/Android.bp Writers +## Soong genrules are now sandboxed + +Previously, soong genrules could access any files in the source tree, without specifying them as +inputs. This makes them incorrect in incremental builds, and incompatible with RBE and Bazel. + +Now, genrules are sandboxed so they can only access their listed srcs. Modules denylisted in +genrule/allowlists.go are exempt from this. You can also set `BUILD_BROKEN_GENRULE_SANDBOXING` +in board config to disable this behavior. + ## Partitions are no longer affected by previous builds Partition builds used to include everything in their staging directories, and building an diff --git a/core/board_config.mk b/core/board_config.mk index eb4c5ecfd1..a0e5d36dac 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -188,6 +188,7 @@ _build_broken_var_list := \ BUILD_BROKEN_VENDOR_PROPERTY_NAMESPACE \ BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES \ BUILD_BROKEN_INCORRECT_PARTITION_IMAGES \ + BUILD_BROKEN_GENRULE_SANDBOXING \ _build_broken_var_list += \ $(foreach m,$(AVAILABLE_BUILD_MODULE_TYPES) \ diff --git a/core/soong_config.mk b/core/soong_config.mk index e541c123df..5bf06dc4f4 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -15,6 +15,10 @@ endif # PRODUCT_AFDO_PROFILES takes precedence over product-agnostic profiles in AFDO_PROFILES ALL_AFDO_PROFILES := $(PRODUCT_AFDO_PROFILES) $(AFDO_PROFILES) +ifneq (,$(filter-out environment undefined,$(origin GENRULE_SANDBOXING))) + $(error GENRULE_SANDBOXING can only be provided via an environment variable, use BUILD_BROKEN_GENRULE_SANDBOXING to disable genrule sandboxing in board config) +endif + ifeq ($(WRITE_SOONG_VARIABLES),true) # Create soong.variables with copies of makefile settings. Runs every build, @@ -280,7 +284,8 @@ $(call add_json_list, BuildBrokenPluginValidation, $(BUILD_BROKEN_PLUGIN $(call add_json_bool, BuildBrokenClangProperty, $(filter true,$(BUILD_BROKEN_CLANG_PROPERTY))) $(call add_json_bool, BuildBrokenClangAsFlags, $(filter true,$(BUILD_BROKEN_CLANG_ASFLAGS))) $(call add_json_bool, BuildBrokenClangCFlags, $(filter true,$(BUILD_BROKEN_CLANG_CFLAGS))) -$(call add_json_bool, GenruleSandboxing, $(filter true,$(GENRULE_SANDBOXING))) +# Use the value of GENRULE_SANDBOXING if set, otherwise use the inverse of BUILD_BROKEN_GENRULE_SANDBOXING +$(call add_json_bool, GenruleSandboxing, $(if $(GENRULE_SANDBOXING),$(filter true,$(GENRULE_SANDBOXING)),$(if $(filter true,$(BUILD_BROKEN_GENRULE_SANDBOXING)),,true))) $(call add_json_bool, BuildBrokenEnforceSyspropOwner, $(filter true,$(BUILD_BROKEN_ENFORCE_SYSPROP_OWNER))) $(call add_json_bool, BuildBrokenTrebleSyspropNeverallow, $(filter true,$(BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW))) $(call add_json_bool, BuildBrokenUsesSoongPython2Modules, $(filter true,$(BUILD_BROKEN_USES_SOONG_PYTHON2_MODULES)))