mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 19:56:06 +00:00

Userspace page aliasing allows us to use middle pointer bits for tags without untagging them before syscalls or accesses. This should enable easier experimentation with HWASan on x86_64 platforms. Currently stack, global, and secondary heap tagging are unsupported. Only primary heap allocations get tagged. Note that aliasing mode will not work properly in the presence of fork(), since heap memory will be shared between the parent and child processes. This mode is non-ideal; we expect Intel LAM to enable full HWASan support on x86_64 in the future. Reviewed By: vitalybuka, eugenis Differential Revision: https://reviews.llvm.org/D98875
30 lines
816 B
C++
30 lines
816 B
C++
// RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <sanitizer/hwasan_interface.h>
|
|
|
|
__attribute__((no_sanitize("hwaddress"))) extern "C" void callback(const char *msg) {
|
|
fprintf(stderr, "== error start\n%s\n== error end\n", msg);
|
|
}
|
|
|
|
int main() {
|
|
__hwasan_enable_allocator_tagging();
|
|
__hwasan_set_error_report_callback(&callback);
|
|
char *volatile p = (char *)malloc(16);
|
|
p[16] = 1;
|
|
free(p);
|
|
// CHECK: ERROR: HWAddressSanitizer:
|
|
// CHECK: WRITE of size 1 at
|
|
// CHECK: allocated here:
|
|
// CHECK: Memory tags around the buggy address
|
|
|
|
// CHECK: == error start
|
|
// CHECK: ERROR: HWAddressSanitizer:
|
|
// CHECK: WRITE of size 1 at
|
|
// CHECK: allocated here:
|
|
// CHECK: Memory tags around the buggy address
|
|
// CHECK: == error end
|
|
}
|