diff options
author | Jeremy Bettis <jbettis@google.com> | 2023-01-04 15:34:29 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-10 23:20:52 +0000 |
commit | 4e2debd3ae435f27f0c8499e92ac08d18c4c22c1 (patch) | |
tree | 493e191f1259f7e240ef9dea1986922e63917d0e /test | |
parent | 210cb0c8729f4187a6bad89e7d3ece8c419433ea (diff) | |
download | chrome-ec-4e2debd3ae435f27f0c8499e92ac08d18c4c22c1.tar.gz |
test: Disable ASAN for 2 functions
These two functions return a pointer to memory on the stack, which is
very naughty and ASAN catches that. However, this is intended to see if
the compiler optimizes out "unnecessary" writes to data that will
"clearly" never be used again, since it's on the stack.
Disable ASAN on these functions to prevent the compiler from being too
smart.
BRANCH=None
BUG=b:264432260
TEST=make clobber -j$(nproc) && \
make runtests -j$(nproc) && \
make -j$(nproc) tests-bloonchipper tests-dartmonkey && \
make clobber -j$(nproc) && \
make -j$(nproc) TEST_ASAN=y runtests && \
echo SUCCESS
Change-Id: If1ca3a6c97f34021b99dd246858ac3a3be7692a8
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136969
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/always_memset.c | 14 | ||||
-rw-r--r-- | test/build.mk | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/test/always_memset.c b/test/always_memset.c index eed15cab27..8a022ef8ef 100644 --- a/test/always_memset.c +++ b/test/always_memset.c @@ -78,8 +78,13 @@ fake_builtin_memset(char *dest, char c, size_t len) * functionality. * - To check how much of the stack |space| was used by the caller, * run "x/256xb $adr" or "x/64xw $adr" after the memcpy. + * + * Disable ASAN with the attribute because this function returns a pointer to + * stack memory, which is normally very naughty, but is what we want to test + * here. */ -test_static void exercise_memset(char **p) +__attribute__((no_sanitize("address"))) test_static void +exercise_memset(char **p) { /* * Add extra stack space so that |buf| doesn't get trampled while the @@ -134,8 +139,13 @@ test_static int test_optimization_working(void) * to optimize out the last memset due to no side effect. * * This function layout must remain identical to exercise_memset. + * + * Disable ASAN with the attribute because this function returns a pointer to + * stack memory, which is normally very naughty, but is what we want to test + * here. */ -test_static void exercise_always_memset(char **p) +__attribute__((no_sanitize("address"))) test_static void +exercise_always_memset(char **p) { /* * Add extra stack space so that |buf| doesn't get trampled while the diff --git a/test/build.mk b/test/build.mk index e993268143..963882cea2 100644 --- a/test/build.mk +++ b/test/build.mk @@ -21,10 +21,7 @@ test-list-host=$(TEST_LIST_HOST) else test-list-host = accel_cal test-list-host += aes -ifeq ($(TEST_ASAN),) -# TODO(b/264432260): always_memset fails with TEST_ASAN test-list-host += always_memset -endif test-list-host += base32 test-list-host += battery_get_params_smart test-list-host += benchmark |