Commit Graph

6347 Commits

Author SHA1 Message Date
Kuba Mracek 43d287e04e [sanitizer] Track which modules are instrumented in LoadedModule objects
This patch adds tracking which modules are instrumented and which are not. On macOS, instrumented modules link against the ASan/TSan/... dylib, so we can just check if such a load command exists or not.

Differential Revision: https://reviews.llvm.org/D28263

llvm-svn: 291268
2017-01-06 19:34:54 +00:00
Mike Aizatsky fb96e04efb [sancov] introducing SANCOV_OPTIONS
Reintroducing https://reviews.llvm.org/rL291068
Define options function everywhere but linux.

llvm-svn: 291267
2017-01-06 19:22:50 +00:00
Michal Gorny 42af8da4c8 [builtins] Implement __floattitf() & __floatuntitf()
Implement the missing __floattitf() and __floatuntitf() functions, to
convert 128-bit (unsigned) integers to quad-precision floating-point
types. This is needed e.g. on AArch64 where 'long double' is
a quad-precision type.

The code is based on the existing code for __floattixf()
and __floatuntixf(), updated to account for different bit field lengths
of quad-precision float. The tests are also copied, with the rounding
tests adjusted for longer significand.

Differential Revision: https://reviews.llvm.org/D27898

llvm-svn: 291259
2017-01-06 18:46:35 +00:00
Filipe Cabecinhas b5304e25fc [ubsan] Minimize size of data for type_mismatch (Redo of D19668)
Summary: This is the compiler-rt side of D28242.

Reviewers: kcc, vitalybuka, pgousseau, gbedwell

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28244

llvm-svn: 291237
2017-01-06 14:40:28 +00:00
Michal Gorny c74123bdff [cmake] Disable appending -msse4.2 flag implicitly
Disable the code appending -msse4.2 flag implicitly when the compiler
supports it. The compiler support for this flags do not indicate that
the underlying CPU will support SSE4.2, and passing it may result in
SSE4.2 code being emitted *implicitly*.

If the target platform supports SSE4.2 appropriately, the relevant bits
should be already enabled via -march= or equivalent. In this case
passing -msse4.2 is redundant.

If a runtime detection is desired (which seems to be a case with SCUDO),
then (as gcc manpage points out) the specific SSE4.2 needs to be
isolated into a separate file, the -msse4.2 flag can be forced only
for that file and the function defined in that file can only be called
when the CPU is determined to support SSE4.2.

This fixes SIGILL on SCUDO when it is compiled using gcc-5.4.

Differential Revision: https://reviews.llvm.org/D28304

llvm-svn: 291217
2017-01-06 08:21:02 +00:00
Evgeniy Stepanov 04cfed9af5 Improved ASAN allocator and quarantine stats.
Summary: Improved ASAN allocator and quarantine stats.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28333

llvm-svn: 291183
2017-01-05 22:17:53 +00:00
Vitaly Buka 8f05c786c9 [compiler-rt] Set valid PC calling __asan_report_error SetErrorReportCallbackTest
Reviewers: eugenis

Subscribers: kubabrecka, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D28376

llvm-svn: 291176
2017-01-05 21:25:21 +00:00
Vitaly Buka e40277987f [compiler-rt] Make macros use __sanitizer::uptr instead of just uptr.
Summary: This allows to use macros outside of __sanitizer namespace

Reviewers: eugenis

Subscribers: kubabrecka, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D28375

llvm-svn: 291175
2017-01-05 21:25:20 +00:00
Vitaly Buka 006aaaf59c [asan] Fix comparison in BufferedStackTrace::LocatePcInTrace
Summary:
Debug builds can have larger distance between stack trace and PC on that stack.
If we assume that PC is always correct we can snap it to the nearest trace.

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28342

llvm-svn: 291173
2017-01-05 21:04:47 +00:00
Mike Aizatsky dc58a7d618 Revert "[sancov] introducing SANCOV_OPTIONS"
and related changes

https://llvm.org/svn/llvm-project/compiler-rt/trunk@291068

llvm-svn: 291141
2017-01-05 16:55:56 +00:00
Mike Aizatsky 252adf7c77 [sancov] force default flags for windows
llvm-svn: 291089
2017-01-05 06:55:55 +00:00
Mike Aizatsky 6196eaf0ae fixing build, accidentally deleted two lines
llvm-svn: 291077
2017-01-05 04:22:20 +00:00
Mike Aizatsky 3fd897dc32 [sancov] workaround for absence of weak symbols on win
llvm-svn: 291076
2017-01-05 04:18:02 +00:00
Mike Aizatsky 078d716d4c [sancov] workaround for absence of weak symbols on win
llvm-svn: 291071
2017-01-05 03:48:20 +00:00
Mike Aizatsky 4ae2e0c386 [sancov] introducing SANCOV_OPTIONS
Summary:
At this point SANCOV_OPTIONS are not functional but it is our intent
to move here sanitizer coverage flags from various sanitizers _OPTIONS.

Reviewers: kcc

Subscribers: kubabrecka, mgorny

Differential Revision: https://reviews.llvm.org/D28311

llvm-svn: 291068
2017-01-05 03:14:35 +00:00
Bob Haarman f04df85258 break overly long line in sanitizer_win.cc
llvm-svn: 291062
2017-01-05 01:35:38 +00:00
Bob Haarman 71a7323b5a fix warning about noreturn in sanitizer_win's internal__exit()
Summary:
A previous fix used __assume(0), but not all compilers know that control will
not pass that. This patch uses a macro which works in more compilers.

Reviewers: rnk

Subscribers: kubabrecka

Differential Revision: https://reviews.llvm.org/D28268

llvm-svn: 291042
2017-01-05 00:37:13 +00:00
Dean Michael Berris 7c030a2d91 [XRay] [compiler-rt] Include argv[0] in the log file name.
Summary:
If you decide to recompile parts of your Linux distro with XRay, it may
be useful to know which trace belongs to which binary.  While there, get
rid of the incorrect strncat() usage; it always returns a pointer to the
start which makes that if() always true.  Replace with snprintf which is
bounded so that enough from both strings fits nicely.

Reviewers: dberris

Subscribers: danalbert, srhines, kubabrecka, mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D27912

llvm-svn: 290861
2017-01-03 04:35:24 +00:00
Dean Michael Berris 0aba35710f Revert "[XRay][compiler-rt] XRay Flight Data Recorder Mode"
This reverts rL290852 as it breaks aarch64 and arm.

llvm-svn: 290854
2017-01-03 04:04:00 +00:00
Dean Michael Berris 33d305b54b [XRay][compiler-rt] XRay Flight Data Recorder Mode
Summary:
In this change we introduce the notion of a "flight data recorder" mode
for XRay logging, where XRay logs in-memory first, and write out data
on-demand as required (as opposed to the naive implementation that keeps
logging while tracing is "on"). This depends on D26232 where we
implement the core data structure for holding the buffers that threads
will be using to write out records of operation.

This implementation only currently works on x86_64 and depends heavily
on the TSC math to write out smaller records to the inmemory buffers.

Also, this implementation defines two different kinds of records with
different sizes (compared to the current naive implementation): a
MetadataRecord (16 bytes) and a FunctionRecord (8 bytes). MetadataRecord
entries are meant to write out information like the thread ID for which
the metadata record is defined for, whether the execution of a thread
moved to a different CPU, etc. while a FunctionRecord represents the
different kinds of function call entry/exit records we might encounter
in the course of a thread's execution along with a delta from the last
time the logging handler was called.

While this implementation is not exactly what is described in the
original XRay whitepaper, this one gives us an initial implementation
that we can iterate and build upon.

Reviewers: echristo, rSerge, majnemer

Subscribers: mehdi_amini, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D27038

llvm-svn: 290852
2017-01-03 03:38:17 +00:00
Evgeniy Stepanov c0e82d6bfc Decrease kLargeMalloc block size in ASAN unit tests.
Summary:
Make kLargeMalloc big enough to be handled by secondary allocator
and small enough to fit into quarantine for all configurations.
It become too big to fit into quarantine on Android after D27873.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: danalbert, llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28142

llvm-svn: 290689
2016-12-28 21:57:51 +00:00
Evgeniy Stepanov f787cf7ee6 [asan] Fix handling of %m in printf interceptor.
llvm-svn: 290632
2016-12-27 22:14:03 +00:00
Vitaly Buka ec494b2675 [compiler-rt] Fix compilation error after r290626
llvm-svn: 290629
2016-12-27 21:30:20 +00:00
Vitaly Buka f2973dcfe8 [compiler-rt] Move logic which replace memcpy interceptor with memmove from asan to sanitizer_common.
Reviewers: eugenis

Subscribers: kubabrecka, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D28074

llvm-svn: 290626
2016-12-27 21:13:11 +00:00
Vitaly Buka a5a916bdca [asan] Fix test broken by r290540
Reviewers: ahatanak, eugenis, myatsina

Subscribers: kubabrecka, zizhar, llvm-commits

Differential Revision: https://reviews.llvm.org/D28128

llvm-svn: 290621
2016-12-27 19:40:23 +00:00
Vitaly Buka b67bfd2fd7 [tsan] Fix string to bool conversion warnings in tsan tests
llvm-svn: 290568
2016-12-27 02:05:24 +00:00
Marina Yatsina 168b954611 [inline-asm]No error for conflict between inputs\outputs and clobber list
Updated test according to commit 290539:

According to extended asm syntax, a case where the clobber list includes a variable from the inputs or outputs should be an error - conflict.
for example:

const long double a = 0.0;
int main()
{

char b;
double t1 = a;
__asm__ ("fucompp": "=a" (b) : "u" (t1), "t" (t1) : "cc", "st", "st(1)");

return 0;
}

This should conflict with the output - t1 which is st, and st which is st aswell.
The patch fixes it.

Commit on behald of Ziv Izhar.

Differential Revision: https://reviews.llvm.org/D15075

llvm-svn: 290540
2016-12-26 12:24:49 +00:00
Kuba Mracek a6a177389c [sanitizer] Define some CPU type symbols (like CPU_SUBTYPE_X86_64_H) when they're not available.
This allows compiler-rt to be built on older macOS SDKs, where there symbols are not defined.

Patch by Jeremy Huddleston Sequoia <jeremyhu@apple.com>.

llvm-svn: 290521
2016-12-25 20:03:40 +00:00
Renato Golin ece8de7c23 Revert "[XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification"
This reverts commit r290452, not quite there yet. We need to test this
offline.

llvm-svn: 290453
2016-12-23 21:58:39 +00:00
Serge Rogatch 4ee228bf73 [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime.

Reviewers: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson

Differential Revision: https://reviews.llvm.org/D27996

llvm-svn: 290452
2016-12-23 21:21:01 +00:00
Vitaly Buka 2e97554245 [compiler-rt] Define COMMON_INTERCEPT_FUNCTION_MEMCPY for tsan and esan
Reviewers: eugenis

Subscribers: kubabrecka, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D28072

llvm-svn: 290396
2016-12-23 01:08:31 +00:00
Vitaly Buka cd613e9d6d Fix interceptors setup broken after r290382
Summary: We setup these interceptors twice which hangs test on windows.

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28070

llvm-svn: 290393
2016-12-23 00:37:07 +00:00
Vitaly Buka 9895f7959a Replace WRAP in interceptors with memset, memmove and memcpy implementation
Summary:
According https://reviews.llvm.org/D27659#625093 WRAP adds confusing stack
frame.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28039

llvm-svn: 290382
2016-12-22 22:02:26 +00:00
Evgeniy Stepanov 37db58e9eb Expose thread local quarantine size as ASAN option.
Summary: Make thread local quarantine size an option so it can be turned off to save memory.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28027

llvm-svn: 290373
2016-12-22 21:43:22 +00:00
Evgeniy Stepanov 055f506c54 Improve ThreadedQuarantineTest heap memory measurements.
Summary:
Warm up ASAN caches in ThreadedQuarantineTest to get more predictable
incremental heap memory usage measurements.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: aemerson, kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28061

llvm-svn: 290371
2016-12-22 21:16:04 +00:00
Renato Golin fe8bbb2333 Revert "[XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification"
This reverts commit r290354, as it broke the build. We need to make sure
this builds on AArch64 before committing again.

llvm-svn: 290362
2016-12-22 19:38:04 +00:00
Serge Rogatch 93fb15788a [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime.

Reviewers: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson

Differential Revision: https://reviews.llvm.org/D27996

llvm-svn: 290354
2016-12-22 18:48:36 +00:00
Krzysztof Parzyszek bd0455defa [compiler-rt] Add missing includes of <errno.h> and <iterator>
The compilation failed due to undeclared identifiers: distance, errno,
and EINTR.

llvm-svn: 290343
2016-12-22 15:31:21 +00:00
Diana Picus 6b88e325ea [XRay] [compiler-rt] Move machine-dependent code into machine-dependent files
Reapply r290077.

Authors: pelikan

Differential Revision: https://reviews.llvm.org/D27979

llvm-svn: 290330
2016-12-22 07:35:56 +00:00
Evgeniy Stepanov 76a60a8ccd Increase the treshold in unit test to accomodate for qurantine size increase.
Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28029

llvm-svn: 290279
2016-12-21 22:50:08 +00:00
Evgeniy Stepanov 1a21263a89 Reduce the size of quarantine cache in ASAN_LOW_MEMORY configuration.
Summary:
Experiments show that on Android the current values result in too much
of the memory consumption for all quarantined chunks.

Reviewers: kcc, eugenis

Subscribers: mgorny, danalbert, srhines, llvm-commits, kubabrecka

Patch by Aleksey Shlyapnikov.

Differential Revision: https://reviews.llvm.org/D27873

llvm-svn: 290218
2016-12-21 00:18:10 +00:00
Dimitry Andric 003fe25b07 Fix build breakage on FreeBSD after rL289878/rL289881
Summary:
After rL289878/rL289881, the build on FreeBSD is broken, because
sanitizer_platform_limits_posix.cc attempts to include <utmp.h> and use
`struct utmp`, neither of which are supported anymore on FreeBSD.

Fix this by adding `&& !SANITIZER_FREEBSD` in a few places, and stop
intercepting utmp functions altogether for FreeBSD.

Reviewers: kubabrecka, emaste, eugenis, ed

Subscribers: ed, llvm-commits

Differential Revision: https://reviews.llvm.org/D27902

llvm-svn: 290167
2016-12-20 07:58:49 +00:00
Kuba Mracek 1187cbd20f [tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query pointer types and allocation stacks of heap pointers
In ASan, we have __asan_locate_address and __asan_get_alloc_stack, which is used in LLDB/Xcode to show the allocation backtrace for a heap memory object. This patch implements the same for TSan.

Differential Revision: https://reviews.llvm.org/D27656

llvm-svn: 290119
2016-12-19 17:52:20 +00:00
Diana Picus c0eb996318 Revert "[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files."
This reverts commit r290077, 78, 79 and 83.

llvm-svn: 290101
2016-12-19 12:43:08 +00:00
Dean Michael Berris 2cc7fc2cc6 [XRay][compiler-rt] Fix missing include of <cerrno>
Futher attempt to un-break ARM and AArch64 build.

Follow-up on D25360.

llvm-svn: 290083
2016-12-19 05:26:14 +00:00
Dean Michael Berris 6f16e2c456 [XRay][compiler-rt] Post-commit review fixup of XRay refactoring.
Missed a couple of files:

- Using #pragma once
- Missing top-matter for headers
- Missing an include for <cstdint>

Follow-up on D25360.

llvm-svn: 290079
2016-12-19 03:59:20 +00:00
Dean Michael Berris 4527ebecb6 [XRay][compiler-rt] Explicitly include <cstdint> for types
This is an attempt to un-break the ARM7, AArch64 builds.

Follow-up on D25360.

llvm-svn: 290078
2016-12-19 03:47:35 +00:00
Dean Michael Berris 094173ba2c [XRay] [compiler-rt] Move machine-dependent code into machine-dependent files.
Summary: Include the necessary headers while there.

Reviewers: dberris

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25360

llvm-svn: 290077
2016-12-19 03:21:26 +00:00
Dean Michael Berris a53217d185 [XRay] [compiler-rt] Fix format string; sanitizers' internal printf() doesn't support %ld.
Summary:
Getting rid of the distance number altogether because:
- a person knowledgeable enough to know what the message means will also
  know how to do hexadecimal math (with the help of a calculator)
- numbers outside INT_MIN - INT_MAX are hard to comprehend anyway

This unbreaks the case when you dynamically link a library with XRay and
it exits pre-main() with a not very informative static string.

Author: pelikan

Reviewers: dberris

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D27894

llvm-svn: 290074
2016-12-19 00:47:40 +00:00
Kuba Mracek 0bd0fe4e7d Ifdef out utmp.h on Darwin to un-break the build after r289878 ([msan] Intercept getutent and friends).
llvm-svn: 289881
2016-12-15 22:40:24 +00:00