summaryrefslogtreecommitdiff
path: root/tests/buffer_tests.cpp
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2019-02-05 18:43:34 -0800
committerEvgenii Stepanov <eugenis@google.com>2019-02-06 13:59:16 -0800
commit7cc670637005e88e00be467c6c387112644a9209 (patch)
tree0141df753769639688cc216287be3f7f76d5cbdf /tests/buffer_tests.cpp
parent352853a53525ecb2a120dfa4e9aa03b3970df8ee (diff)
Cleanup bionic tests with hwasan.
The tests were patched earlier to run with tagging heap allocator. This change enables hwasan code instrumentation in the tests themselves, and fixes the issues that arise, mainly in the code that: * compares addresses of unrelated stack variables * compares address of a stack variable with stack limits as found in /proc/self/maps * writes address of a stack variable to a hardware watchpoint register etc. Note that static tests are broken at the moment, like all static binaries. Dynamic tests pass 100% with this change. Bug: 114279110, 124007027 Test: SANITIZE_TARGET=hwaddress; run dynamic bionic tests Change-Id: I68b8df9dd3e30b47734ddc083811a75a7f27deaa
Diffstat (limited to 'tests/buffer_tests.cpp')
-rw-r--r--tests/buffer_tests.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/buffer_tests.cpp b/tests/buffer_tests.cpp
index 75634483b..fb0b6d842 100644
--- a/tests/buffer_tests.cpp
+++ b/tests/buffer_tests.cpp
@@ -20,6 +20,7 @@
#include <gtest/gtest.h>
#include "buffer_tests.h"
+#include "utils.h"
// For the comparison buffer tests, the maximum length to test for the
// miscompare checks.
@@ -227,16 +228,11 @@ static void VerifyFencepost(uint8_t *buffer) {
}
}
-// Malloc can return a tagged pointer, which is not accepted in mm system calls like mprotect.
-// Clear top 8 bits of the address on 64-bit platforms.
+// Malloc can return a tagged pointer, which is not accepted in mm system calls like mprotect
+// in the preliminary version of the syscall tagging support in the current Pixel 2 kernel.
+// Note: the final version of the kernel patchset may relax this requirement.
static int MprotectHeap(void* addr, size_t len, int prot) {
-#if defined(__LP64__)
- constexpr uintptr_t mask = (static_cast<uintptr_t>(1) << 56) - 1;
- void* untagged_addr = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) & mask);
-#else
- void* untagged_addr = addr;
-#endif
- return mprotect(untagged_addr, len, prot);
+ return mprotect(untag_address(addr), len, prot);
}
void RunSingleBufferAlignTest(