Commit Graph

10984 Commits

Author SHA1 Message Date
Kamil Rytarowski
175d2b8620 Add interceptors for the fts(3) API family from NetBSD
Summary:
fts(3) is API to traverse a file hierarchy.
Cover this interface with interceptors.

Add a test to validate the interface reading
the number of regular files in /etc.

Based on original work by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348227
2018-12-04 01:45:52 +00:00
Kamil Rytarowski
145ac7940e Add new interceptor for regex(3) in NetBSD
Summary:
Add interceptors for the NetBSD style of regex(3) present inside libc:

 - regcomp
 - regexec
 - regerror
 - regfree
 - regnsub
 - regasub

Add a dedicated test verifying the installed interceptors.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348224
2018-12-04 01:41:42 +00:00
Vedant Kumar
6b062cd694 [gcov/Darwin] Ensure external symbols are exported when using an export list
Make sure that symbols needed to implement runtime support for gcov are
exported when using an export list on Darwin.

Without the clang driver exporting these symbols, the linker hides them,
resulting in tapi verification failures.

rdar://45944768

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

llvm-svn: 348187
2018-12-03 20:53:58 +00:00
Eugene Leviant
a50c05872e [SanitizerCommon] Remove RenameFile
This function seems to be no longer used by compiler-rt
libraries

Differential revision: https://reviews.llvm.org/D55123

llvm-svn: 348140
2018-12-03 14:03:51 +00:00
Dan Liew
8bffb63497 Introduce a way to allow the ASan dylib on Darwin platforms to be loaded via dlopen().
Summary:

The purpose of this option is provide a way for the ASan dylib
to be loaded via `dlopen()` without triggering most initialization
steps (e.g. shadow memory set up) that normally occur when the
ASan dylib is loaded.

This new functionality is exposed by

- A `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` macro which indicates if the
  feature is supported. This only true for Darwin currently.
- A `HandleDlopenInit()` function which should return true if the library
  is being loaded via `dlopen()` and
  `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` is supported. Platforms that
  support this may perform any initialization they wish inside this
  function.

Although disabling initialization is something that could potentially
apply to other sanitizers it appears to be unnecessary for other
sanitizers so this patch only makes the change for ASan.

rdar://problem/45284065

Reviewers: kubamracek, george.karpenkov, kcc, eugenis, krytarowski

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 348078
2018-12-01 15:45:42 +00:00
Vitaly Buka
a7b079534a [compiler-rt] Use "ColumnLimit: 0" instead of "clang-format off" in tests
Reviewers: eugenis, jfb

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 348061
2018-12-01 01:24:29 +00:00
Kamil Rytarowski
f130d111b6 Add a new interceptor for getvfsstat(2) from NetBSD
Summary:
getvfsstat - gets list of all mounted file systems.

Add a dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348027
2018-11-30 19:43:53 +00:00
Reid Kleckner
63f084bd7a Revert r346560 "[winasan] Unpoison the stack in NtTerminateThread"
This reverts r343606 again. The NtTerminateThread interceptor is causing
problems in NaCl:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/CrWinAsan/1839

I reproduced the problem locally and tried my best to debug them, but
it's beyond me.

llvm-svn: 347933
2018-11-29 23:57:17 +00:00
Julian Lettner
647782c78b (no commit message)
llvm-svn: 347788
2018-11-28 18:17:23 +00:00
Matt Morehouse
32c57553c3 [gcov] Disable instrprof-gcov-fork.test.
Test has been flaky for over a week and author hasn't fixed.

llvm-svn: 347779
2018-11-28 17:24:07 +00:00
Martin Storsjo
fec4f351d5 [CMake] Add a missing case of TO_CMAKE_PATH
This fixes building sanitizers for mingw natively.

llvm-svn: 347646
2018-11-27 09:23:15 +00:00
Kuba Mracek
265cd31fbf Fix filtering of sanitizer_common unittest architectures on Darwin.
llvm-svn: 347622
2018-11-27 01:37:08 +00:00
Benjamin Kramer
a2ada4d1ce [X86][compiler-rt] Add missing semicolon
llvm-svn: 347519
2018-11-24 20:57:03 +00:00
Craig Topper
428caa398c [X86] Make conversion of feature bits into a mask explicitly unsigned by using 1U instead of 1.
llvm-svn: 347517
2018-11-24 20:25:45 +00:00
Craig Topper
62e5924dd6 [X86][compiler-rt] Attempt to fix a warning about a shift amount being negative in a macro expansion.
llvm-svn: 347516
2018-11-24 20:14:03 +00:00
David Carlier
0a01f5d244 Unbreak FreeBSD build.
M    lib/sanitizer_common/sanitizer_platform_limits_posix.cc

llvm-svn: 347451
2018-11-22 10:31:01 +00:00
Petr Hosek
e7dec7848b [XRay] Support for Fuchsia
This extends XRay to support Fuchsia.

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

llvm-svn: 347443
2018-11-22 02:00:44 +00:00
Peter Collingbourne
56f3bb4b36 tsan: Update measurements in check_analyze.sh.
These changed as a result of r347379. Unfortunately there was a
regression; filed PR39748 to track it.

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

llvm-svn: 347442
2018-11-22 00:47:37 +00:00
Peter Collingbourne
c56109306b tsan: Correct the name of an executable.
llvm-svn: 347439
2018-11-22 00:00:26 +00:00
David Carlier
0c81a62d9d [Sanitizer] Adding setvbuf in supported platforms and other stream buffer functions
- Enabling setvbuf interceptions for non NetBSD platforms.
- setbuf, setbuffer, setlinebuf as well.

Reviewers: vitalybuka, krytarowski	

Reviewed By: vitalybuka

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

llvm-svn: 347426
2018-11-21 21:17:46 +00:00
Roman Lebedev
1d0c7f563c [compiler-rt][UBSan] silence_unsigned_overflow: do *NOT* ignore *fatal* unsigned overflows
Summary:
D48660 / rL335762 added a `silence_unsigned_overflow` env flag for [[ https://github.com/google/oss-fuzz/pull/1717 | oss-fuzz needs ]],
that allows to silence the reports from unsigned overflows.
It makes sense, it is there because `-fsanitize=integer` sanitizer is not enabled on oss-fuzz,
so this allows to still use it as an interestingness signal, without getting the actual reports.

However there is a slight problem here.
All types of unsigned overflows are ignored.
Even if `-fno-sanitize-recover=unsigned` was used (which means the program will die after the report)
there will still be no report, the program will just silently die.

At the moment there are just two projects on oss-fuzz that care:
* [[ 8eeffa627f/projects/llvm_libcxx/build.sh (L18-L20) | libc++ ]]
* [[ 8eeffa627f/projects/librawspeed/build.sh | RawSpeed ]] (me)

I suppose this could be overridden there ^, but i really don't think this is intended behavior in any case..

Reviewers: kcc, Dor1s, #sanitizers, filcab, vsk, kubamracek

Reviewed By: Dor1s

Subscribers: dberris, mclow.lists, llvm-commits

Tags: #sanitizers

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

llvm-svn: 347415
2018-11-21 20:35:43 +00:00
Dmitry Vyukov
d0fb5d8b00 tsan: add pthread_tryjoin_np and pthread_timedjoin_np interceptors
Add pthread_tryjoin_np() and pthread_timedjoin_np() interceptors on Linux,
so that ThreadSanitizer can handle programs using these functions.

Author: Yuri Per (yuri)
Reviewed in: https://reviews.llvm.org/D54521

llvm-svn: 347383
2018-11-21 09:31:21 +00:00
Douglas Yung
5839abb2f9 Add header <atomic> which is needed to compile with some older library versions.
llvm-svn: 347382
2018-11-21 08:54:40 +00:00
Dean Michael Berris
2b95e3c5cf [XRay] Add a test for re-initialising FDR mode (NFC)
This change adds an end-to-end test that ensures FDR mode can be
re-initialised safely in the face of multiple threads being traced.

llvm-svn: 347368
2018-11-21 00:30:26 +00:00
David Carlier
d931c135f0 Revert "[Sanitizer] intercept setvbuf on other platforms where it is supported"
llvm-svn: 347358
2018-11-20 22:50:31 +00:00
David Carlier
a1ea566fbc [Sanitizer] Unbreak non NetBSD builds.
llvm-svn: 347357
2018-11-20 22:35:29 +00:00
David Carlier
5ffb47b3a1 [Sanitizer] intercept setvbuf on other platforms where it is supported
Unit tests enabled only in platform tested.

Reviewers: krytarowski, vitalybuka

Reviewed By: krytarowski, vitalybuka

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

llvm-svn: 347355
2018-11-20 22:17:23 +00:00
Michal Gorny
4b0b84f4bb [cmake] Fix detecting terminfo library
Copy the fix for determining the correct terminfo library from LLVM --
use distinct variables for check_library_exists() calls.  Otherwise,
the first check (for -ltinfo) populates the variable and no other checks
are performed.  Effectively, systems with other libraries than the first
one listed are presumed not to have terminfo routines at all.

Also sync the check order to include the NetBSD fix from r347156.

This partially fixes undefined symbols when linking XRay tests.  It's
probably not the best solution to the problem there but as long
as the terminfo check stays in config-ix, I thnk it's worth fixing.

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

llvm-svn: 347338
2018-11-20 18:41:11 +00:00
Vitaly Buka
afedb893a6 [tsan] Add __cxa_guard_acquire hooks to support cooperative scheduling
Reviewers: dvyukov

Subscribers: krytarowski, kubamracek, llvm-commits

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

llvm-svn: 347336
2018-11-20 18:21:42 +00:00
Dean Michael Berris
388af45f18 [XRay] Add a test for allocator exhaustion
Use a more representative test of allocating small chunks for
oddly-sized (small) objects from an allocator that has a page's worth of
memory.

llvm-svn: 347286
2018-11-20 03:56:04 +00:00
Dean Michael Berris
ba02cb58cf [XRay] Move buffer extents back to the heap
Summary:
This change addresses an issue which shows up with the synchronised race
between threads writing into a buffer, and another thread reading the
buffer.

In a lot of cases, we cannot guarantee that threads will always see the
signal to finalise their buffers in time despite the grace periods and
state machine maintained through atomic variables. This change addresses
it by ensuring that the same instance being updated to indicate how much
of the buffer is "used" by the writing thread is the same instance being
read by the thread processing the buffer to be written out to disk or
handled through the iterators.

To do this, we ensure that all the "extents" instances live in their own
the backing store, in a different contiguous page from the
buffer-specific backing store. We also take precautions to ensure that
the atomic variables are cache-line-sized to prevent false-sharing from
unnecessarily causing cache contention on unrelated writes/reads.

It's feasible that we may in the future be able to move the storage of
the extents objects into the single backing store, slightly changing the
way to compute the size(s) of the buffers, but in the meantime we'll
settle for the isolation afforded by having a different backing store
for the extents instances.

Reviewers: mboerger

Subscribers: jfb, llvm-commits

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

llvm-svn: 347280
2018-11-20 01:00:26 +00:00
Petr Hosek
8e0e35a3f5 [compiler-rt] Use zx_futex_wait_deprecated for Fuchsia sanitizer runtime
This change is part of the soft-transition to the new synchronization
primitives which implement priority inheritance.

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

llvm-svn: 347279
2018-11-20 00:55:20 +00:00
Kamil Rytarowski
74abaf8cdc Add interceptor for the setvbuf(3) from NetBSD
Summary:
setvbuf(3) is a routine to setup stream buffering.

Enable the interceptor for NetBSD.

Add dedicated tests for setvbuf(3) and functions
on top of this interface: setbuf, setbuffer, setlinebuf.

Based on original work by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: devnexen, tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 347270
2018-11-19 22:44:26 +00:00
Kostya Serebryany
0e799d92fd [hwasan] don't check tail magic when in right_align mode (should fix the bot)
llvm-svn: 347121
2018-11-17 01:02:09 +00:00
Kostya Serebryany
b5c1d69e40 [hwasan] make the heap-buffer-overflow.c test more robust and re-enable it. With malloc_align_right the relative offsets of heap chunks are less predictable to simply don't test for them.
llvm-svn: 347118
2018-11-17 00:40:34 +00:00
Kostya Serebryany
c265e7673d [hwasan] implement free_checks_tail_magic=1
Summary:
With free_checks_tail_magic=1 (default) HWASAN
writes magic bytes to the tail of every heap allocation
(last bytes of the last granule, if the last granule is not fully used)
and checks these bytes on free().

This feature will detect buffer overwires within the last granule
at the time of free().

This is an alternative to malloc_align_right=[1289] that should have
fewer compatibility issues. It is also weaker since it doesn't
detect read overflows and reports bugs at free() instead of at access.

Reviewers: eugenis

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 347116
2018-11-17 00:25:17 +00:00
Kostya Serebryany
31b6a14a99 [hwasan] use reads instead of writes in a test
llvm-svn: 347107
2018-11-16 23:01:42 +00:00
Kamil Rytarowski
003b720873 Revert "Cast the 2nd argument of _Unwind_SetIP() to _Unwind_Ptr"
_Unwind_Ptr is unknown on some targets.

Detected on green-dragon-21 (MacPro Late 2013 | OS X 10.14(18A391) | Xcode 10.1(10B61)).

llvm-svn: 347106
2018-11-16 23:00:28 +00:00
Kamil Rytarowski
54eaafafbf Cast the 2nd argument of _Unwind_SetIP() to _Unwind_Ptr
This modification is require for NetBSD with GCC, as there is a
custom unwind.h header implementation with different types.

No functional change intended for others.

Cherry-picked chunk from D33878.

llvm-svn: 347102
2018-11-16 22:17:36 +00:00
Kamil Rytarowski
7461cc12fc Cast _Unwind_GetIP() and _Unwind_GetRegionStart() to uintptr_t
This modification is require for NetBSD with GCC, as there is a
custom unwind.h header implementation with different types.

No functional change intended for others.

Cherry-picked chunk from D33878.

llvm-svn: 347101
2018-11-16 22:15:09 +00:00
Vitaly Buka
c505ceeb3c [sanitizer] Update global_symbols.txt
llvm-svn: 347099
2018-11-16 21:42:22 +00:00
Kostya Serebryany
f5912d0ef2 [hwasan] disable one test line while investigating a bot failure
llvm-svn: 347091
2018-11-16 20:35:07 +00:00
Kamil Rytarowski
56ef906532 Add new interceptor for mi_vector_hash(3)
Summary:
mi_vector_hash(3) provides fast 32bit hash functions.

Add a test for this interface.

Enable the API for NetBSD.

Based on original work by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 347088
2018-11-16 19:54:13 +00:00
Kamil Rytarowski
47fb42e6c3 Add new interceptor for getmntinfo(3) from NetBSD
Summary:
getmntinfo gets information about mounted file systems.

Add a dedicated test for new interceptor.

Based on original work by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 347083
2018-11-16 19:47:42 +00:00
Kostya Serebryany
ba5c7169c5 [hwasan] optionally right-align heap allocations
Summary:
... so that we can find intra-granule buffer overflows.
The default is still to always align left.
It remains to be seen wether we can enable this mode at scale.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: jfb, dvyukov, kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 347082
2018-11-16 19:38:48 +00:00
Petr Hosek
5f5c773765 [compiler-rt] Use exact spelling when building for default target
When building for default target only, use exact target spelling
when deriving the name for the per-target runtime directory. This
is necessary for AArch32 where the CMake build by default rewrites
the architecture which leads to unexpected results.

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

llvm-svn: 347022
2018-11-16 04:14:23 +00:00
Dan Liew
ee6eb9b25a Start adding the supporting code to perform out-of-process allocator
enumeration.

Summary:

This patch introduces the local portion (`LocalAddressSpaceView`) of the
`AddressSpaceView` abstraction and modifies the secondary allocator
so that the `ForEachChunk()` method (and its callees) would work in the
out-of-process case when `AddressSpaceView` is `RemoteAddressSpaceView`.

The `AddressSpaceView` abstraction simply maps pointers from a target
process to a pointer in the local process (via its `Load()` method). For
the local (in-process) case this is a no-op. For the remote
(out-of-process) case this is not a no-op. The implementation of the
out-of-process `RemoteAddressSpaceView` is not included in this patch
and will be introduced later.

This patch is considerably simpler than the `ObjectView` abstraction
used in previous patches but lacks the type safety and stricter memory
management of the `ObjectView` abstraction.

This patch does not introduce any tests because with
`LocalAddressSpaceView` it should be a non functional change and unit
tests already cover the secondary allocator.  When
`RemoteAddressSpaceView` is landed tests will be added to ensure that it
functions as expected.

rdar://problem/45284065

Reviewers: kcc, kubamracek, dvyukov, vitalybuka, cryptoad,
george.karpenkov, morehouse

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 346956
2018-11-15 14:20:28 +00:00
Petr Hosek
2d2e23e89b [CMake] Passthrough CFLAGS when checking the compiler-rt path
This is needed when cross-compiling for a different target since
CFLAGS may contain additional flags like -resource-dir which
change the location in which compiler-rt builtins are found.

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

llvm-svn: 346820
2018-11-14 00:09:26 +00:00
George Karpenkov
6fd29477c3 [lsan] [FIXUP] Fixup for http://reviews.llvm.org/D54484
After the change, the tests started failing, as skipped sections can be
equal in size to kMaxSegName.
Changing `<` to `<=` to address the off-by-one problem.

llvm-svn: 346804
2018-11-13 22:17:16 +00:00
George Karpenkov
2e8839de7c [lsan] [NFC] Change ARRAY_SIZE to internal_strnlen
Calling ARRAY_SIZE on a char* will not actually compute it's size, but just the pointer size.
A new Clang warning enabled by default warns about this.

Replaced the call with internal_strnlen.

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

llvm-svn: 346792
2018-11-13 20:19:38 +00:00