Commit Graph

205 Commits

Author SHA1 Message Date
David Majnemer 3400563ea6 UBSan: Teach isDerivedFromAtOffset and findBaseAtOffset about vbases
When the __virtual_mask is set, __offset_flags >> __offset_shift yields
an offset into the vtable.  Dereferencing this vtable slot gets us the
vbase offset.

Adjust a test case to verify that this, in fact, works.

Differential Revision: http://reviews.llvm.org/D6074

llvm-svn: 221445
2014-11-06 08:55:23 +00:00
Renato Golin 6d41f7ae22 UBSAN stable runtime more generic with arm* targets
llvm-svn: 219924
2014-10-16 12:43:10 +00:00
Renato Golin 45abb8c969 Adds stable-runtime to ubsan to avoid broken ARM tests with asan
llvm-svn: 219906
2014-10-16 07:48:27 +00:00
Renato Golin 498b223eec Re-enable ASAN/UBSAN tests on ARM, with VFP3 they began to pass
When compiling with -mfpu=vfpv3, those tests began to pass, like the others
with "Illegal Instruction" error, so removing the XFAIL from them should
get the bot green (and have more tests!).

llvm-svn: 219721
2014-10-14 21:00:22 +00:00
Alexey Samsonov 37efdf0033 [UBSan] XFAIL test added in r219642 on Darwin
llvm-svn: 219699
2014-10-14 17:31:15 +00:00
Alexey Samsonov eb47d8a2c8 Sanitize upcasts and conversion to virtual base.
This change adds UBSan check to upcasts. Namely, when we
perform derived-to-base conversion, we:
1) check that the pointer-to-derived has suitable alignment
   and underlying storage, if this pointer is non-null.
2) if vptr-sanitizer is enabled, and we perform conversion to
   virtual base, we check that pointer-to-derived has a matching vptr.

llvm-svn: 219642
2014-10-13 23:59:00 +00:00
Chandler Carruth 30bdfa7f99 [UBSan] Disable one run line of this test to allow the test as a whole
to pass in an opt build.

The test case in question does show UBSan catching the error, but it
doesn't then successfully set the exit code of the program. I'll let the
UBSan folks sort out why. It should reproduce trivially with an
optimized build.

llvm-svn: 219563
2014-10-11 06:49:00 +00:00
Alexey Samsonov 19c2e631bd [UBSan] Fix UBSan testcase for float->int conversion after LLVM r219542.
llvm-svn: 219559
2014-10-11 01:34:16 +00:00
Renato Golin 1a8093c3a7 Disabling main() check on UBSAN, since the noreturn check is already made
llvm-svn: 219488
2014-10-10 10:26:14 +00:00
Renato Golin e68963a986 XFAIL some more sanitiser ARMv7l tests
Some more tests failing on the ARMv7 buildbot.

llvm-svn: 219404
2014-10-09 11:34:40 +00:00
Renato Golin 1aaa4bcdd1 Mark sanitizer tests XFAIL on ARMv7
ASAN, UBSAN and profile tests that don't work with arm-linux-gnueabi and
android also don't work on armv7l-linux-gnueabihf. Some of the tests have
known causes, others not yet. In order to get a green bot, I'm disabling
those tests for now and will investigate when the priority rises.

llvm-svn: 219343
2014-10-08 21:13:23 +00:00
Alexander Potapenko 79dc4420f0 Disable the ubsan-asan config on Darwin.
UBSan doesn't work together with ASan on Darwin yet, see http://llvm.org/bugs/show_bug.cgi?id=21112

llvm-svn: 218746
2014-10-01 08:53:00 +00:00
Alexander Potapenko d775f3b5f0 [UBsan] Disable summary.cpp on Darwin. The test requires ubsan-asan, which does not work yet.
llvm-svn: 218675
2014-09-30 13:55:44 +00:00
Alexander Potapenko a3d4131cd5 [UBSan] Use <machine/endian.h> on Darwin.
llvm-svn: 218662
2014-09-30 10:07:37 +00:00
Petar Jovanovic c2e0427b94 [UBSan] Adding support of MIPS32
Changed files: 
config-ix.cmake: Enabled UBSan for MIPS32
sanitizer_stacktrace.cc: Program counter for MIPS32 is four byte aligned
and a delay slot so subtracted PC by 8 for getting call site address.
cast-overflow.cpp: Added big endian support for this test case.

Patch by Sagar Thakur.

Differential Revision: http://reviews.llvm.org/D4881

llvm-svn: 218519
2014-09-26 14:16:06 +00:00
Alexey Samsonov 7dd95610e5 UBSan: print 'undefined-behavior' instead of 'runtime-error' in report summary
llvm-svn: 218264
2014-09-22 19:39:46 +00:00
Alexey Samsonov 25c2224922 [UBSan] Introduce more flexible __ubsan_default_options function instead of UBSAN_DEFAULT_OPTIONS compile definition
llvm-svn: 218137
2014-09-19 18:54:52 +00:00
Alexey Samsonov 760750c44f [UBSan] Optionally report summary in UBSan error reports.
By default summary is not printed if UBSan is run in a standalone mode,
but is printed if it's combined with another sanitizer (like ASan).

llvm-svn: 218135
2014-09-19 18:33:45 +00:00
Alexey Samsonov 1947bf9921 PR20721: Don't let UBSan print inaccessible memory
Summary:
UBSan needs to check if memory snippet it's going to print resides
in addressable memory. Similar check might be helpful in ASan with
dump_instruction_bytes option (see http://reviews.llvm.org/D5167).

Instead of scanning /proc/self/maps manually, delegate this check to
the OS kernel: try to write this memory in a syscall and assume that
memory is inaccessible if the syscall failed (e.g. with EFAULT).

Fixes PR20721.

Test Plan: compiler-rt test suite

Reviewers: eugenis, glider

Reviewed By: glider

Subscribers: emaste, ygribov, llvm-commits, glider, rsmith

Differential Revision: http://reviews.llvm.org/D5253

llvm-svn: 217971
2014-09-17 17:56:15 +00:00
Alexey Samsonov 74f07ed7fe Revert r217616. Problems and complexity it introduces negate its benefit
llvm-svn: 217652
2014-09-12 01:26:57 +00:00
Alexey Samsonov 5d2c0dfe4c [UBSan] Parse common flags from UBSAN_OPTIONS runtime variable even if
UBSan is combined with ASan.

llvm-svn: 217616
2014-09-11 18:20:11 +00:00
Alexey Samsonov b69d5dffc3 [UBSan] Add halt_on_error runtime flag
llvm-svn: 217535
2014-09-10 19:35:31 +00:00
Alexey Samsonov 90452df7b1 Report source location of returns_nonnull attribute in UBSan reports.
llvm-svn: 217400
2014-09-08 20:17:19 +00:00
Alexey Samsonov 8e1162c71d Implement nonnull-attribute sanitizer
Summary:
This patch implements a new UBSan check, which verifies
that function arguments declared to be nonnull with __attribute__((nonnull))
are actually nonnull in runtime.

To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs
(where applicable) and if function declaration has nonnull attribute specified
for a certain formal parameter, we compare the corresponding RValue to null as
soon as it's calculated.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rnk

Differential Revision: http://reviews.llvm.org/D5082

llvm-svn: 217389
2014-09-08 17:22:45 +00:00
Alexander Potapenko 2164fa3b9b [ubsan] Follow-up for r216657: fixed the line numbers in the test.
llvm-svn: 216661
2014-08-28 10:25:17 +00:00
Alexander Potapenko 53cce89a81 [UBSan] Temporarily disable checks for stack traces in UBSan reports on Darwin
to make the tests green.
Slow stack unwinding is disabled in libsanitizer on Darwin now.

llvm-svn: 216657
2014-08-28 09:25:06 +00:00
Alexey Samsonov 2ccbc621df [UBSan] Add support for printing backtraces to all UBSan handlers
llvm-svn: 216289
2014-08-22 21:42:04 +00:00
Alexander Potapenko ea2402ebf4 [ubsan] Follow-up for r216263: fix the expected line number.
llvm-svn: 216266
2014-08-22 12:44:16 +00:00
Alexander Potapenko 66ae9712c5 [ubsan] Do not run Function/function.cpp on Darwin where -fsanitize=function is not supported.
llvm-svn: 216263
2014-08-22 11:09:10 +00:00
Alexey Samsonov de443c5002 [UBSan] Add returns-nonnull sanitizer.
Summary:
This patch adds a runtime check verifying that functions
annotated with "returns_nonnull" attribute do in fact return nonnull pointers.
It is based on suggestion by Jakub Jelinek:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140623/223693.html.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4849

llvm-svn: 215485
2014-08-13 00:26:40 +00:00
Alexey Samsonov 68b9e74592 [CMake] Determine which compiler-rt libraries are supported on
a given platform in a top-level CMakeLists.txt to use it both
in lib/ and in test/ subdirectories. Move architecture/platform
checks to config-ix.

llvm-svn: 215247
2014-08-08 22:01:20 +00:00
Alexander Kornienko c3f7bcbd48 The test doesn't export ASAN_OPTIONS, so $ASAN_OPTIONS should not be used in RUN lines.
llvm-svn: 214855
2014-08-05 11:12:23 +00:00
Alexey Samsonov ff24fd2516 [UBSan] Allow to suppress reports from vptr checker for specified types.
Based on http://reviews.llvm.org/D4702 by Byoungyoung Lee!

llvm-svn: 214833
2014-08-05 01:24:22 +00:00
Alexey Samsonov 8b9d18e4fe [UBSan] Try to enable pipefail in UBSan lit tests to make them behave more predictably
llvm-svn: 214149
2014-07-29 00:30:01 +00:00
Alexey Samsonov bfa711c8b0 [UBSan] Add the ability to dump call stacks to -fsanitize=vptr
This change introduces the first UBSan-specific runtime flag: print_stacktrace
(off by default). It can be set in UBSAN_OPTIONS to unwind and print call stacks
in addition to diagnostic messages. For now these stacks are printed only
in vptr checker.

This change is based on http://reviews.llvm.org/D4410 by Byoungyoung Lee!

llvm-svn: 213783
2014-07-23 18:44:54 +00:00
Alexey Samsonov cd875aa551 [UBSan] Introduce UBSAN_OPTIONS environment variable.
If UBSan is run in a standalone mode (w/o any other sanitizer), it
still uses functions from sanitizer_common, some of which depend on
the value of runtime flags. Allow to override the default values of these
flags with UBSAN_OPTIONS variable. In particular, UBSAN_OPTIONS=symbolize=0
can be used to turn off online symbolization.

llvm-svn: 213782
2014-07-23 18:32:55 +00:00
Greg Fitzgerald 11b49c3818 light up sanitizers for ARM, take 2
Differential Revision: http://reviews.llvm.org/D3794

llvm-svn: 209856
2014-05-29 22:38:13 +00:00
Greg Fitzgerald c1146ec5ba Revert "light up sanitizers for ARM"
This commit broke the Windows build, where CMAKE_C_COMPILER can
compile and link with -march=armv7-a but the just-built-clang
cannot.

llvm-svn: 209851
2014-05-29 21:33:36 +00:00
Greg Fitzgerald 32685ec5fd light up sanitizers for ARM
You can expect the sanitizers to be built under any of the following conditions:

1) CMAKE_C_COMPILER is GCC built to cross-compile to ARM
2) CMAKE_C_COMPILER is Clang built to cross-compile to ARM (ARM is default target)
3) CMAKE_C_COMPILER is Clang and CMAKE_C_FLAGS contains -target and --sysroot

Differential Revision: http://reviews.llvm.org/D3794

llvm-svn: 209835
2014-05-29 19:01:32 +00:00
Kostya Serebryany ef769fac90 [ubsan] temporary disable testing with -m32 as there are bots that don't support it
llvm-svn: 209517
2014-05-23 15:02:06 +00:00
Kostya Serebryany a72efdff9e [ubsan] handle long double in 32-bit mode; part of the patch by Marek Polacek
llvm-svn: 209516
2014-05-23 14:45:13 +00:00
Greg Fitzgerald 38ff567743 [ubsan] fix vptr test on ARM
Differential Revision: http://reviews.llvm.org/D3751

llvm-svn: 209249
2014-05-20 22:07:58 +00:00
Greg Fitzgerald 5a1cf70ac3 removed redundant lit variable
Thanks Alexey!

llvm-svn: 208747
2014-05-14 01:04:17 +00:00
Greg Fitzgerald 320713ffbe Add target flags to ubsan tests
llvm-svn: 208746
2014-05-14 00:46:01 +00:00
Greg Fitzgerald 1402830dc5 Add %run to tests that used %T/name.exe
llvm-svn: 208744
2014-05-14 00:32:15 +00:00
Greg Fitzgerald b8aae5405b Add %run to all lit tests
llvm-svn: 207709
2014-04-30 21:34:17 +00:00
Greg Fitzgerald 6759fd9fdd Allow any test to be executed via a %run command.
Configure %run with COMPILER_RT_EMULATOR:

  $ cmake -DCOMPILER_RT_EMULATOR="qemu-arm -L $SYSROOT"

llvm-svn: 207707
2014-04-30 21:32:30 +00:00
Kostya Serebryany c9db838267 [asan] enable LeakSanitizer (LSan) by default in asan. This only affects Linux x86_64. LSan has been used in various projects for more than half a year and we now consider it quite stable to be on by default.
llvm-svn: 206896
2014-04-22 13:56:56 +00:00
Alexey Samsonov 5e6d83258e [CMake] lit tests shouldn't depend on runtimes in standalone build
llvm-svn: 201771
2014-02-20 09:47:18 +00:00
Alexey Samsonov 31043152d3 Add rudimentary support for running compiler-rt lit tests with GCC
llvm-svn: 201680
2014-02-19 15:13:14 +00:00
Alexey Samsonov 2769570556 Simplify lit test configs for LSan and UBSan by using a generic config
llvm-svn: 201553
2014-02-18 08:56:49 +00:00
Alexey Samsonov 4dcbe7e959 Remove debug print
llvm-svn: 201544
2014-02-18 07:30:37 +00:00
Alexey Samsonov 1c9b9bcb5c Simplify defining Clang compile flags in lit configs
llvm-svn: 201513
2014-02-17 13:08:10 +00:00
Alexey Samsonov 9a70077b47 [ASan] Rename asan_runtime_libraries to asan. Re-enable tests on Android.
llvm-svn: 201417
2014-02-14 14:45:13 +00:00
Alexey Samsonov ba869e79a0 Move UBSan test suite under test/
llvm-svn: 201401
2014-02-14 11:42:22 +00:00