diff options
author | Vedant Kumar <vsk@apple.com> | 2017-06-01 19:22:18 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-06-01 19:22:18 +0000 |
commit | a125eb55cb6050cba7412a5dbbfe80ca6ad4d79f (patch) | |
tree | 8db5dd9dab5a7fddf9a8ca3ddf74fcce50fe1afd /llvm/lib/Bitcode | |
parent | 532a9e888a6e759c044ea34f3b0d01113ff6d6be (diff) | |
download | bcm5719-llvm-a125eb55cb6050cba7412a5dbbfe80ca6ad4d79f.tar.gz bcm5719-llvm-a125eb55cb6050cba7412a5dbbfe80ca6ad4d79f.zip |
[ubsan] Add a check for pointer overflow UB
Check pointer arithmetic for overflow.
For some more background on this check, see:
https://wdtz.org/catching-pointer-overflow-bugs.html
https://reviews.llvm.org/D20322
Patch by Will Dietz and John Regehr!
This version of the patch is different from the original in a few ways:
- It introduces the EmitCheckedInBoundsGEP utility which inserts
checks when the pointer overflow check is enabled.
- It does some constant-folding to reduce instrumentation overhead.
- It does not check some GEPs in CGExprCXX. I'm not sure that
inserting checks here, or in CGClass, would catch many bugs.
Possible future directions for this check:
- Introduce CGF.EmitCheckedStructGEP, to detect overflows when
accessing structures.
Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.
Differential Revision: https://reviews.llvm.org/D33305
llvm-svn: 304459
Diffstat (limited to 'llvm/lib/Bitcode')
0 files changed, 0 insertions, 0 deletions