summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-02-21 22:02:24 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-02-21 22:02:24 +0000
commit748f97f86ca8e5ce660be440ddee30d93e8f87c8 (patch)
tree94daf3376f20e2e7d96314776d2275a62309ff95
parent0733cd3710e924eb8452338480e27db71c35910f (diff)
downloadcompiler-rt-748f97f86ca8e5ce660be440ddee30d93e8f87c8.tar.gz
Revert "[asan] Fix vfork handling.", +1
Revert r354625, r354627 - multiple build failures. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354629 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/sanitizer/hwasan_interface.h8
-rw-r--r--lib/asan/CMakeLists.txt1
-rw-r--r--lib/asan/asan_interceptors.cc4
-rw-r--r--lib/asan/asan_interceptors_vfork.S7
-rw-r--r--lib/asan/asan_interface.inc2
-rw-r--r--lib/asan/asan_interface_internal.h3
-rw-r--r--lib/asan/asan_rtl.cc13
-rw-r--r--lib/asan/asan_thread.h3
-rw-r--r--lib/hwasan/CMakeLists.txt1
-rw-r--r--lib/hwasan/hwasan.cc24
-rw-r--r--lib/hwasan/hwasan_interceptors.cc5
-rw-r--r--lib/hwasan/hwasan_interceptors_vfork.S7
-rw-r--r--lib/hwasan/hwasan_interface_internal.h6
-rw-r--r--lib/hwasan/hwasan_thread.h3
-rw-r--r--lib/sanitizer_common/CMakeLists.txt1
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S43
-rw-r--r--test/asan/TestCases/Linux/vfork.cc31
-rw-r--r--test/hwasan/TestCases/Linux/vfork.c32
18 files changed, 0 insertions, 194 deletions
diff --git a/include/sanitizer/hwasan_interface.h b/include/sanitizer/hwasan_interface.h
index 104af4caa..731ffc401 100644
--- a/include/sanitizer/hwasan_interface.h
+++ b/include/sanitizer/hwasan_interface.h
@@ -50,10 +50,6 @@ extern "C" {
// does would cause false reports.
void __hwasan_handle_longjmp(const void *sp_dst);
- // Set memory tag for the part of the current thread stack below sp_dst to
- // zero. Call this in vfork() before returning in the parent process.
- void __hwasan_handle_vfork(const void *sp_dst);
-
// Libc hook for thread creation. Should be called in the child thread before
// any instrumented code.
void __hwasan_thread_enter();
@@ -69,10 +65,6 @@ extern "C" {
// Print one-line report about the memory usage of the current process.
void __hwasan_print_memory_usage();
- /* Returns the offset of the first byte in the memory range that can not be
- * accessed through the pointer in x, or -1 if the whole range is good. */
- intptr_t __hwasan_test_shadow(const volatile void *x, size_t size);
-
int __sanitizer_posix_memalign(void **memptr, size_t alignment, size_t size);
void * __sanitizer_memalign(size_t alignment, size_t size);
void * __sanitizer_aligned_alloc(size_t alignment, size_t size);
diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt
index 0cf6888a1..51bda0524 100644
--- a/lib/asan/CMakeLists.txt
+++ b/lib/asan/CMakeLists.txt
@@ -13,7 +13,6 @@ set(ASAN_SOURCES
asan_globals_win.cc
asan_interceptors.cc
asan_interceptors_memintrinsics.cc
- asan_interceptors_vfork.S
asan_linux.cc
asan_mac.cc
asan_malloc_linux.cc
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index e59679bec..7f2660df4 100644
--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -579,8 +579,6 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
}
#endif // ASAN_INTERCEPT___CXA_ATEXIT
-DEFINE_REAL(void, vfork);
-
// ---------------------- InitializeAsanInterceptors ---------------- {{{1
namespace __asan {
void InitializeAsanInterceptors() {
@@ -658,8 +656,6 @@ void InitializeAsanInterceptors() {
ASAN_INTERCEPT_FUNC(__cxa_atexit);
#endif
- __interception::GetRealFunctionAddress("vfork", (uptr *)&REAL(vfork), 0, 0);
-
InitializePlatformInterceptors();
VReport(1, "AddressSanitizer: libc interceptors initialized\n");
diff --git a/lib/asan/asan_interceptors_vfork.S b/lib/asan/asan_interceptors_vfork.S
deleted file mode 100644
index 7f4d8c688..000000000
--- a/lib/asan/asan_interceptors_vfork.S
+++ /dev/null
@@ -1,7 +0,0 @@
-#define COMMON_INTERCEPTOR_SPILL_AREA __asan_extra_spill_area
-#define COMMON_INTERCEPTOR_HANDLE_VFORK __asan_handle_vfork
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S"
-
-#if defined(__linux__)
-.section .note.GNU-stack,"",@progbits
-#endif
diff --git a/lib/asan/asan_interface.inc b/lib/asan/asan_interface.inc
index 99f1db493..1dd9c6301 100644
--- a/lib/asan/asan_interface.inc
+++ b/lib/asan/asan_interface.inc
@@ -26,7 +26,6 @@ INTERFACE_FUNCTION(__asan_exp_store4)
INTERFACE_FUNCTION(__asan_exp_store8)
INTERFACE_FUNCTION(__asan_exp_store16)
INTERFACE_FUNCTION(__asan_exp_storeN)
-INTERFACE_FUNCTION(__asan_extra_spill_area)
INTERFACE_FUNCTION(__asan_get_alloc_stack)
INTERFACE_FUNCTION(__asan_get_current_fake_stack)
INTERFACE_FUNCTION(__asan_get_free_stack)
@@ -39,7 +38,6 @@ INTERFACE_FUNCTION(__asan_get_report_pc)
INTERFACE_FUNCTION(__asan_get_report_sp)
INTERFACE_FUNCTION(__asan_get_shadow_mapping)
INTERFACE_FUNCTION(__asan_handle_no_return)
-INTERFACE_FUNCTION(__asan_handle_vfork)
INTERFACE_FUNCTION(__asan_init)
INTERFACE_FUNCTION(__asan_load_cxx_array_cookie)
INTERFACE_FUNCTION(__asan_load1)
diff --git a/lib/asan/asan_interface_internal.h b/lib/asan/asan_interface_internal.h
index 59163a332..ea8750e90 100644
--- a/lib/asan/asan_interface_internal.h
+++ b/lib/asan/asan_interface_internal.h
@@ -249,9 +249,6 @@ extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
const char* __asan_default_suppressions();
-
- SANITIZER_INTERFACE_ATTRIBUTE void *__asan_extra_spill_area();
- SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp);
} // extern "C"
#endif // ASAN_INTERFACE_INTERNAL_H
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index f5ebef3c8..67eb1a783 100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -597,19 +597,6 @@ void NOINLINE __asan_handle_no_return() {
curr_thread->fake_stack()->HandleNoReturn();
}
-void *__asan_extra_spill_area() {
- AsanThread *t = GetCurrentThread();
- CHECK(t);
- return t->extra_spill_area();
-}
-
-void __asan_handle_vfork(void *sp) {
- AsanThread *t = GetCurrentThread();
- CHECK(t);
- uptr bottom = t->stack_bottom();
- PoisonShadow(bottom, (uptr)sp - bottom, 0);
-}
-
void NOINLINE __asan_set_death_callback(void (*callback)(void)) {
SetUserDieCallback(callback);
}
diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h
index 5a6010e85..1e08d5771 100644
--- a/lib/asan/asan_thread.h
+++ b/lib/asan/asan_thread.h
@@ -130,8 +130,6 @@ class AsanThread {
AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }
AsanStats &stats() { return stats_; }
- void *extra_spill_area() { return &extra_spill_area_; }
-
private:
// NOTE: There is no AsanThread constructor. It is allocated
// via mmap() and *must* be valid in zero-initialized state.
@@ -167,7 +165,6 @@ class AsanThread {
AsanThreadLocalMallocStorage malloc_storage_;
AsanStats stats_;
bool unwinding_;
- uptr extra_spill_area_;
};
// ScopedUnwinding is a scope for stacktracing member of a context
diff --git a/lib/hwasan/CMakeLists.txt b/lib/hwasan/CMakeLists.txt
index d64564412..7460abc54 100644
--- a/lib/hwasan/CMakeLists.txt
+++ b/lib/hwasan/CMakeLists.txt
@@ -6,7 +6,6 @@ set(HWASAN_RTL_SOURCES
hwasan_allocator.cc
hwasan_dynamic_shadow.cc
hwasan_interceptors.cc
- hwasan_interceptors_vfork.S
hwasan_linux.cc
hwasan_memintrinsics.cc
hwasan_poisoning.cc
diff --git a/lib/hwasan/hwasan.cc b/lib/hwasan/hwasan.cc
index 3a87dea26..9c83f73bd 100644
--- a/lib/hwasan/hwasan.cc
+++ b/lib/hwasan/hwasan.cc
@@ -477,30 +477,6 @@ void __hwasan_handle_longjmp(const void *sp_dst) {
TagMemory(sp, dst - sp, 0);
}
-void __hwasan_handle_vfork(const void *sp_dst) {
- uptr sp = (uptr)sp_dst;
- Thread *t = GetCurrentThread();
- CHECK(t);
- uptr top = t->stack_top();
- uptr bottom = t->stack_bottom();
- static const uptr kMaxExpectedCleanupSize = 64 << 20; // 64M
- if (top == 0 || bottom == 0 || sp < bottom || sp >= top ||
- sp - bottom > kMaxExpectedCleanupSize) {
- Report(
- "WARNING: HWASan is ignoring requested __hwasan_handle_vfork: "
- "stack top: %zx; current %zx; bottom: %zx \n"
- "False positive error reports may follow\n",
- top, sp, bottom);
- return;
- }
- TagMemory(bottom, sp - bottom, 0);
-}
-
-void *__hwasan_extra_spill_area() {
- Thread *t = GetCurrentThread();
- return &t->vfork_spill();
-}
-
void __hwasan_print_memory_usage() {
InternalScopedString s(kMemoryUsageBufferSize);
HwasanFormatMemoryUsage(s);
diff --git a/lib/hwasan/hwasan_interceptors.cc b/lib/hwasan/hwasan_interceptors.cc
index 1884b3da3..baecb1e03 100644
--- a/lib/hwasan/hwasan_interceptors.cc
+++ b/lib/hwasan/hwasan_interceptors.cc
@@ -227,10 +227,6 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr,
}
#endif
-#if HWASAN_WITH_INTERCEPTORS
-DEFINE_REAL(void, vfork);
-#endif
-
static void BeforeFork() {
StackDepotLockAll();
}
@@ -270,7 +266,6 @@ void InitializeInterceptors() {
INTERCEPT_FUNCTION(fork);
#if HWASAN_WITH_INTERCEPTORS
- __interception::GetRealFunctionAddress("vfork", (uptr *)&REAL(vfork), 0, 0);
#if !defined(__aarch64__)
INTERCEPT_FUNCTION(pthread_create);
#endif
diff --git a/lib/hwasan/hwasan_interceptors_vfork.S b/lib/hwasan/hwasan_interceptors_vfork.S
deleted file mode 100644
index 54b4a78db..000000000
--- a/lib/hwasan/hwasan_interceptors_vfork.S
+++ /dev/null
@@ -1,7 +0,0 @@
-#define COMMON_INTERCEPTOR_SPILL_AREA __hwasan_extra_spill_area
-#define COMMON_INTERCEPTOR_HANDLE_VFORK __hwasan_handle_vfork
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S"
-
-#if defined(__linux__)
-.section .note.GNU-stack,"",@progbits
-#endif
diff --git a/lib/hwasan/hwasan_interface_internal.h b/lib/hwasan/hwasan_interface_internal.h
index 1b025c923..c2ae66653 100644
--- a/lib/hwasan/hwasan_interface_internal.h
+++ b/lib/hwasan/hwasan_interface_internal.h
@@ -117,9 +117,6 @@ SANITIZER_INTERFACE_ATTRIBUTE
void __hwasan_handle_longjmp(const void *sp_dst);
SANITIZER_INTERFACE_ATTRIBUTE
-void __hwasan_handle_vfork(const void *sp_dst);
-
-SANITIZER_INTERFACE_ATTRIBUTE
u16 __sanitizer_unaligned_load16(const uu16 *p);
SANITIZER_INTERFACE_ATTRIBUTE
@@ -203,9 +200,6 @@ SANITIZER_INTERFACE_ATTRIBUTE
void *__hwasan_memset(void *s, int c, uptr n);
SANITIZER_INTERFACE_ATTRIBUTE
void *__hwasan_memmove(void *dest, const void *src, uptr n);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void *__hwasan_extra_spill_area();
} // extern "C"
#endif // HWASAN_INTERFACE_INTERNAL_H
diff --git a/lib/hwasan/hwasan_thread.h b/lib/hwasan/hwasan_thread.h
index 6fa592bfa..9c45adec1 100644
--- a/lib/hwasan/hwasan_thread.h
+++ b/lib/hwasan/hwasan_thread.h
@@ -67,14 +67,11 @@ class Thread {
Print("Thread: ");
}
- uptr &vfork_spill() { return vfork_spill_; }
-
private:
// NOTE: There is no Thread constructor. It is allocated
// via mmap() and *must* be valid in zero-initialized state.
void ClearShadowForThreadStackAndTLS();
void Print(const char *prefix);
- uptr vfork_spill_;
uptr stack_top_;
uptr stack_bottom_;
uptr tls_begin_;
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index d37804572..4d331ec5e 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -126,7 +126,6 @@ set(SANITIZER_IMPL_HEADERS
sanitizer_common_interceptors.inc
sanitizer_common_interceptors_format.inc
sanitizer_common_interceptors_ioctl.inc
- sanitizer_common_interceptors_vfork_aarch64.inc.S
sanitizer_common_interface.inc
sanitizer_common_interface_posix.inc
sanitizer_common_syscalls.inc
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S b/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
deleted file mode 100644
index fa20c7765..000000000
--- a/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
+++ /dev/null
@@ -1,43 +0,0 @@
-#if defined(__aarch64__) && defined(__linux__)
-
-#include "sanitizer_common/sanitizer_asm.h"
-
-ASM_HIDDEN(COMMON_INTERCEPTOR_SPILL_AREA)
-
-.comm _ZN14__interception10real_vforkE,8,8
-.globl vfork
-ASM_TYPE_FUNCTION(vfork)
-vfork:
- // Save x30 in the off-stack spill area.
- stp xzr, x30, [sp, #-16]!
- bl COMMON_INTERCEPTOR_SPILL_AREA
- ldp xzr, x30, [sp], 16
- str x30, [x0]
-
- // Call real vfork. This may return twice. User code that runs between the first and the second return
- // may clobber the stack frame of the interceptor; that's why it does not have a frame.
- adrp x0, _ZN14__interception10real_vforkE
- ldr x0, [x0, :lo12:_ZN14__interception10real_vforkE]
- blr x0
-
- stp x0, xzr, [sp, #-16]!
- cmp x0, #0
- b.eq .L_exit
-
- // x0 != 0 => parent process. Clear stack shadow.
- add x0, sp, #16
- bl COMMON_INTERCEPTOR_HANDLE_VFORK
-
-.L_exit:
- // Restore x30.
- bl COMMON_INTERCEPTOR_SPILL_AREA
- ldr x30, [x0]
- ldp x0, xzr, [sp], 16
-
- ret
-ASM_SIZE(vfork)
-
-.globl __interceptor_vfork
-.set __interceptor_vfork, vfork
-
-#endif
diff --git a/test/asan/TestCases/Linux/vfork.cc b/test/asan/TestCases/Linux/vfork.cc
deleted file mode 100644
index b366c1e06..000000000
--- a/test/asan/TestCases/Linux/vfork.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// https://github.com/google/sanitizers/issues/925
-// RUN: %clang_asan -O0 %s -o %t && %run %t 2>&1
-
-// REQUIRES: aarch64-android-target-arch
-
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sanitizer/asan_interface.h>
-
-__attribute__((noinline, no_sanitize("address"))) void child() {
- alignas(8) char x[100000];
- __asan_poison_memory_region(x, sizeof(x));
- _exit(0);
-}
-
-__attribute__((noinline, no_sanitize("address"))) void parent() {
- alignas(8) char x[100000];
- assert(__asan_address_is_poisoned(x + 5000) == 0);
-}
-
-int main(int argc, char **argv) {
- if (vfork())
- parent();
- else
- child();
-
- return 0;
-}
diff --git a/test/hwasan/TestCases/Linux/vfork.c b/test/hwasan/TestCases/Linux/vfork.c
deleted file mode 100644
index bcdd370d7..000000000
--- a/test/hwasan/TestCases/Linux/vfork.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// https://github.com/google/sanitizers/issues/925
-// RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1
-
-// REQUIRES: aarch64-target-arch
-
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sanitizer/hwasan_interface.h>
-
-__attribute__((noinline, no_sanitize("hwaddress"))) void child() {
- char x[10000];
- __hwasan_tag_memory(x, 0xAA, sizeof(x));
- _exit(0);
-}
-
-__attribute__((noinline, no_sanitize("hwaddress"))) void parent() {
- char x[10000];
- __hwasan_print_shadow(&x, sizeof(x));
- assert(__hwasan_test_shadow(x, sizeof(x)) == -1);
-}
-
-int main(int argc, char **argv) {
- if (vfork())
- parent();
- else
- child();
-
- return 0;
-}