Insert poisoned paddings between fields in C++ classes so that AddressSanitizer can...
authorKostya Serebryany <kcc@google.com>
Thu, 16 Oct 2014 20:54:52 +0000 (20:54 +0000)
committerKostya Serebryany <kcc@google.com>
Thu, 16 Oct 2014 20:54:52 +0000 (20:54 +0000)
commit293dc9be6e3660377141b5998ee2987c3104e980
treeaf584d5d8dde96d893932cd10cefd1ca7f9a75dd
parent899ded9cdf53b3d84c8d0e771851cc256296bfd2
Insert poisoned paddings between fields in C++ classes so that AddressSanitizer can find intra-object-overflow bugs

Summary:
The general approach is to add extra paddings after every field
in AST/RecordLayoutBuilder.cpp, then add code to CTORs/DTORs that poisons the paddings
(CodeGen/CGClass.cpp).

Everything is done under the flag -fsanitize-address-field-padding.
The blacklist file (-fsanitize-blacklist) allows to avoid the transformation
for given classes or source files.

See also https://code.google.com/p/address-sanitizer/wiki/IntraObjectOverflow

Test Plan: run SPEC2006 and some of the Chromium tests with  -fsanitize-address-field-padding

Reviewers: samsonov, rnk, rsmith

Reviewed By: rsmith

Subscribers: majnemer, cfe-commits

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

llvm-svn: 219961
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/SanitizerBlacklist.h
clang/lib/AST/Decl.cpp
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Basic/SanitizerBlacklist.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/sanitize-address-field-padding.cpp [new file with mode: 0644]