From 779b64ec5d4098133a3f87520ed53daae1c46f6a Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov Date: Fri, 9 Apr 2021 14:33:10 -0700 Subject: [PATCH] Fix evaluation order of (Cfi|Memtag) exclude paths. Before this change, exclude paths disabled sanitization of targets that would otherwise be enabled by SanitizeDevice product variable (aka SANITIZE_TARGET). With this change, in addition to the above logic, exclude path disables sanitization of targets that would otherwise be enabled by the corresponding include path. Effectively, this change disables sanitization of targets that are covered by *both* include and exclude paths. Test: build/soong/cc/cc_test.go Bug: b/184976817 Change-Id: I96f1e2a808d88b352b92b7490fa1df5c010314c3 --- android/config.go | 6 +++--- cc/cc_test.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/config.go b/android/config.go index 80651bbdf..d003410ef 100644 --- a/android/config.go +++ b/android/config.go @@ -1259,7 +1259,7 @@ func (c *config) CFIEnabledForPath(path string) bool { if len(c.productVariables.CFIIncludePaths) == 0 { return false } - return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) + return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) && !c.CFIDisabledForPath(path) } func (c *config) MemtagHeapDisabledForPath(path string) bool { @@ -1273,14 +1273,14 @@ func (c *config) MemtagHeapAsyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapAsyncIncludePaths) == 0 { return false } - return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) + return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) && !c.MemtagHeapDisabledForPath(path) } func (c *config) MemtagHeapSyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapSyncIncludePaths) == 0 { return false } - return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) + return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) && !c.MemtagHeapDisabledForPath(path) } func (c *config) VendorConfig(name string) VendorConfig { diff --git a/cc/cc_test.go b/cc/cc_test.go index e4dfc97ad..07dcc951f 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -3921,8 +3921,9 @@ var prepareForTestWithMemtagHeap = android.GroupFixturePreparers( }), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.MemtagHeapExcludePaths = []string{"subdir_exclude"} - variables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} - variables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} + // "subdir_exclude" is covered by both include and exclude paths. Exclude wins. + variables.MemtagHeapSyncIncludePaths = []string{"subdir_sync", "subdir_exclude"} + variables.MemtagHeapAsyncIncludePaths = []string{"subdir_async", "subdir_exclude"} }), )