[compiler-rt] r354627 - [asan] Fix vfork handling.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 21 13:55:06 PST 2019
Author: eugenis
Date: Thu Feb 21 13:55:06 2019
New Revision: 354627
URL: http://llvm.org/viewvc/llvm-project?rev=354627&view=rev
Log:
[asan] Fix vfork handling.
__asan_handle_vfork was unpoisoning the wrong part of the stack.
Adjust the test to catch this reliably (current failure is
non-deterministic).
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/test/asan/TestCases/Linux/vfork.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=354627&r1=354626&r2=354627&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Feb 21 13:55:06 2019
@@ -606,10 +606,8 @@ void *__asan_extra_spill_area() {
void __asan_handle_vfork(void *sp) {
AsanThread *t = GetCurrentThread();
CHECK(t);
- uptr PageSize = GetPageSizeCached();
- uptr top = t->stack_top();
- uptr bottom = ((uptr)sp - PageSize) & ~(PageSize - 1);
- PoisonShadow(bottom, top - bottom, 0);
+ uptr bottom = t->stack_bottom();
+ PoisonShadow(bottom, (uptr)sp - bottom, 0);
}
void NOINLINE __asan_set_death_callback(void (*callback)(void)) {
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/vfork.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/vfork.cc?rev=354627&r1=354626&r2=354627&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/vfork.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/vfork.cc Thu Feb 21 13:55:06 2019
@@ -11,13 +11,13 @@
#include <sanitizer/asan_interface.h>
__attribute__((noinline, no_sanitize("address"))) void child() {
- char x[10000];
+ alignas(8) char x[100000];
__asan_poison_memory_region(x, sizeof(x));
_exit(0);
}
__attribute__((noinline, no_sanitize("address"))) void parent() {
- char x[10000];
+ alignas(8) char x[100000];
assert(__asan_address_is_poisoned(x + 5000) == 0);
}
More information about the llvm-commits
mailing list