summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-12-28 01:27:18 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-12-28 01:27:18 +0000
commit3408b497f9f4517b4e7a62e1da4a6745dde41185 (patch)
tree98d64634805272937d0416fba88389947dd35510 /compiler-rt
parent5ede950df9e99dc813f9251173cc6d38bf6293e8 (diff)
downloadbcm5719-llvm-3408b497f9f4517b4e7a62e1da4a6745dde41185.tar.gz
bcm5719-llvm-3408b497f9f4517b4e7a62e1da4a6745dde41185.zip
Revert "[asan] Support running without /proc.", +1
Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/asan/asan_linux.cc2
-rw-r--r--compiler-rt/lib/asan/asan_thread.cc49
-rw-r--r--compiler-rt/lib/hwasan/hwasan_thread.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_flags.inc3
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc10
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.h2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc6
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc5
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cc4
-rw-r--r--compiler-rt/test/asan/TestCases/Posix/no-fd.cc4
15 files changed, 15 insertions, 84 deletions
diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc
index 71006bfd056..a150b1955d6 100644
--- a/compiler-rt/lib/asan/asan_linux.cc
+++ b/compiler-rt/lib/asan/asan_linux.cc
@@ -210,8 +210,6 @@ void AsanCheckIncompatibleRT() {
}
} else {
if (__asan_rt_version == ASAN_RT_VERSION_UNDEFINED) {
- if (!MemoryMappingLayout::IsAvailable())
- return;
// Ensure that dynamic runtime is not present. We should detect it
// as early as possible, otherwise ASan interceptors could bind to
// the functions in dynamic ASan runtime instead of the functions in
diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc
index 6b4e09e6f8f..c05f2e28f3d 100644
--- a/compiler-rt/lib/asan/asan_thread.cc
+++ b/compiler-rt/lib/asan/asan_thread.cc
@@ -18,7 +18,6 @@
#include "asan_thread.h"
#include "asan_mapping.h"
#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_file.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
@@ -224,11 +223,9 @@ void AsanThread::Init(const InitOptions *options) {
atomic_store(&stack_switching_, false, memory_order_release);
CHECK_EQ(this->stack_size(), 0U);
SetThreadStackAndTls(options);
- if (stack_top_ != stack_bottom_) {
- CHECK_GT(this->stack_size(), 0U);
- CHECK(AddrIsInMem(stack_bottom_));
- CHECK(AddrIsInMem(stack_top_ - 1));
- }
+ CHECK_GT(this->stack_size(), 0U);
+ CHECK(AddrIsInMem(stack_bottom_));
+ CHECK(AddrIsInMem(stack_top_ - 1));
ClearShadowForThreadStackAndTLS();
fake_stack_ = nullptr;
if (__asan_option_detect_stack_use_after_return)
@@ -285,42 +282,27 @@ AsanThread *CreateMainThread() {
return main_thread;
}
-static bool StackLimitsAreAvailable() {
-#if SANITIZER_WINDOWS
- return true;
-#else
- return MemoryMappingLayout::IsAvailable();
-#endif
-}
-
// This implementation doesn't use the argument, which is just passed down
// from the caller of Init (which see, above). It's only there to support
// OS-specific implementations that need more information passed through.
void AsanThread::SetThreadStackAndTls(const InitOptions *options) {
DCHECK_EQ(options, nullptr);
- // If this process is "init" (pid 1), /proc may not be mounted yet.
- if (!start_routine_ && !StackLimitsAreAvailable()) {
- stack_top_ = stack_bottom_ = 0;
- tls_begin_ = tls_end_ = 0;
- } else {
- uptr tls_size = 0;
- uptr stack_size = 0;
- GetThreadStackAndTls(tid() == 0, &stack_bottom_, &stack_size, &tls_begin_,
- &tls_size);
- stack_top_ = stack_bottom_ + stack_size;
- tls_end_ = tls_begin_ + tls_size;
- dtls_ = DTLS_Get();
-
- int local;
- CHECK(AddrIsInStack((uptr)&local));
- }
+ uptr tls_size = 0;
+ uptr stack_size = 0;
+ GetThreadStackAndTls(tid() == 0, &stack_bottom_, &stack_size, &tls_begin_,
+ &tls_size);
+ stack_top_ = stack_bottom_ + stack_size;
+ tls_end_ = tls_begin_ + tls_size;
+ dtls_ = DTLS_Get();
+
+ int local;
+ CHECK(AddrIsInStack((uptr)&local));
}
#endif // !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
void AsanThread::ClearShadowForThreadStackAndTLS() {
- if (stack_top_ != stack_bottom_)
- PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0);
+ PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0);
if (tls_begin_ != tls_end_) {
uptr tls_begin_aligned = RoundDownTo(tls_begin_, SHADOW_GRANULARITY);
uptr tls_end_aligned = RoundUpTo(tls_end_, SHADOW_GRANULARITY);
@@ -332,9 +314,6 @@ void AsanThread::ClearShadowForThreadStackAndTLS() {
bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
StackFrameAccess *access) {
- if (stack_top_ == stack_bottom_)
- return false;
-
uptr bottom = 0;
if (AddrIsInStack(addr)) {
bottom = stack_bottom();
diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cc b/compiler-rt/lib/hwasan/hwasan_thread.cc
index 930d84e4826..0d15c7e467c 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread.cc
+++ b/compiler-rt/lib/hwasan/hwasan_thread.cc
@@ -44,7 +44,7 @@ void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
ScopedTaggingDisabler disabler;
// If this process is "init" (pid 1), /proc may not be mounted yet.
- if (IsMainThread() && !MemoryMappingLayout::IsAvailable()) {
+ if (IsMainThread() && !FileExists("/proc/self/maps")) {
stack_top_ = stack_bottom_ = 0;
tls_begin_ = tls_end_ = 0;
} else {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
index b4f2d604fa5..8e0d724e66a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -243,6 +243,3 @@ COMMON_FLAG(bool, dump_registers, true,
COMMON_FLAG(bool, detect_write_exec, false,
"If true, triggers warning when writable-executable pages requests "
"are being made")
-COMMON_FLAG(bool, test_only_emulate_no_procfs, false,
- "TEST ONLY fail to open any files under /proc to emulate sanitized "
- "\"init\"")
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index 87f65455920..8b31ace1a66 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -453,8 +453,6 @@ uptr internal_execve(const char *filename, char *const argv[],
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
- if (ShouldMockFailureToOpen(filename))
- return false;
struct stat st;
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
if (internal_syscall(SYSCALL(newfstatat), AT_FDCWD, filename, &st, 0))
@@ -1005,8 +1003,6 @@ ThreadLister::~ThreadLister() {
// Take care of unusable kernel area in top gigabyte.
static uptr GetKernelAreaSize() {
#if SANITIZER_LINUX && !SANITIZER_X32
- if (!MemoryMappingLayout::IsAvailable())
- return 0;
const uptr gbyte = 1UL << 30;
// Firstly check if there are writable segments
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
index add82ae8330..6f5387e162c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
@@ -44,7 +44,6 @@ struct MemoryMappingLayoutData {
};
void ReadProcMaps(ProcSelfMapsBuff *proc_maps);
-bool IsProcMapsAvailable();
// Syscall wrappers.
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index 8954a7a8807..43db7fc12e0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -282,8 +282,6 @@ uptr internal_waitpid(int pid, int *status, int options) {
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
- if (ShouldMockFailureToOpen(filename))
- return false;
struct stat st;
if (stat(filename, &st))
return false;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index 1286e560b50..6db92585fc0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -18,7 +18,6 @@
#include "sanitizer_common.h"
#include "sanitizer_file.h"
-#include "sanitizer_flags.h"
#include "sanitizer_libc.h"
#include "sanitizer_posix.h"
#include "sanitizer_procmaps.h"
@@ -158,8 +157,6 @@ void MprotectMallocZones(void *addr, int prot) {}
#endif
fd_t OpenFile(const char *filename, FileAccessMode mode, error_t *errno_p) {
- if (ShouldMockFailureToOpen(filename))
- return kInvalidFd;
int flags;
switch (mode) {
case RdOnly: flags = O_RDONLY; break;
@@ -232,8 +229,6 @@ static inline bool IntervalsAreSeparate(uptr start1, uptr end1,
// several worker threads on Mac, which aren't expected to map big chunks of
// memory).
bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) {
- if (!MemoryMappingLayout::IsAvailable())
- return true; // hope for the best
MemoryMappingLayout proc_maps(/*cache_enabled*/true);
MemoryMappedSegment segment;
while (proc_maps.Next(&segment)) {
@@ -339,11 +334,6 @@ fd_t ReserveStandardFds(fd_t fd) {
return fd;
}
-bool ShouldMockFailureToOpen(const char *path) {
- return common_flags()->test_only_emulate_no_procfs &&
- internal_strncmp(path, "/proc/", 6) == 0;
-}
-
} // namespace __sanitizer
#endif // SANITIZER_POSIX
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
index 04a76445eab..37f27d56707 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
@@ -103,8 +103,6 @@ bool IsStateDetached(int state);
// Move the fd out of {0, 1, 2} range.
fd_t ReserveStandardFds(fd_t fd);
-bool ShouldMockFailureToOpen(const char *path);
-
} // namespace __sanitizer
#endif // SANITIZER_POSIX_H
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
index 0b7ae1971a4..9fde040a11a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
@@ -75,7 +75,6 @@ class MemoryMappingLayout {
// to obtain the memory mappings. It should fall back to pre-cached data
// instead of aborting.
static void CacheMemoryMappings();
- static bool IsAvailable();
// Adds all mapped objects into a vector.
void DumpListOfModules(InternalMmapVectorNoCtor<LoadedModule> *modules);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc
index 8264f0c1104..4cebd98583c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc
@@ -45,10 +45,6 @@
namespace __sanitizer {
-bool IsProcMapsAvailable() {
- return true;
-}
-
void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
const int Mib[] = {
#if SANITIZER_FREEBSD
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
index 2613a50b286..1f2b431c7cc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
@@ -144,12 +144,6 @@ void MemoryMappingLayout::DumpListOfModules(
}
}
-bool MemoryMappingLayout::IsAvailable() {
- if (cached_proc_self_maps.data)
- return true;
- return IsProcMapsAvailable();
-}
-
void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) {
char *smaps = nullptr;
uptr smaps_cap = 0;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc
index ade725e7fc4..633e9393cce 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc
@@ -13,15 +13,10 @@
#include "sanitizer_platform.h"
#if SANITIZER_LINUX
#include "sanitizer_common.h"
-#include "sanitizer_file.h"
#include "sanitizer_procmaps.h"
namespace __sanitizer {
-bool IsProcMapsAvailable() {
- return FileExists("/proc/self/maps");
-}
-
void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
if (!ReadFileToBuffer("/proc/self/maps", &proc_maps->data,
&proc_maps->mmaped_size, &proc_maps->len)) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cc
index c285a207a70..9e5e37e6b9d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cc
@@ -20,10 +20,6 @@
namespace __sanitizer {
-bool IsProcMapsAvailable() {
- return FileExists("/proc/self/xmap");
-}
-
void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
ReadFileToBuffer("/proc/self/xmap", &proc_maps->data, &proc_maps->mmaped_size,
&proc_maps->len);
diff --git a/compiler-rt/test/asan/TestCases/Posix/no-fd.cc b/compiler-rt/test/asan/TestCases/Posix/no-fd.cc
index c835929f7fe..1c94545c7b3 100644
--- a/compiler-rt/test/asan/TestCases/Posix/no-fd.cc
+++ b/compiler-rt/test/asan/TestCases/Posix/no-fd.cc
@@ -9,10 +9,6 @@
#include <stdlib.h>
#include <unistd.h>
-extern "C" const char *__asan_default_options() {
- return "test_only_emulate_no_procfs=1";
-}
-
void parent(int argc, char **argv) {
fprintf(stderr, "hello\n");
// CHECK: hello
OpenPOWER on IntegriCloud