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 | // Requires AddressSanitizer |
44 | SANITIZER("pointer-compare" , PointerCompare) |
45 | |
46 | // Requires AddressSanitizer |
47 | SANITIZER("pointer-subtract" , PointerSubtract) |
48 | |
49 | // Kernel AddressSanitizer (KASan) |
50 | SANITIZER("kernel-address" , KernelAddress) |
51 | |
52 | // Hardware-assisted AddressSanitizer |
53 | SANITIZER("hwaddress" , HWAddress) |
54 | |
55 | // Kernel Hardware-assisted AddressSanitizer (KHWASan) |
56 | SANITIZER("kernel-hwaddress" , KernelHWAddress) |
57 | |
58 | // A variant of AddressSanitizer using AArch64 MTE extension. |
59 | SANITIZER("memtag-stack" , MemtagStack) |
60 | SANITIZER("memtag-heap" , MemtagHeap) |
61 | SANITIZER("memtag-globals" , MemtagGlobals) |
62 | SANITIZER_GROUP("memtag" , MemTag, MemtagStack | MemtagHeap | MemtagGlobals) |
63 | |
64 | // MemorySanitizer |
65 | SANITIZER("memory" , Memory) |
66 | |
67 | // Kernel MemorySanitizer (KMSAN) |
68 | SANITIZER("kernel-memory" , KernelMemory) |
69 | |
70 | // libFuzzer |
71 | SANITIZER("fuzzer" , Fuzzer) |
72 | |
73 | // libFuzzer-required instrumentation, no linking. |
74 | SANITIZER("fuzzer-no-link" , FuzzerNoLink) |
75 | |
76 | // ThreadSanitizer |
77 | SANITIZER("thread" , Thread) |
78 | |
79 | // LeakSanitizer |
80 | SANITIZER("leak" , Leak) |
81 | |
82 | // UndefinedBehaviorSanitizer |
83 | SANITIZER("alignment" , Alignment) |
84 | SANITIZER("array-bounds" , ArrayBounds) |
85 | SANITIZER("bool" , Bool) |
86 | SANITIZER("builtin" , Builtin) |
87 | SANITIZER("enum" , Enum) |
88 | SANITIZER("float-cast-overflow" , FloatCastOverflow) |
89 | SANITIZER("float-divide-by-zero" , FloatDivideByZero) |
90 | SANITIZER("function" , Function) |
91 | SANITIZER("integer-divide-by-zero" , IntegerDivideByZero) |
92 | SANITIZER("nonnull-attribute" , NonnullAttribute) |
93 | SANITIZER("null" , Null) |
94 | SANITIZER("nullability-arg" , NullabilityArg) |
95 | SANITIZER("nullability-assign" , NullabilityAssign) |
96 | SANITIZER("nullability-return" , NullabilityReturn) |
97 | SANITIZER_GROUP("nullability" , Nullability, |
98 | NullabilityArg | NullabilityAssign | NullabilityReturn) |
99 | SANITIZER("object-size" , ObjectSize) |
100 | SANITIZER("pointer-overflow" , PointerOverflow) |
101 | SANITIZER("return" , Return) |
102 | SANITIZER("returns-nonnull-attribute" , ReturnsNonnullAttribute) |
103 | SANITIZER("shift-base" , ShiftBase) |
104 | SANITIZER("shift-exponent" , ShiftExponent) |
105 | SANITIZER_GROUP("shift" , Shift, ShiftBase | ShiftExponent) |
106 | SANITIZER("signed-integer-overflow" , SignedIntegerOverflow) |
107 | SANITIZER("unreachable" , Unreachable) |
108 | SANITIZER("vla-bound" , VLABound) |
109 | SANITIZER("vptr" , Vptr) |
110 | |
111 | // IntegerSanitizer |
112 | SANITIZER("unsigned-integer-overflow" , UnsignedIntegerOverflow) |
113 | SANITIZER("unsigned-shift-base" , UnsignedShiftBase) |
114 | |
115 | // DataFlowSanitizer |
116 | SANITIZER("dataflow" , DataFlow) |
117 | |
118 | // Control Flow Integrity |
119 | SANITIZER("cfi-cast-strict" , CFICastStrict) |
120 | SANITIZER("cfi-derived-cast" , CFIDerivedCast) |
121 | SANITIZER("cfi-icall" , CFIICall) |
122 | SANITIZER("cfi-mfcall" , CFIMFCall) |
123 | SANITIZER("cfi-unrelated-cast" , CFIUnrelatedCast) |
124 | SANITIZER("cfi-nvcall" , CFINVCall) |
125 | SANITIZER("cfi-vcall" , CFIVCall) |
126 | SANITIZER_GROUP("cfi" , CFI, |
127 | CFIDerivedCast | CFIICall | CFIMFCall | CFIUnrelatedCast | |
128 | CFINVCall | CFIVCall) |
129 | |
130 | // Kernel Control Flow Integrity |
131 | SANITIZER("kcfi" , KCFI) |
132 | |
133 | // Safe Stack |
134 | SANITIZER("safe-stack" , SafeStack) |
135 | |
136 | // Shadow Call Stack |
137 | SANITIZER("shadow-call-stack" , ShadowCallStack) |
138 | |
139 | // -fsanitize=undefined includes all the sanitizers which have low overhead, no |
140 | // ABI or address space layout implications, and only catch undefined behavior. |
141 | SANITIZER_GROUP("undefined" , Undefined, |
142 | Alignment | Bool | Builtin | ArrayBounds | Enum | |
143 | FloatCastOverflow | |
144 | IntegerDivideByZero | NonnullAttribute | Null | ObjectSize | |
145 | PointerOverflow | Return | ReturnsNonnullAttribute | Shift | |
146 | SignedIntegerOverflow | Unreachable | VLABound | Function | |
147 | Vptr) |
148 | |
149 | // -fsanitize=undefined-trap is an alias for -fsanitize=undefined. |
150 | SANITIZER_GROUP("undefined-trap" , UndefinedTrap, Undefined) |
151 | |
152 | // ImplicitConversionSanitizer |
153 | SANITIZER("implicit-unsigned-integer-truncation" , |
154 | ImplicitUnsignedIntegerTruncation) |
155 | SANITIZER("implicit-signed-integer-truncation" , ImplicitSignedIntegerTruncation) |
156 | SANITIZER_GROUP("implicit-integer-truncation" , ImplicitIntegerTruncation, |
157 | ImplicitUnsignedIntegerTruncation | |
158 | ImplicitSignedIntegerTruncation) |
159 | |
160 | SANITIZER("implicit-integer-sign-change" , ImplicitIntegerSignChange) |
161 | |
162 | SANITIZER_GROUP("implicit-integer-arithmetic-value-change" , |
163 | ImplicitIntegerArithmeticValueChange, |
164 | ImplicitIntegerSignChange | ImplicitSignedIntegerTruncation) |
165 | |
166 | SANITIZER_GROUP("implicit-integer-conversion" , ImplicitIntegerConversion, |
167 | ImplicitIntegerArithmeticValueChange | |
168 | ImplicitUnsignedIntegerTruncation) |
169 | |
170 | // Implicit bitfield sanitizers |
171 | SANITIZER("implicit-bitfield-conversion" , ImplicitBitfieldConversion) |
172 | |
173 | SANITIZER_GROUP("implicit-conversion" , ImplicitConversion, |
174 | ImplicitIntegerConversion | |
175 | ImplicitBitfieldConversion) |
176 | |
177 | SANITIZER_GROUP("integer" , Integer, |
178 | ImplicitIntegerConversion | IntegerDivideByZero | Shift | |
179 | SignedIntegerOverflow | UnsignedIntegerOverflow | |
180 | UnsignedShiftBase) |
181 | |
182 | SANITIZER("objc-cast" , ObjCCast) |
183 | |
184 | SANITIZER("local-bounds" , LocalBounds) |
185 | SANITIZER_GROUP("bounds" , Bounds, ArrayBounds | LocalBounds) |
186 | |
187 | // Scudo hardened allocator |
188 | SANITIZER("scudo" , Scudo) |
189 | |
190 | // Magic group, containing all sanitizers. For example, "-fno-sanitize=all" |
191 | // can be used to disable all the sanitizers. |
192 | SANITIZER_GROUP("all" , All, ~SanitizerMask()) |
193 | |
194 | #undef SANITIZER |
195 | #undef SANITIZER_GROUP |
196 | |