Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e235ded7 authored by Hang Lu's avatar Hang Lu
Browse files

Enable HWASan for multiple modules in one place(Make)

Environment variables HWASAN_INCLUDE_PATHS and
PRODUCT_HWASAN_INCLUDE_PATHS can be used to enable HWASan for multiple
modules, by just adding the module directory to the env variable.

Bug: b/271948407
Test: Set specific module directory to above env variable and check the
assembly codes of output elf files after building, finding hwasan
related symbols inside.

Change-Id: I4493cb627fb564ee317eb95bd24ec020d42ae28c
parent 0ab788ee
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -155,6 +155,17 @@ ifeq ($(filter memtag_heap, $(my_sanitize)),)
  endif
endif

# Enable HWASan in included paths.
ifeq ($(filter hwaddress, $(my_sanitize)),)
  combined_include_paths := $(HWASAN_INCLUDE_PATHS) \
                            $(PRODUCT_HWASAN_INCLUDE_PATHS)

  ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
         $(filter $(dir)%,$(LOCAL_PATH)))),)
    my_sanitize := hwaddress $(my_sanitize)
  endif
endif

# If CFI is disabled globally, remove it from my_sanitize.
ifeq ($(strip $(ENABLE_CFI)),false)
  my_sanitize := $(filter-out cfi,$(my_sanitize))
+3 −0
Original line number Diff line number Diff line
@@ -239,6 +239,9 @@ _product_list_vars += PRODUCT_CFI_INCLUDE_PATHS
# Whether any paths are excluded from sanitization when SANITIZE_TARGET=cfi
_product_list_vars += PRODUCT_CFI_EXCLUDE_PATHS

# Whether any paths should have HWASan enabled for components
_product_list_vars += PRODUCT_HWASAN_INCLUDE_PATHS

# Whether the Scudo hardened allocator is disabled platform-wide
_product_single_value_vars += PRODUCT_DISABLE_SCUDO

+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ $(call add_json_bool, EnableCFI, $(call invert_bool,$(fi
$(call add_json_list, CFIExcludePaths,                   $(CFI_EXCLUDE_PATHS) $(PRODUCT_CFI_EXCLUDE_PATHS))
$(call add_json_list, CFIIncludePaths,                   $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS))
$(call add_json_list, IntegerOverflowExcludePaths,       $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
$(call add_json_list, HWASanIncludePaths,                $(HWASAN_INCLUDE_PATHS) $(PRODUCT_HWASAN_INCLUDE_PATHS))

$(call add_json_list, MemtagHeapExcludePaths,            $(MEMTAG_HEAP_EXCLUDE_PATHS) $(PRODUCT_MEMTAG_HEAP_EXCLUDE_PATHS))
$(call add_json_list, MemtagHeapAsyncIncludePaths,       $(MEMTAG_HEAP_ASYNC_INCLUDE_PATHS) $(PRODUCT_MEMTAG_HEAP_ASYNC_INCLUDE_PATHS))