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