From 8dcfdcebe92a06f3a68c7345c6bdc450f0d84277 Mon Sep 17 00:00:00 2001 From: Vishwath Mohan Date: Wed, 18 Jan 2017 17:50:29 -0800 Subject: [PATCH] Hide CFI behind a global flag. This CL ensures that the LOCAL_SANITIZE=cfi is not honored unless it is enabled globally using ENABLE_CFI='true' first. This allows CFI to be hidden behind a flag. Bug: 30227045 Bug: 22033465 Test: m -j40 works and device boots Test: cfi is correctly honored only when the global flag is set. Change-Id: If4508ba448bd4260020483f9c11ee849bb419713 --- core/config_sanitizers.mk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index 3a59ee3f9..c9883d4c8 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -3,6 +3,7 @@ ############################################## my_sanitize := $(strip $(LOCAL_SANITIZE)) +my_sanitize_diag := $(strip $(LOCAL_SANITIZE_DIAG)) # SANITIZE_HOST is only in effect if the module is already using clang (host # modules that haven't set `LOCAL_CLANG := false` and device modules that @@ -61,6 +62,12 @@ ifeq ($(LOCAL_SANITIZE),never) my_sanitize := endif +# If CFI is disabled globally, remove it from my_sanitize. +ifeq ($(strip $(ENABLE_CFI)),) + my_sanitize := $(filter-out cfi,$(my_sanitize)) + my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag)) +endif + my_nosanitize = $(strip $(LOCAL_NOSANITIZE)) ifneq ($(my_nosanitize),) my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize)) @@ -195,8 +202,8 @@ ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),) my_cflags += -fsanitize-recover=$(recover_arg) endif -ifneq ($(strip $(LOCAL_SANITIZE_DIAG)),) - notrap_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_DIAG)), +ifneq ($(my_sanitize_diag),) + notrap_arg := $(subst $(space),$(comma),$(my_sanitize_diag)), my_cflags += -fno-sanitize-trap=$(notrap_arg) # Diagnostic requires a runtime library, unless ASan or TSan are also enabled. ifeq ($(filter address thread,$(my_sanitize)),)