Commit Graph

11084 Commits

Author SHA1 Message Date
Vitaly Buka
cdecca0324 Revert "[asan] Disable test on powerpc64be"
Now the test is passing on that bot. Some incremental build issues?

This reverts commit e00b5a5229ae02088d9f32a4e328eaa08abaf354.

llvm-svn: 349852
2018-12-20 23:25:26 +00:00
Vitaly Buka
5bcd4e8876 [asan] Disable test on powerpc64be
llvm-svn: 349844
2018-12-20 22:29:54 +00:00
Evgeniy Stepanov
3b7e8b2dbb [sanitizer] Support running without fd 0,1,2.
Summary:
Support running with no open file descriptors (as may happen to
"init" process on linux).
* Remove a check that writing to stderr succeeds.
* When opening a file (ex. for log_path option), dup the new fd out of
[0, 2] range to avoid confusing the program.

(2nd attempt, this time without the sanitizer_rtems change)

Reviewers: pcc, vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 349817
2018-12-20 20:36:33 +00:00
David Carlier
22594ae962 [Sanitizer] Enable vis api on FreeBSD
Reviewers: krytarowski

Reviewed By: krytarowski

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

llvm-svn: 349762
2018-12-20 14:25:43 +00:00
Ilya Biryukov
ea8646ad66 Revert "[sanitizer] Support running without fd 0,1,2."
This reverts commit r349699.
Reason: the commit breaks compilation of sanitizer_rtems.cc when
building for RTEMS.

llvm-svn: 349745
2018-12-20 12:50:03 +00:00
Vitaly Buka
5538115092 [asan] Revert still Androind incompatible tests enabled in r349736
llvm-svn: 349740
2018-12-20 10:56:34 +00:00
Vitaly Buka
cd51ffa290 [asan] Fix and re-enable few test on Android
llvm-svn: 349736
2018-12-20 10:15:51 +00:00
Eugene Leviant
d3bd614856 [HWASAN] Add support for memory intrinsics
This is patch complements D55117 implementing __hwasan_mem*
functions in runtime

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

llvm-svn: 349730
2018-12-20 09:10:03 +00:00
Evgeniy Stepanov
17e705129e Remove pointless casts.
llvm-svn: 349717
2018-12-20 01:49:21 +00:00
Vitaly Buka
a938b9dd3e [asan] Disable test incompatible with new Android
llvm-svn: 349705
2018-12-20 00:24:09 +00:00
Evgeniy Stepanov
f762a9f8f0 [sanitizer] Support running without fd 0,1,2.
Summary:
Support running with no open file descriptors (as may happen to
"init" process on linux).
* Remove a check that writing to stderr succeeds.
* When opening a file (ex. for log_path option), dup the new fd out of
[0, 2] range to avoid confusing the program.

Reviewers: pcc, vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 349699
2018-12-19 23:45:17 +00:00
Kostya Kortchinsky
ebaba9df3a [sanitizer] Remove spurious semi-colon
Summary:
An extra ';' at the end of a namespace triggers a pedantic warning:
```
.../sanitizer_common/sanitizer_type_traits.h:42:2: warning: extra ‘;’ [-Wpedantic]
 };  // namespace __sanitizer
```

Reviewers: eugenis, delcypher

Reviewed By: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

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

llvm-svn: 349666
2018-12-19 19:05:29 +00:00
Michal Gorny
0f71c17e7c [sanitizer_common] Fix sha2 interceptors not to use vars in array len
Fix the sha2 interceptor macros to use a constant for array parameter
length rather than referencing the extern variable.  Since the digest
length is provided in hash name, reuse the macro parameter for it.
Verify that the calculated value matches the one provided by system
headers.

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

llvm-svn: 349645
2018-12-19 17:22:14 +00:00
Amy Kwan
6c735b02f1 [compiler-rt][builtins][PowerPC] Enable builtins tests on PowerPC 64 bit LE
This patch aims to enable the tests for the compiler-rt builtin functions (that
currently already exist within compiler-rt) for PowerPC 64bit LE (ppc64le).
Previously when unit tests are run, these tests would be reported as
UNSUPPORTED. This patch updates the REQUIRES line for each test (to enable for
ppc64le), and each test is linked against compiler-rt when running.

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

llvm-svn: 349634
2018-12-19 15:52:41 +00:00
Kamil Rytarowski
342d03e71f Reimplement Thread Static Data ASan routines with TLS
Summary:
Thread Static Data cannot be used in early init on NetBSD
and FreeBSD. Reuse the ASan TSD API for compatibility with
existing code with an alternative implementation using Thread
Local Storage.

New version uses Thread Local Storage to store a pointer
with thread specific data. The destructor from TSD has been
replaced with a TLS destrucutor that is called upon thread
exit.

Reviewers: joerg, vitalybuka, jfb

Reviewed By: vitalybuka

Subscribers: dim, emaste, ro, jfb, devnexen, kubamracek, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 349619
2018-12-19 11:11:29 +00:00
Dmitry Vyukov
2ba80d6df6 tsan: align default value of detect_deadlocks flag with actual behavior
I tricked myself into thinking that deadlock detection is off by default in TSan by looking at the default value of the detect_deadlocks flag and outdated docs. (Created a pull request to update docs.)
I even managed to confuse others: https://groups.google.com/forum/#!topic/thread-sanitizer/xYvnAYwtoDk

However, the default value is overwritten in code (TSan_flags.cc:InitializeFlags). The TSan/deadlock tests also rely on this

This changes aligns the default value of the flag with the actual default behavior.

Author: yln (Julian Lettner)
Reviewed in: https://reviews.llvm.org/D55846

llvm-svn: 349609
2018-12-19 09:34:13 +00:00
Vitaly Buka
6471f72a63 [asan] Disable ODR test on Android
llvm-svn: 349585
2018-12-19 00:07:25 +00:00
Vitaly Buka
4e4920694c [asan] Restore ODR-violation detection on vtables
Summary:
unnamed_addr is still useful for detecting of ODR violations on vtables

Still unnamed_addr with lld and --icf=safe or --icf=all can trigger false
reports which can be avoided with --icf=none or by using private aliases
with -fsanitize-address-use-odr-indicator

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: kubamracek, hiraditya, llvm-commits

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

llvm-svn: 349555
2018-12-18 22:23:30 +00:00
Nico Weber
cfa54fb456 Fix a gcc -Wpedantix warning
llvm-svn: 349492
2018-12-18 15:17:01 +00:00
Peter Collingbourne
44ea4f5744 hwasan: Allow range of frame descriptors to be empty.
As of r349413 it's now possible for a binary to contain an empty
hwasan frame section. Handle that case simply by doing nothing.

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

llvm-svn: 349428
2018-12-18 00:48:07 +00:00
Dan Liew
b85b15d64a Don't trigger sanitizer initialization from sysctlbyname and sysctl interceptor.
Summary:
This fixes the `ThreadSanitizer-x86_64-iossim` testsuite which broke
when r348770 (https://reviews.llvm.org/D55473) landed.

The root cause of the problem is that early-on during the iOS simulator
init process a call to `sysctlbyname` is issued. If the TSan initializer
is triggered at this point it will eventually trigger a call to
`__cxa_at_exit(...)`. This call then aborts because the library
implementing this function is not yet had its initialization function
called.

rdar://problem/46696934

Reviewers: kubamracek, george.karpenkov, devnexen, vitalybuka, krytarowski

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 349402
2018-12-17 21:42:55 +00:00
David Carlier
34144f5ec0 [Sanitizer] capsicum variadic api subset
Reviewers: markj, vitalybuka

Reviewed By: markj

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

llvm-svn: 349392
2018-12-17 20:57:06 +00:00
Kamil Rytarowski
ca72239534 Improve the comment in previous
llvm-svn: 349296
2018-12-16 10:24:06 +00:00
Kamil Rytarowski
bb66b0dac1 Expand TSan sysroot workaround to NetBSD
https://bugs.llvm.org/show_bug.cgi?id=26651

llvm-svn: 349295
2018-12-16 10:22:30 +00:00
Kamil Rytarowski
7970eccc89 Enable test/msan/pthread_getname_np.cc for NetBSD
llvm-svn: 349263
2018-12-15 10:42:14 +00:00
Kamil Rytarowski
17751e1414 Enable SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP for NetBSD
llvm-svn: 349262
2018-12-15 10:41:55 +00:00
Kamil Rytarowski
5748bb4133 Fix internal_sleep() for NetBSD
This is a follow up of a similar fix for Linux from D55692.

llvm-svn: 349257
2018-12-15 08:25:25 +00:00
Peter Collingbourne
a53bb3ac85 Fix typo in test cases as well.
llvm-svn: 349255
2018-12-15 07:08:04 +00:00
Peter Collingbourne
1ad24332d1 hwasan: Fix typo: Previosly -> Previously.
llvm-svn: 349254
2018-12-15 07:06:24 +00:00
Kostya Serebryany
1879e8d3fc [libFuzzer] make len_control less aggressive
llvm-svn: 349210
2018-12-14 23:21:31 +00:00
Kamil Rytarowski
cea79772c5 Mark interception_failure_test.cc as passing for NetBSD and asan-dynamic-runtime
llvm-svn: 349159
2018-12-14 16:26:09 +00:00
Kamil Rytarowski
2ae9783b4f Set shared_libasan_path in lit tests for NetBSD
Reuse the Linux code path.

llvm-svn: 349156
2018-12-14 15:58:05 +00:00
Dan Liew
41fec1bfc5 Introduce AddressSpaceView template parameter to SizeClassAllocator32, FlatByteMap, and TwoLevelByteMap.
Summary:
This is a follow up patch to r346956 for the `SizeClassAllocator32`
allocator.

This patch makes `AddressSpaceView` a template parameter both to the
`ByteMap` implementations (but makes `LocalAddressSpaceView` the
default), some `AP32` implementations and is used in `SizeClassAllocator32`.
The actual changes to `ByteMap` implementations and
`SizeClassAllocator32` are very simple. However the patch is large
because it requires changing all the `AP32` definitions, and users of
those definitions.

For ASan and LSan we make `AP32` and `ByteMap` templateds type that take
a single `AddressSpaceView` argument. This has been done because we will
instantiate the allocator with a type that isn't `LocalAddressSpaceView`
in the future patches. For the allocators used in the other sanitizers
(i.e. HWAsan, MSan, Scudo, and TSan) use of `LocalAddressSpaceView` is
hard coded because we do not intend to instantiate the allocators with
any other type.

In the cases where untemplated types have become templated on a single
`AddressSpaceView` parameter (e.g. `PrimaryAllocator`) their name has
been changed to have a `ASVT` suffix (Address Space View Type) to
indicate they are templated.  The only exception to this are the `AP32`
types due to the desire to keep the type name as short as possible.

In order to check that template is instantiated in the correct a way a
`static_assert(...)` has been added that checks that the
`AddressSpaceView` type used by `Params::ByteMap::AddressSpaceView` matches
the `Params::AddressSpaceView`. This uses the new `sanitizer_type_traits.h`
header.

rdar://problem/45284065

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

Subscribers: mgorny, llvm-commits, #sanitizers

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

llvm-svn: 349138
2018-12-14 09:03:18 +00:00
Fangrui Song
c4e6de2e3f [sanitizer] Fix nolibc internal_sleep
Reviewers: kubamracek, vitalybuka

Reviewed By: vitalybuka

Subscribers: delcypher, llvm-commits, #sanitizers

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

llvm-svn: 349134
2018-12-14 08:09:43 +00:00
Vlad Tsyrklevich
137e23d536 Windows ASan: Instrument _msize_base()
Summary:
A recent update to the VS toolchain in chromium [1] broke the windows
ASan bot because the new toolchain calls _msize_base() instead of
_msize() in a number of _aligned_* UCRT routines. Instrument
_msize_base() as well.

[1] https://crbug.com/914947

Reviewers: rnk, #sanitizers, vitalybuka

Reviewed By: rnk, #sanitizers, vitalybuka

Subscribers: vitalybuka, kubamracek, llvm-commits

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

llvm-svn: 349115
2018-12-14 00:39:16 +00:00
Evgeniy Stepanov
e6acf2c3b4 Revert "Switch Android from TLS_SLOT_TSAN(8) to TLS_SLOT_SANITIZER(6)"
Breaks sanitizer-android buildbot.

This reverts commit 85e02baff327e7b67ea5b47897302901abb2aa5d.

llvm-svn: 349093
2018-12-13 23:47:59 +00:00
Dan Liew
c2e2dd43f0 Implement a small subset of the C++ type_traits header inside sanitizer_common so we can avoid depending on system C++ headers.
Summary:
In particular we implement the `is_same<T,U>` templated type. This is
useful for doing compile-time comparison of types in `static_assert`s.
The plan is to use this in another patch (
https://reviews.llvm.org/D54904 ).

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

Subscribers: mgorny, #sanitizers, llvm-commits

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

llvm-svn: 349077
2018-12-13 19:55:36 +00:00
David Carlier
a4ee854259 [Sanitizer] capsicum further support of the API
Reviewers: vitalybuka, krytarowski, emaste

Reviewed By: emaste

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

llvm-svn: 349042
2018-12-13 15:05:24 +00:00
Kamil Rytarowski
0bc12879fc Add a new interceptors for cdbr(3) and cdbw(3) API from NetBSD
Summary:
cdb - formats of the constant database.

cdbr, cdbr_open, cdbr_open_mem, cdbr_entries, cdbr_get, cdbr_find,
cdbr_close - constant database access methods.

cdbw_open, cdbw_put, cdbw_put_data, cdbw_put_key, cdbw_stable_seeder,
cdbw_output, cdbw_close - creates constant databases.

Add a dedicated test for this API.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 349021
2018-12-13 10:19:00 +00:00
Kamil Rytarowski
ce86b919da Add new interceptors for vis(3) API in NetBSD
Summary:
Add interceptors for the NetBSD style of vis(3) present inside libc:

 - vis
 - nvis
 - strvis
 - stravis
 - strnvis
 - strvisx
 - strnvisx
 - strenvisx
 - svis
 - snvis
 - strsvis
 - strsnvis
 - strsvisx
 - strsnvisx
 - strsenvisx
 - unvis
 - strunvis
 - strnunvis
 - strunvisx
 - strnunvisx

Add a dedicated test verifying the installed interceptors.

Based on original work by Yang Zheng.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 349018
2018-12-13 10:14:01 +00:00
Vitaly Buka
a257639a69 [asan] Don't check ODR violations for particular types of globals
Summary:
private and internal: should not trigger ODR at all.
unnamed_addr: current ODR checking approach fail and rereport false violation if
a linker merges such globals
linkonce_odr, weak_odr: could cause similar problems and they are already not
instrumented for ELF.

Reviewers: eugenis, kcc

Subscribers: kubamracek, hiraditya, llvm-commits

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

llvm-svn: 349015
2018-12-13 09:47:39 +00:00
Evgeniy Stepanov
1020085898 [hwasan] Link ubsan_cxx to shared runtime library.
Summary: This is needed for C++-specific ubsan and cfi error reporting to work.

Reviewers: kcc, vitalybuka

Subscribers: srhines, kubamracek, mgorny, llvm-commits

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

llvm-svn: 348986
2018-12-12 22:56:00 +00:00
Ryan Prichard
b7e1cae526 Switch Android from TLS_SLOT_TSAN(8) to TLS_SLOT_SANITIZER(6)
Summary:
The TLS_SLOT_TSAN slot is available starting in N, but its location (8)
is incompatible with the proposed solution for implementing ELF TLS on
Android (i.e. bump ARM/AArch64 alignment to reserve an 8-word TCB).

Instead, starting in Q, Bionic replaced TLS_SLOT_DLERROR(6) with
TLS_SLOT_SANITIZER(6). Switch compiler-rt to the new slot.

Reviewers: eugenis, srhines, enh

Reviewed By: eugenis

Subscribers: ruiu, srhines, kubamracek, javed.absar, kristof.beyls, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 348984
2018-12-12 22:45:12 +00:00
Evgeniy Stepanov
0af6e5facd [hwasan] Verify Android TLS slot at startup.
Summary:
Add a check that TLS_SLOT_TSAN / TLS_SLOT_SANITIZER, whichever
android_get_tls_slot is using, is not conflicting with
TLS_SLOT_DLERROR.

Reviewers: rprichard, vitalybuka

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 348979
2018-12-12 22:10:52 +00:00
David Carlier
8ec89e6b16 [Sanitizer] Expand FSEEK interception to FreeBSD
Reviewers: krytarowski

Reviewed By: krytarowski

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

llvm-svn: 348888
2018-12-11 19:08:40 +00:00
Dan Liew
a94b00513f Fix bug where we'd try symbolize a second time with the same arguments.
Summary:
Fix bug where we'd try symbolize a second time with the same arguments even though symbolization failed the first time.

This looks like a long standing typo given that the guard for trying
symbolization again is to only try it if symbolization failed using
`binary` and `original_binary != binary`.

Reviewers: kubamracek, glider, samsonov

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 348841
2018-12-11 12:43:44 +00:00
Yi Kong
a140d5269e [builtins] Remove trailing whitespaces, NFC
Remove trailing whitespaces so that it is easier to diff the code between
div{s,d,t}f3.c

llvm-svn: 348807
2018-12-10 22:52:59 +00:00
David Carlier
2b26a98a0d [Sanitizer] expand sysctl/getmntinfo/nl_langinfo to Darwin
Reviewers: vitalybuka, krytarowski, kubamracek

Reviewed By: vitalybuka, krytarowski

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

llvm-svn: 348770
2018-12-10 16:29:30 +00:00
Kamil Rytarowski
2eb1f5432f Add data types needed for md2(3)/NetBSD interceptors
Missing part of D55469.

llvm-svn: 348747
2018-12-10 09:09:18 +00:00
Kamil Rytarowski
50bd2ec198 Add interceptors for the sha2(3) from NetBSD
Summary:
SHA224_Init, SHA224_Update, SHA224_Final, SHA224_End, SHA224_File,
SHA224_FileChunk, SHA224_Data, SHA256_Init, SHA256_Update, SHA256_Final,
SHA256_End, SHA256_File, SHA256_FileChunk, SHA256_Data, SHA384_Init,
SHA384_Update, SHA384_Final, SHA384_End, SHA384_File, SHA384_FileChunk,
SHA384_Data, SHA512_Init, SHA512_Update, SHA512_Final, SHA512_End,
SHA512_File, SHA512_FileChunk, SHA512_Data – calculates the NIST Secure
Hash Standard (version 2)

Add tests for new interceptors.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348745
2018-12-10 09:06:56 +00:00