diff options
author | Derek Bruening <bruening@google.com> | 2016-06-13 15:42:39 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-06-13 15:42:39 +0000 |
commit | d5a0419aecd169af9f26b6f7254ff2ef555e497f (patch) | |
tree | c969efaae3f2a01befbd5c81c9c5a21988cd680e /test/esan | |
parent | 51be894d7708c17d006a298b247facc796305db0 (diff) |
[sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors. The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.
Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up. This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.
Adds a test that emulates an instrumented allocator.
Reviewers: aizatsky
Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka
Differential Revision: http://reviews.llvm.org/D21083
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/esan')
-rw-r--r-- | test/esan/TestCases/workingset-early-fault.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/esan/TestCases/workingset-early-fault.c b/test/esan/TestCases/workingset-early-fault.c new file mode 100644 index 000000000..1c420c368 --- /dev/null +++ b/test/esan/TestCases/workingset-early-fault.c @@ -0,0 +1,33 @@ +// Test shadow faults during esan initialization as well as +// faults during dlsym's calloc during interceptor init. +// +// RUN: %clang_esan_wset %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +// Our goal is to emulate an instrumented allocator, whose calloc +// invoked from dlsym will trigger shadow faults, to test an +// early shadow fault during esan interceptor init. +// We do this by replacing calloc: +void *calloc(size_t size, size_t n) { + // Unfortunately we can't print anything to make the test + // ensure we got here b/c the sanitizer interceptors can't + // handle that during interceptor init. + + // Ensure we trigger a shadow write fault: + int x[16]; + x[0] = size; + // Now just emulate calloc. + void *res = malloc(size*n); + memset(res, 0, size*n); + return res; +} + +int main(int argc, char **argv) { + printf("all done\n"); + return 0; +} +// CHECK: all done |