forked from OSchip/llvm-project
[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 llvm-svn: 335762
This commit is contained in:
parent
d052de856d
commit
520748f01e
|
@ -180,6 +180,13 @@ will need to:
|
||||||
``UBSAN_OPTIONS=print_stacktrace=1``.
|
``UBSAN_OPTIONS=print_stacktrace=1``.
|
||||||
#. Make sure ``llvm-symbolizer`` binary is in ``PATH``.
|
#. Make sure ``llvm-symbolizer`` binary is in ``PATH``.
|
||||||
|
|
||||||
|
Silencing Unsigned Integer Overflow
|
||||||
|
===================================
|
||||||
|
To silence reports from unsigned integer overflow, you can set
|
||||||
|
``UBSAN_OPTIONS=silence_unsigned_overflow=1``. This feature, combined with
|
||||||
|
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
|
||||||
|
providing fuzzing signal without blowing up logs.
|
||||||
|
|
||||||
Issue Suppression
|
Issue Suppression
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,6 @@ UBSAN_FLAG(bool, print_stacktrace, false,
|
||||||
UBSAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
|
UBSAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
|
||||||
UBSAN_FLAG(bool, report_error_type, false,
|
UBSAN_FLAG(bool, report_error_type, false,
|
||||||
"Print specific error type instead of 'undefined-behavior' in summary.")
|
"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.")
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#if CAN_SANITIZE_UB
|
#if CAN_SANITIZE_UB
|
||||||
#include "ubsan_handlers.h"
|
#include "ubsan_handlers.h"
|
||||||
#include "ubsan_diag.h"
|
#include "ubsan_diag.h"
|
||||||
|
#include "ubsan_flags.h"
|
||||||
#include "ubsan_monitor.h"
|
#include "ubsan_monitor.h"
|
||||||
|
|
||||||
#include "sanitizer_common/sanitizer_common.h"
|
#include "sanitizer_common/sanitizer_common.h"
|
||||||
|
@ -118,6 +119,9 @@ static void handleIntegerOverflowImpl(OverflowData *Data, ValueHandle LHS,
|
||||||
if (ignoreReport(Loc, Opts, ET))
|
if (ignoreReport(Loc, Opts, ET))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!IsSigned && flags()->silence_unsigned_overflow)
|
||||||
|
return;
|
||||||
|
|
||||||
ScopedReport R(Opts, Loc, ET);
|
ScopedReport R(Opts, Loc, ET);
|
||||||
|
|
||||||
Diag(Loc, DL_Error, ET, "%0 integer overflow: "
|
Diag(Loc, DL_Error, ET, "%0 integer overflow: "
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
|
// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
|
||||||
// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=all -fsanitize-recover=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
|
// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=all -fsanitize-recover=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
|
||||||
|
// RUN: %env_ubsan_opts=silence_unsigned_overflow=1 %run %t 2>&1 | FileCheck %s --check-prefix=SILENT-RECOVER --allow-empty
|
||||||
// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=ABORT
|
// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=ABORT
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -18,5 +19,6 @@ int main() {
|
||||||
|
|
||||||
(void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
|
(void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
|
||||||
// RECOVER: 10000000000000000000 + 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
|
// RECOVER: 10000000000000000000 + 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
|
||||||
|
// SILENT-RECOVER-NOT: runtime error
|
||||||
// ABORT-NOT: runtime error
|
// ABORT-NOT: runtime error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue