summaryrefslogtreecommitdiff
path: root/tests/malloc_test.cpp
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2018-11-06 16:48:27 -0800
committerEvgenii Stepanov <eugenis@google.com>2018-11-06 16:59:25 -0800
commitacd6f4f9f5d248345231542df91947b44a309c26 (patch)
tree56ebc05a9af0de40af4c624e722ca2e489d0c7f1 /tests/malloc_test.cpp
parent96bd339c51194bf56781ccc738fde8babd618fc6 (diff)
Disable a few bionic tests under HWASan.
* HWASan report invalid use of the allocator api (like alignment not being power of two, or allocation size too large) in a way tests do not expect. * Code in .preinit_array runs before HWASan shadow is initialized and needs to be excluded from instrumentation. * It looks that mm system calls (mmap/mprotect/etc) will not allow tagged pointers. In fact, the use of mprotect on malloc()ed memory is doubtful - one can imagine some kind of speculative load from such memory, as compiler knows that it is addressable. Bug: 114279110 Test: bionic-unit-tests with hwasan Change-Id: I6ba4b46a0d554de77c923ad134cf156ce4ddba1b
Diffstat (limited to 'tests/malloc_test.cpp')
-rw-r--r--tests/malloc_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index c4f13f6e7..d585d8cc3 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -25,6 +25,7 @@
#include <tinyxml2.h>
#include "private/bionic_config.h"
+#include "utils.h"
#if defined(__BIONIC__)
#define HAVE_REALLOCARRAY 1
@@ -41,6 +42,7 @@ TEST(malloc, malloc_std) {
}
TEST(malloc, malloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, malloc(SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -59,12 +61,14 @@ TEST(malloc, calloc_std) {
}
TEST(malloc, calloc_illegal) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(-1, 100));
ASSERT_EQ(ENOMEM, errno);
}
TEST(malloc, calloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(1, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -80,6 +84,7 @@ TEST(malloc, calloc_overflow) {
}
TEST(malloc, memalign_multiple) {
+ SKIP_WITH_HWASAN; // hwasan requires power of 2 alignment.
// Memalign test where the alignment is any value.
for (size_t i = 0; i <= 12; i++) {
for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) {
@@ -94,10 +99,12 @@ TEST(malloc, memalign_multiple) {
}
TEST(malloc, memalign_overflow) {
+ SKIP_WITH_HWASAN;
ASSERT_EQ(nullptr, memalign(4096, SIZE_MAX));
}
TEST(malloc, memalign_non_power2) {
+ SKIP_WITH_HWASAN;
void* ptr;
for (size_t align = 0; align <= 256; align++) {
ptr = memalign(align, 1024);
@@ -280,6 +287,7 @@ TEST(malloc, calloc_multiple_realloc) {
}
TEST(malloc, realloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, realloc(nullptr, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);