[compiler-rt][UBSan] Sanitization for alignment assumptions.
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 15 Jan 2019 09:44:27 +0000 (09:44 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 15 Jan 2019 09:44:27 +0000 (09:44 +0000)
commita06ad18669f85b21df9ce9e4847c4b899692fb9b
treed2127fee7afa9d728cac2b5a8373b7ccb00200c0
parentbd1c0870198e025f92d31eead0fb2019c4057a4a
[compiler-rt][UBSan] Sanitization for alignment assumptions.

Summary:
This is the compiler-rt part.
The clang part is D54589.

This is a second commit, the original one was r351106,
which was mass-reverted in r351159 because 2 compiler-rt tests were failing.

Now, i have fundamentally changed the testing approach:
i malloc a few bytes, intentionally mis-align the pointer
(increment it by one), and check that. Also, i have decreased
the expected alignment. This hopefully should be enough to pacify
all the bots. If not, i guess i might just drop the two 'bad' tests.

Reviewers: filcab, vsk, #sanitizers, vitalybuka, rsmith, morehouse

Reviewed By: morehouse

Subscribers: rjmccall, krytarowski, rsmith, kcc, srhines, kubamracek, dberris, llvm-commits

Tags: #sanitizers

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

llvm-svn: 351178
20 files changed:
compiler-rt/lib/ubsan/ubsan_checks.inc
compiler-rt/lib/ubsan/ubsan_handlers.cc
compiler-rt/lib/ubsan/ubsan_handlers.h
compiler-rt/lib/ubsan/ubsan_interface.inc
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc
compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp [new file with mode: 0644]
compiler-rt/test/fuzzer/fuzzer-alignment-assumption.test [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-align_value-on-lvalue.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-align_value-on-paramvar.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-alloc_align-on-function-variable.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-alloc_align-on-function.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-attribute-assume_aligned-on-function.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-builtin_assume_aligned-three-params-variable.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-builtin_assume_aligned-three-params.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-builtin_assume_aligned-two-params.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-openmp.cpp [new file with mode: 0644]
compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-summary.cpp [new file with mode: 0644]
compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c [new file with mode: 0644]