soong: HWASan exclude path support

Adds the ability to centrally disable HWASan for multiple modules when
building with SANITIZE_TARGET=hwaddress. Soong version of the patchset.

HWASan takes precedence over CFI and several other sanitizers that it's
incompatible with[1], which can be problematic for modules that require
those sanitizers (e.g. those that depend on vendor prebuilts where only
sanitized variants are provided). This patch adds an easy way to disable
HWASan for such modules while still keeping it globally enabled.

Test: build with HWASAN_EXCLUDE_PATHS set and verify with readelf that
      relevant modules have no references to __hwasan symbols

[1] bb31ca1168/core/config_sanitizers.mk (236)

Change-Id: I5824f71f2a400c64cde29e2c7afdd167d851d337
This commit is contained in:
Tomislav Novak
2023-08-22 10:51:44 -07:00
parent b98da95f1b
commit f734f00898
3 changed files with 12 additions and 2 deletions

View File

@@ -553,7 +553,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
}
if found, globalSanitizers = removeFromList("hwaddress", globalSanitizers); found && s.Hwaddress == nil {
s.Hwaddress = proptools.BoolPtr(true)
if !ctx.Config().HWASanDisabledForPath(ctx.ModuleDir()) {
s.Hwaddress = proptools.BoolPtr(true)
}
}
if found, globalSanitizers = removeFromList("writeonly", globalSanitizers); found && s.Writeonly == nil {