From d8328a931bb60b382268386912119f1d0ac2cf7c Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Mon, 10 Jun 2024 17:35:25 -0700 Subject: [PATCH] [HWASan] [16k] do not instrument getauxval To support page agnostic systems, we call getauxval before HWASan is fully set up. Bug: 315511637 Change-Id: I0b760943a23bd3a4d83bcc2182696a827dcbd446 --- libc/bionic/getauxval.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp index a3c6b1932..e188d73ff 100644 --- a/libc/bionic/getauxval.cpp +++ b/libc/bionic/getauxval.cpp @@ -37,7 +37,9 @@ // This function needs to be safe to call before TLS is set up, so it can't // access errno or the stack protector. -__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) { +// Cannot use HWASan, as this is called during setup of the HWASan runtime to +// determine the page size. +__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) __attribute__((no_sanitize("hwaddress"))) { for (ElfW(auxv_t)* v = __libc_shared_globals()->auxv; v->a_type != AT_NULL; ++v) { if (v->a_type == type) { *exists = true; @@ -48,7 +50,9 @@ __LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exist return 0; } -extern "C" unsigned long getauxval(unsigned long type) { +// Cannot use HWASan, as this is called during setup of the HWASan runtime to +// determine the page size. +extern "C" unsigned long getauxval(unsigned long type) __attribute__((no_sanitize("hwaddress"))) { bool exists; unsigned long result = __bionic_getauxval(type, &exists); if (!exists) errno = ENOENT;