summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-06-27 18:24:46 +0000
committerMatt Morehouse <mascasa@google.com>2018-06-27 18:24:46 +0000
commite833fe37b0abc09640c727ab55449d6e96a3e61e (patch)
treee300a41da507050af44561f2f1d23a0ebe6fe8ed /lib
parent1523dfc20a7df45eae863bbe79a3cf768e26fd2f (diff)
[UBSan] Add silence_unsigned_overflow flag.
Summary: Setting UBSAN_OPTIONS=silence_unsigned_overflow=1 will silence all UIO reports. This feature, combined with -fsanitize-recover=unsigned-integer-overflow, is useful for providing fuzzing signal without the excessive log output. Helps with https://github.com/google/oss-fuzz/issues/910. Reviewers: kcc, vsk Reviewed By: vsk Subscribers: vsk, kubamracek, Dor1s, llvm-commits Differential Revision: https://reviews.llvm.org/D48660 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/ubsan/ubsan_flags.inc3
-rw-r--r--lib/ubsan/ubsan_handlers.cc4
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/ubsan/ubsan_flags.inc b/lib/ubsan/ubsan_flags.inc
index d171a98e1..1638a054e 100644
--- a/lib/ubsan/ubsan_flags.inc
+++ b/lib/ubsan/ubsan_flags.inc
@@ -24,3 +24,6 @@ UBSAN_FLAG(bool, print_stacktrace, false,
UBSAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
UBSAN_FLAG(bool, report_error_type, false,
"Print specific error type instead of 'undefined-behavior' in summary.")
+UBSAN_FLAG(bool, silence_unsigned_overflow, false,
+ "Do not print error reports for unsigned integer overflow. "
+ "Used to provide fuzzing signal without blowing up logs.")
diff --git a/lib/ubsan/ubsan_handlers.cc b/lib/ubsan/ubsan_handlers.cc
index 59a5a6b72..b48862a9d 100644
--- a/lib/ubsan/ubsan_handlers.cc
+++ b/lib/ubsan/ubsan_handlers.cc
@@ -15,6 +15,7 @@
#if CAN_SANITIZE_UB
#include "ubsan_handlers.h"
#include "ubsan_diag.h"
+#include "ubsan_flags.h"
#include "ubsan_monitor.h"
#include "sanitizer_common/sanitizer_common.h"
@@ -118,6 +119,9 @@ static void handleIntegerOverflowImpl(OverflowData *Data, ValueHandle LHS,
if (ignoreReport(Loc, Opts, ET))
return;
+ if (!IsSigned && flags()->silence_unsigned_overflow)
+ return;
+
ScopedReport R(Opts, Loc, ET);
Diag(Loc, DL_Error, ET, "%0 integer overflow: "