about summary refs log tree commit diff homepage
path: root/runtime/Sanitizer/ubsan/ubsan_checks.inc
blob: b426beea10b7b4b33a527083b9bb0aa06d08f5e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//===-- ubsan_checks.inc ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// List of checks handled by UBSan runtime.
//
//===----------------------------------------------------------------------===//

#include "klee/Config/Version.h"

#ifndef UBSAN_CHECK
# error "Define UBSAN_CHECK prior to including this file!"
#endif

// UBSAN_CHECK(Name, SummaryKind, FSanitizeFlagName)
// SummaryKind and FSanitizeFlagName should be string literals.

UBSAN_CHECK(GenericUB, "undefined-behavior", "undefined")
UBSAN_CHECK(NullPointerUse, "null-pointer-use", "null")
#if LLVM_VERSION_MAJOR >= 11
UBSAN_CHECK(NullPointerUseWithNullability, "null-pointer-use",
            "nullability-assign")
#endif
#if LLVM_VERSION_MAJOR >= 10
UBSAN_CHECK(NullptrWithOffset, "nullptr-with-offset", "pointer-overflow")
UBSAN_CHECK(NullptrWithNonZeroOffset, "nullptr-with-nonzero-offset",
            "pointer-overflow")
UBSAN_CHECK(NullptrAfterNonZeroOffset, "nullptr-after-nonzero-offset",
            "pointer-overflow")
#endif
#if LLVM_VERSION_MAJOR >= 5
UBSAN_CHECK(PointerOverflow, "pointer-overflow", "pointer-overflow")
#endif
UBSAN_CHECK(MisalignedPointerUse, "misaligned-pointer-use", "alignment")
#if LLVM_VERSION_MAJOR >= 8
UBSAN_CHECK(AlignmentAssumption, "alignment-assumption", "alignment")
#endif
UBSAN_CHECK(InsufficientObjectSize, "insufficient-object-size", "object-size")
UBSAN_CHECK(SignedIntegerOverflow, "signed-integer-overflow",
            "signed-integer-overflow")
UBSAN_CHECK(UnsignedIntegerOverflow, "unsigned-integer-overflow",
            "unsigned-integer-overflow")
UBSAN_CHECK(IntegerDivideByZero, "integer-divide-by-zero",
            "integer-divide-by-zero")
UBSAN_CHECK(FloatDivideByZero, "float-divide-by-zero", "float-divide-by-zero")
#if LLVM_VERSION_MAJOR >= 6
UBSAN_CHECK(InvalidBuiltin, "invalid-builtin-use", "invalid-builtin-use")
#endif
#if LLVM_VERSION_MAJOR >= 11
UBSAN_CHECK(InvalidObjCCast, "invalid-objc-cast", "invalid-objc-cast")
#endif
#if LLVM_VERSION_MAJOR >= 8
UBSAN_CHECK(ImplicitUnsignedIntegerTruncation,
            "implicit-unsigned-integer-truncation",
            "implicit-unsigned-integer-truncation")
UBSAN_CHECK(ImplicitSignedIntegerTruncation,
            "implicit-signed-integer-truncation",
            "implicit-signed-integer-truncation")
#elif LLVM_VERSION_MAJOR >= 7
UBSAN_CHECK(ImplicitIntegerTruncation, "implicit-integer-truncation",
            "implicit-integer-truncation")
#endif
#if LLVM_VERSION_MAJOR >= 8
UBSAN_CHECK(ImplicitIntegerSignChange,
            "implicit-integer-sign-change",
            "implicit-integer-sign-change")
UBSAN_CHECK(ImplicitSignedIntegerTruncationOrSignChange,
            "implicit-signed-integer-truncation-or-sign-change",
            "implicit-signed-integer-truncation,implicit-integer-sign-change")
#endif
UBSAN_CHECK(InvalidShiftBase, "invalid-shift-base", "shift-base")
UBSAN_CHECK(InvalidShiftExponent, "invalid-shift-exponent", "shift-exponent")
UBSAN_CHECK(OutOfBoundsIndex, "out-of-bounds-index", "bounds")
UBSAN_CHECK(UnreachableCall, "unreachable-call", "unreachable")
UBSAN_CHECK(MissingReturn, "missing-return", "return")
UBSAN_CHECK(NonPositiveVLAIndex, "non-positive-vla-index", "vla-bound")
UBSAN_CHECK(FloatCastOverflow, "float-cast-overflow", "float-cast-overflow")
UBSAN_CHECK(InvalidBoolLoad, "invalid-bool-load", "bool")
UBSAN_CHECK(InvalidEnumLoad, "invalid-enum-load", "enum")
UBSAN_CHECK(FunctionTypeMismatch, "function-type-mismatch", "function")
UBSAN_CHECK(InvalidNullReturn, "invalid-null-return",
            "returns-nonnull-attribute")
#if LLVM_VERSION_MAJOR >= 11
UBSAN_CHECK(InvalidNullReturnWithNullability, "invalid-null-return",
            "nullability-return")
#endif
UBSAN_CHECK(InvalidNullArgument, "invalid-null-argument", "nonnull-attribute")
#if LLVM_VERSION_MAJOR >= 11
UBSAN_CHECK(InvalidNullArgumentWithNullability, "invalid-null-argument",
            "nullability-arg")
#endif
UBSAN_CHECK(DynamicTypeMismatch, "dynamic-type-mismatch", "vptr")
UBSAN_CHECK(CFIBadType, "cfi-bad-type", "cfi")