xref: /aosp_15_r20/external/compiler-rt/lib/asan/asan_flags.inc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot//===-- asan_flags.inc ------------------------------------------*- C++ -*-===//
2*7c3d14c8STreehugger Robot//
3*7c3d14c8STreehugger Robot//                     The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot//
5*7c3d14c8STreehugger Robot// This file is distributed under the University of Illinois Open Source
6*7c3d14c8STreehugger Robot// License. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot//
8*7c3d14c8STreehugger Robot//===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot//
10*7c3d14c8STreehugger Robot// ASan runtime flags.
11*7c3d14c8STreehugger Robot//
12*7c3d14c8STreehugger Robot//===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot#ifndef ASAN_FLAG
14*7c3d14c8STreehugger Robot# error "Define ASAN_FLAG prior to including this file!"
15*7c3d14c8STreehugger Robot#endif
16*7c3d14c8STreehugger Robot
17*7c3d14c8STreehugger Robot// ASAN_FLAG(Type, Name, DefaultValue, Description)
18*7c3d14c8STreehugger Robot// See COMMON_FLAG in sanitizer_flags.inc for more details.
19*7c3d14c8STreehugger Robot
20*7c3d14c8STreehugger RobotASAN_FLAG(int, quarantine_size, -1,
21*7c3d14c8STreehugger Robot            "Deprecated, please use quarantine_size_mb.")
22*7c3d14c8STreehugger RobotASAN_FLAG(int, quarantine_size_mb, -1,
23*7c3d14c8STreehugger Robot          "Size (in Mb) of quarantine used to detect use-after-free "
24*7c3d14c8STreehugger Robot          "errors. Lower value may reduce memory usage but increase the "
25*7c3d14c8STreehugger Robot          "chance of false negatives.")
26*7c3d14c8STreehugger RobotASAN_FLAG(int, redzone, 16,
27*7c3d14c8STreehugger Robot          "Minimal size (in bytes) of redzones around heap objects. "
28*7c3d14c8STreehugger Robot          "Requirement: redzone >= 16, is a power of two.")
29*7c3d14c8STreehugger RobotASAN_FLAG(int, max_redzone, 2048,
30*7c3d14c8STreehugger Robot          "Maximal size (in bytes) of redzones around heap objects.")
31*7c3d14c8STreehugger RobotASAN_FLAG(
32*7c3d14c8STreehugger Robot    bool, debug, false,
33*7c3d14c8STreehugger Robot    "If set, prints some debugging information and does additional checks.")
34*7c3d14c8STreehugger RobotASAN_FLAG(
35*7c3d14c8STreehugger Robot    int, report_globals, 1,
36*7c3d14c8STreehugger Robot    "Controls the way to handle globals (0 - don't detect buffer overflow on "
37*7c3d14c8STreehugger Robot    "globals, 1 - detect buffer overflow, 2 - print data about registered "
38*7c3d14c8STreehugger Robot    "globals).")
39*7c3d14c8STreehugger RobotASAN_FLAG(bool, check_initialization_order, false,
40*7c3d14c8STreehugger Robot          "If set, attempts to catch initialization order issues.")
41*7c3d14c8STreehugger RobotASAN_FLAG(
42*7c3d14c8STreehugger Robot    bool, replace_str, true,
43*7c3d14c8STreehugger Robot    "If set, uses custom wrappers and replacements for libc string functions "
44*7c3d14c8STreehugger Robot    "to find more errors.")
45*7c3d14c8STreehugger RobotASAN_FLAG(bool, replace_intrin, true,
46*7c3d14c8STreehugger Robot          "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
47*7c3d14c8STreehugger RobotASAN_FLAG(bool, detect_stack_use_after_return, false,
48*7c3d14c8STreehugger Robot          "Enables stack-use-after-return checking at run-time.")
49*7c3d14c8STreehugger RobotASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
50*7c3d14c8STreehugger Robot          "Minimum fake stack size log.")
51*7c3d14c8STreehugger RobotASAN_FLAG(int, max_uar_stack_size_log,
52*7c3d14c8STreehugger Robot          20, // 1Mb per size class, i.e. ~11Mb per thread
53*7c3d14c8STreehugger Robot          "Maximum fake stack size log.")
54*7c3d14c8STreehugger RobotASAN_FLAG(bool, uar_noreserve, false,
55*7c3d14c8STreehugger Robot          "Use mmap with 'noreserve' flag to allocate fake stack.")
56*7c3d14c8STreehugger RobotASAN_FLAG(
57*7c3d14c8STreehugger Robot    int, max_malloc_fill_size, 0x1000,  // By default, fill only the first 4K.
58*7c3d14c8STreehugger Robot    "ASan allocator flag. max_malloc_fill_size is the maximal amount of "
59*7c3d14c8STreehugger Robot    "bytes that will be filled with malloc_fill_byte on malloc.")
60*7c3d14c8STreehugger RobotASAN_FLAG(int, malloc_fill_byte, 0xbe,
61*7c3d14c8STreehugger Robot          "Value used to fill the newly allocated memory.")
62*7c3d14c8STreehugger RobotASAN_FLAG(bool, allow_user_poisoning, true,
63*7c3d14c8STreehugger Robot          "If set, user may manually mark memory regions as poisoned or "
64*7c3d14c8STreehugger Robot          "unpoisoned.")
65*7c3d14c8STreehugger RobotASAN_FLAG(
66*7c3d14c8STreehugger Robot    int, sleep_before_dying, 0,
67*7c3d14c8STreehugger Robot    "Number of seconds to sleep between printing an error report and "
68*7c3d14c8STreehugger Robot    "terminating the program. Useful for debugging purposes (e.g. when one "
69*7c3d14c8STreehugger Robot    "needs to attach gdb).")
70*7c3d14c8STreehugger RobotASAN_FLAG(bool, check_malloc_usable_size, true,
71*7c3d14c8STreehugger Robot          "Allows the users to work around the bug in Nvidia drivers prior to "
72*7c3d14c8STreehugger Robot          "295.*.")
73*7c3d14c8STreehugger RobotASAN_FLAG(bool, unmap_shadow_on_exit, false,
74*7c3d14c8STreehugger Robot          "If set, explicitly unmaps the (huge) shadow at exit.")
75*7c3d14c8STreehugger RobotASAN_FLAG(bool, protect_shadow_gap, true, "If set, mprotect the shadow gap")
76*7c3d14c8STreehugger RobotASAN_FLAG(bool, print_stats, false,
77*7c3d14c8STreehugger Robot          "Print various statistics after printing an error message or if "
78*7c3d14c8STreehugger Robot          "atexit=1.")
79*7c3d14c8STreehugger RobotASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.")
80*7c3d14c8STreehugger RobotASAN_FLAG(bool, print_scariness, false,
81*7c3d14c8STreehugger Robot          "Print the scariness score. Experimental.")
82*7c3d14c8STreehugger RobotASAN_FLAG(bool, atexit, false,
83*7c3d14c8STreehugger Robot          "If set, prints ASan exit stats even after program terminates "
84*7c3d14c8STreehugger Robot          "successfully.")
85*7c3d14c8STreehugger RobotASAN_FLAG(
86*7c3d14c8STreehugger Robot    bool, print_full_thread_history, true,
87*7c3d14c8STreehugger Robot    "If set, prints thread creation stacks for the threads involved in the "
88*7c3d14c8STreehugger Robot    "report and their ancestors up to the main thread.")
89*7c3d14c8STreehugger RobotASAN_FLAG(
90*7c3d14c8STreehugger Robot    bool, poison_heap, true,
91*7c3d14c8STreehugger Robot    "Poison (or not) the heap memory on [de]allocation. Zero value is useful "
92*7c3d14c8STreehugger Robot    "for benchmarking the allocator or instrumentator.")
93*7c3d14c8STreehugger RobotASAN_FLAG(bool, poison_partial, true,
94*7c3d14c8STreehugger Robot          "If true, poison partially addressable 8-byte aligned words "
95*7c3d14c8STreehugger Robot          "(default=true). This flag affects heap and global buffers, but not "
96*7c3d14c8STreehugger Robot          "stack buffers.")
97*7c3d14c8STreehugger RobotASAN_FLAG(bool, poison_array_cookie, true,
98*7c3d14c8STreehugger Robot          "Poison (or not) the array cookie after operator new[].")
99*7c3d14c8STreehugger Robot
100*7c3d14c8STreehugger Robot// Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
101*7c3d14c8STreehugger Robot// https://github.com/google/sanitizers/issues/131
102*7c3d14c8STreehugger Robot// https://github.com/google/sanitizers/issues/309
103*7c3d14c8STreehugger Robot// TODO(glider,timurrrr): Fix known issues and enable this back.
104*7c3d14c8STreehugger RobotASAN_FLAG(bool, alloc_dealloc_mismatch,
105*7c3d14c8STreehugger Robot          !SANITIZER_MAC && !SANITIZER_WINDOWS && !SANITIZER_ANDROID,
106*7c3d14c8STreehugger Robot          "Report errors on malloc/delete, new/free, new/delete[], etc.")
107*7c3d14c8STreehugger Robot
108*7c3d14c8STreehugger RobotASAN_FLAG(bool, new_delete_type_mismatch, true,
109*7c3d14c8STreehugger Robot          "Report errors on mismatch between size of new and delete.")
110*7c3d14c8STreehugger RobotASAN_FLAG(
111*7c3d14c8STreehugger Robot    bool, strict_init_order, false,
112*7c3d14c8STreehugger Robot    "If true, assume that dynamic initializers can never access globals from "
113*7c3d14c8STreehugger Robot    "other modules, even if the latter are already initialized.")
114*7c3d14c8STreehugger RobotASAN_FLAG(
115*7c3d14c8STreehugger Robot    bool, start_deactivated, false,
116*7c3d14c8STreehugger Robot    "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap "
117*7c3d14c8STreehugger Robot    "poisoning) to reduce memory consumption as much as possible, and "
118*7c3d14c8STreehugger Robot    "restores them to original values when the first instrumented module is "
119*7c3d14c8STreehugger Robot    "loaded into the process. This is mainly intended to be used on "
120*7c3d14c8STreehugger Robot    "Android. ")
121*7c3d14c8STreehugger RobotASAN_FLAG(
122*7c3d14c8STreehugger Robot    int, detect_invalid_pointer_pairs, 0,
123*7c3d14c8STreehugger Robot    "If non-zero, try to detect operations like <, <=, >, >= and - on "
124*7c3d14c8STreehugger Robot    "invalid pointer pairs (e.g. when pointers belong to different objects). "
125*7c3d14c8STreehugger Robot    "The bigger the value the harder we try.")
126*7c3d14c8STreehugger RobotASAN_FLAG(
127*7c3d14c8STreehugger Robot    bool, detect_container_overflow, true,
128*7c3d14c8STreehugger Robot    "If true, honor the container overflow annotations. See "
129*7c3d14c8STreehugger Robot    "https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow")
130*7c3d14c8STreehugger RobotASAN_FLAG(int, detect_odr_violation, 2,
131*7c3d14c8STreehugger Robot          "If >=2, detect violation of One-Definition-Rule (ODR); "
132*7c3d14c8STreehugger Robot          "If ==1, detect ODR-violation only if the two variables "
133*7c3d14c8STreehugger Robot          "have different sizes")
134*7c3d14c8STreehugger RobotASAN_FLAG(bool, dump_instruction_bytes, false,
135*7c3d14c8STreehugger Robot          "If true, dump 16 bytes starting at the instruction that caused SEGV")
136*7c3d14c8STreehugger RobotASAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
137*7c3d14c8STreehugger RobotASAN_FLAG(bool, halt_on_error, true,
138*7c3d14c8STreehugger Robot          "Crash the program after printing the first error report "
139*7c3d14c8STreehugger Robot          "(WARNING: USE AT YOUR OWN RISK!)")
140*7c3d14c8STreehugger RobotASAN_FLAG(bool, use_odr_indicator, false,
141*7c3d14c8STreehugger Robot          "Use special ODR indicator symbol for ODR violation detection")
142