OSDN Git Service

Add an unsigned shift base sanitizer
authorJF Bastien <jfbastien@apple.com>
Fri, 14 Aug 2020 21:05:57 +0000 (14:05 -0700)
committerJF Bastien <jfbastien@apple.com>
Fri, 28 Aug 2020 02:50:10 +0000 (19:50 -0700)
commit82d29b397bb24c6a9e5c41401278886f4614e544
tree838e1d5f9e2dedfb615cc3fce7c7a6b226c6b44b
parent832c8a72988a3d5889a1ae16322df39f0215d5a2
Add an unsigned shift base sanitizer

It's not undefined behavior for an unsigned left shift to overflow (i.e. to
shift bits out), but it has been the source of bugs and exploits in certain
codebases in the past. As we do in other parts of UBSan, this patch adds a
dynamic checker which acts beyond UBSan and checks other sources of errors. The
option is enabled as part of -fsanitize=integer.

The flag is named: -fsanitize=unsigned-shift-base
This matches shift-base and shift-exponent flags.

<rdar://problem/46129047>

Differential Revision: https://reviews.llvm.org/D86000
clang/docs/UndefinedBehaviorSanitizer.rst
clang/include/clang/Basic/Sanitizers.def
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Driver/ToolChain.cpp
clang/test/CodeGen/unsigned-shift-base.c [new file with mode: 0644]
clang/test/Driver/fsanitize.c
compiler-rt/test/ubsan/TestCases/Integer/unsigned-shift.cpp [new file with mode: 0644]
llvm/docs/ReleaseNotes.rst