1 | //===--- Sanitizers.def - Runtime sanitizer options -------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file defines the options for specifying which runtime sanitizers to |
10 | // enable. Users of this file must define the SANITIZER macro to make use of |
11 | // this information. Users of this file can also define the SANITIZER_GROUP |
12 | // macro to get information on options which refer to sets of sanitizers. |
13 | // |
14 | //===----------------------------------------------------------------------===// |
15 | |
16 | #ifndef SANITIZER |
17 | #error "Define SANITIZER prior to including this file!" |
18 | #endif |
19 | |
20 | // SANITIZER(NAME, ID) |
21 | |
22 | // The first value is the name of the sanitizer as a string. The sanitizer can |
23 | // be enabled by specifying -fsanitize=NAME. |
24 | |
25 | // The second value is an identifier which can be used to refer to the |
26 | // sanitizer. |
27 | |
28 | |
29 | // SANITIZER_GROUP(NAME, ID, ALIAS) |
30 | |
31 | // The first two values have the same semantics as the corresponding SANITIZER |
32 | // values. The third value is an expression ORing together the IDs of individual |
33 | // sanitizers in this group. |
34 | |
35 | #ifndef SANITIZER_GROUP |
36 | #define SANITIZER_GROUP(NAME, ID, ALIAS) |
37 | #endif |
38 | |
39 | |
40 | // AddressSanitizer |
41 | SANITIZER("address", Address) |
42 | |
43 | // Kernel AddressSanitizer (KASan) |
44 | SANITIZER("kernel-address", KernelAddress) |
45 | |
46 | // Hardware-assisted AddressSanitizer |
47 | SANITIZER("hwaddress", HWAddress) |
48 | |
49 | // Kernel Hardware-assisted AddressSanitizer (KHWASan) |
50 | SANITIZER("kernel-hwaddress", KernelHWAddress) |
51 | |
52 | // MemorySanitizer |
53 | SANITIZER("memory", Memory) |
54 | |
55 | // Kernel MemorySanitizer (KMSAN) |
56 | SANITIZER("kernel-memory", KernelMemory) |
57 | |
58 | // libFuzzer |
59 | SANITIZER("fuzzer", Fuzzer) |
60 | |
61 | // libFuzzer-required instrumentation, no linking. |
62 | SANITIZER("fuzzer-no-link", FuzzerNoLink) |
63 | |
64 | // ThreadSanitizer |
65 | SANITIZER("thread", Thread) |
66 | |
67 | // LeakSanitizer |
68 | SANITIZER("leak", Leak) |
69 | |
70 | // UndefinedBehaviorSanitizer |
71 | SANITIZER("alignment", Alignment) |
72 | SANITIZER("array-bounds", ArrayBounds) |
73 | SANITIZER("bool", Bool) |
74 | SANITIZER("builtin", Builtin) |
75 | SANITIZER("enum", Enum) |
76 | SANITIZER("float-cast-overflow", FloatCastOverflow) |
77 | SANITIZER("float-divide-by-zero", FloatDivideByZero) |
78 | SANITIZER("function", Function) |
79 | SANITIZER("integer-divide-by-zero", IntegerDivideByZero) |
80 | SANITIZER("nonnull-attribute", NonnullAttribute) |
81 | SANITIZER("null", Null) |
82 | SANITIZER("nullability-arg", NullabilityArg) |
83 | SANITIZER("nullability-assign", NullabilityAssign) |
84 | SANITIZER("nullability-return", NullabilityReturn) |
85 | SANITIZER_GROUP("nullability", Nullability, |
86 | NullabilityArg | NullabilityAssign | NullabilityReturn) |
87 | SANITIZER("object-size", ObjectSize) |
88 | SANITIZER("pointer-overflow", PointerOverflow) |
89 | SANITIZER("return", Return) |
90 | SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute) |
91 | SANITIZER("shift-base", ShiftBase) |
92 | SANITIZER("shift-exponent", ShiftExponent) |
93 | SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent) |
94 | SANITIZER("signed-integer-overflow", SignedIntegerOverflow) |
95 | SANITIZER("unreachable", Unreachable) |
96 | SANITIZER("vla-bound", VLABound) |
97 | SANITIZER("vptr", Vptr) |
98 | |
99 | // IntegerSanitizer |
100 | SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow) |
101 | |
102 | // DataFlowSanitizer |
103 | SANITIZER("dataflow", DataFlow) |
104 | |
105 | // Control Flow Integrity |
106 | SANITIZER("cfi-cast-strict", CFICastStrict) |
107 | SANITIZER("cfi-derived-cast", CFIDerivedCast) |
108 | SANITIZER("cfi-icall", CFIICall) |
109 | SANITIZER("cfi-mfcall", CFIMFCall) |
110 | SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast) |
111 | SANITIZER("cfi-nvcall", CFINVCall) |
112 | SANITIZER("cfi-vcall", CFIVCall) |
113 | SANITIZER_GROUP("cfi", CFI, |
114 | CFIDerivedCast | CFIICall | CFIMFCall | CFIUnrelatedCast | |
115 | CFINVCall | CFIVCall) |
116 | |
117 | // Safe Stack |
118 | SANITIZER("safe-stack", SafeStack) |
119 | |
120 | // Shadow Call Stack |
121 | SANITIZER("shadow-call-stack", ShadowCallStack) |
122 | |
123 | // -fsanitize=undefined includes all the sanitizers which have low overhead, no |
124 | // ABI or address space layout implications, and only catch undefined behavior. |
125 | SANITIZER_GROUP("undefined", Undefined, |
126 | Alignment | Bool | Builtin | ArrayBounds | Enum | |
127 | FloatCastOverflow | FloatDivideByZero | |
128 | IntegerDivideByZero | NonnullAttribute | Null | ObjectSize | |
129 | PointerOverflow | Return | ReturnsNonnullAttribute | Shift | |
130 | SignedIntegerOverflow | Unreachable | VLABound | Function | |
131 | Vptr) |
132 | |
133 | // -fsanitize=undefined-trap is an alias for -fsanitize=undefined. |
134 | SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined) |
135 | |
136 | // ImplicitConversionSanitizer |
137 | SANITIZER("implicit-unsigned-integer-truncation", |
138 | ImplicitUnsignedIntegerTruncation) |
139 | SANITIZER("implicit-signed-integer-truncation", ImplicitSignedIntegerTruncation) |
140 | SANITIZER_GROUP("implicit-integer-truncation", ImplicitIntegerTruncation, |
141 | ImplicitUnsignedIntegerTruncation | |
142 | ImplicitSignedIntegerTruncation) |
143 | |
144 | SANITIZER("implicit-integer-sign-change", ImplicitIntegerSignChange) |
145 | |
146 | SANITIZER_GROUP("implicit-integer-arithmetic-value-change", |
147 | ImplicitIntegerArithmeticValueChange, |
148 | ImplicitIntegerSignChange | ImplicitSignedIntegerTruncation) |
149 | |
150 | // FIXME: |
151 | //SANITIZER_GROUP("implicit-integer-conversion", ImplicitIntegerConversion, |
152 | // ImplicitIntegerArithmeticValueChange | |
153 | // ImplicitUnsignedIntegerTruncation) |
154 | //SANITIZER_GROUP("implicit-conversion", ImplicitConversion, |
155 | // ImplicitIntegerConversion) |
156 | |
157 | SANITIZER_GROUP("implicit-conversion", ImplicitConversion, |
158 | ImplicitIntegerArithmeticValueChange | |
159 | ImplicitUnsignedIntegerTruncation) |
160 | |
161 | SANITIZER_GROUP("integer", Integer, |
162 | ImplicitConversion | IntegerDivideByZero | Shift | |
163 | SignedIntegerOverflow | UnsignedIntegerOverflow) |
164 | |
165 | SANITIZER("local-bounds", LocalBounds) |
166 | SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds) |
167 | |
168 | // Scudo hardened allocator |
169 | SANITIZER("scudo", Scudo) |
170 | |
171 | // Magic group, containing all sanitizers. For example, "-fno-sanitize=all" |
172 | // can be used to disable all the sanitizers. |
173 | SANITIZER_GROUP("all", All, ~SanitizerMask()) |
174 | |
175 | #undef SANITIZER |
176 | #undef SANITIZER_GROUP |
177 | |