From 4e2debd3ae435f27f0c8499e92ac08d18c4c22c1 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 4 Jan 2023 15:34:29 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136969 Code-Coverage: Zoss Reviewed-by: Daisuke Nojiri Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- test/always_memset.c | 14 ++++++++++++-- test/build.mk | 3 --- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'test') 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 -- cgit v1.2.1