1278497Sdim//===-- asan_flags.inc ------------------------------------------*- C++ -*-===// 2278497Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6278497Sdim// 7278497Sdim//===----------------------------------------------------------------------===// 8278497Sdim// 9278497Sdim// ASan runtime flags. 10278497Sdim// 11278497Sdim//===----------------------------------------------------------------------===// 12278497Sdim#ifndef ASAN_FLAG 13278497Sdim# error "Define ASAN_FLAG prior to including this file!" 14278497Sdim#endif 15278497Sdim 16278497Sdim// ASAN_FLAG(Type, Name, DefaultValue, Description) 17278497Sdim// See COMMON_FLAG in sanitizer_flags.inc for more details. 18278497Sdim 19278497SdimASAN_FLAG(int, quarantine_size, -1, 20278497Sdim "Deprecated, please use quarantine_size_mb.") 21278497SdimASAN_FLAG(int, quarantine_size_mb, -1, 22278497Sdim "Size (in Mb) of quarantine used to detect use-after-free " 23278497Sdim "errors. Lower value may reduce memory usage but increase the " 24278497Sdim "chance of false negatives.") 25314564SdimASAN_FLAG(int, thread_local_quarantine_size_kb, -1, 26314564Sdim "Size (in Kb) of thread local quarantine used to detect " 27314564Sdim "use-after-free errors. Lower value may reduce memory usage but " 28314564Sdim "increase the chance of false negatives. It is not advised to go " 29314564Sdim "lower than 64Kb, otherwise frequent transfers to global quarantine " 30314564Sdim "might affect performance.") 31278497SdimASAN_FLAG(int, redzone, 16, 32278497Sdim "Minimal size (in bytes) of redzones around heap objects. " 33278497Sdim "Requirement: redzone >= 16, is a power of two.") 34278497SdimASAN_FLAG(int, max_redzone, 2048, 35278497Sdim "Maximal size (in bytes) of redzones around heap objects.") 36278497SdimASAN_FLAG( 37278497Sdim bool, debug, false, 38278497Sdim "If set, prints some debugging information and does additional checks.") 39278497SdimASAN_FLAG( 40278497Sdim int, report_globals, 1, 41278497Sdim "Controls the way to handle globals (0 - don't detect buffer overflow on " 42278497Sdim "globals, 1 - detect buffer overflow, 2 - print data about registered " 43278497Sdim "globals).") 44278497SdimASAN_FLAG(bool, check_initialization_order, false, 45278497Sdim "If set, attempts to catch initialization order issues.") 46278497SdimASAN_FLAG( 47278497Sdim bool, replace_str, true, 48278497Sdim "If set, uses custom wrappers and replacements for libc string functions " 49278497Sdim "to find more errors.") 50278497SdimASAN_FLAG(bool, replace_intrin, true, 51309124Sdim "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.") 52278497SdimASAN_FLAG(bool, detect_stack_use_after_return, false, 53278497Sdim "Enables stack-use-after-return checking at run-time.") 54278497SdimASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway. 55278497Sdim "Minimum fake stack size log.") 56278497SdimASAN_FLAG(int, max_uar_stack_size_log, 57278497Sdim 20, // 1Mb per size class, i.e. ~11Mb per thread 58278497Sdim "Maximum fake stack size log.") 59278497SdimASAN_FLAG(bool, uar_noreserve, false, 60278497Sdim "Use mmap with 'noreserve' flag to allocate fake stack.") 61278497SdimASAN_FLAG( 62278497Sdim int, max_malloc_fill_size, 0x1000, // By default, fill only the first 4K. 63278497Sdim "ASan allocator flag. max_malloc_fill_size is the maximal amount of " 64278497Sdim "bytes that will be filled with malloc_fill_byte on malloc.") 65321369SdimASAN_FLAG( 66321369Sdim int, max_free_fill_size, 0, 67321369Sdim "ASan allocator flag. max_free_fill_size is the maximal amount of " 68321369Sdim "bytes that will be filled with free_fill_byte during free.") 69278497SdimASAN_FLAG(int, malloc_fill_byte, 0xbe, 70278497Sdim "Value used to fill the newly allocated memory.") 71321369SdimASAN_FLAG(int, free_fill_byte, 0x55, 72321369Sdim "Value used to fill deallocated memory.") 73278497SdimASAN_FLAG(bool, allow_user_poisoning, true, 74278497Sdim "If set, user may manually mark memory regions as poisoned or " 75278497Sdim "unpoisoned.") 76278497SdimASAN_FLAG( 77278497Sdim int, sleep_before_dying, 0, 78278497Sdim "Number of seconds to sleep between printing an error report and " 79278497Sdim "terminating the program. Useful for debugging purposes (e.g. when one " 80278497Sdim "needs to attach gdb).") 81327952SdimASAN_FLAG( 82327952Sdim int, sleep_after_init, 0, 83327952Sdim "Number of seconds to sleep after AddressSanitizer is initialized. " 84327952Sdim "Useful for debugging purposes (e.g. when one needs to attach gdb).") 85278497SdimASAN_FLAG(bool, check_malloc_usable_size, true, 86278497Sdim "Allows the users to work around the bug in Nvidia drivers prior to " 87278497Sdim "295.*.") 88278497SdimASAN_FLAG(bool, unmap_shadow_on_exit, false, 89278497Sdim "If set, explicitly unmaps the (huge) shadow at exit.") 90341825SdimASAN_FLAG(bool, protect_shadow_gap, !SANITIZER_RTEMS, 91341825Sdim "If set, mprotect the shadow gap") 92278497SdimASAN_FLAG(bool, print_stats, false, 93278497Sdim "Print various statistics after printing an error message or if " 94278497Sdim "atexit=1.") 95278497SdimASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.") 96309124SdimASAN_FLAG(bool, print_scariness, false, 97309124Sdim "Print the scariness score. Experimental.") 98278497SdimASAN_FLAG(bool, atexit, false, 99278497Sdim "If set, prints ASan exit stats even after program terminates " 100278497Sdim "successfully.") 101278497SdimASAN_FLAG( 102278497Sdim bool, print_full_thread_history, true, 103278497Sdim "If set, prints thread creation stacks for the threads involved in the " 104278497Sdim "report and their ancestors up to the main thread.") 105278497SdimASAN_FLAG( 106278497Sdim bool, poison_heap, true, 107278497Sdim "Poison (or not) the heap memory on [de]allocation. Zero value is useful " 108278497Sdim "for benchmarking the allocator or instrumentator.") 109278497SdimASAN_FLAG(bool, poison_partial, true, 110278497Sdim "If true, poison partially addressable 8-byte aligned words " 111278497Sdim "(default=true). This flag affects heap and global buffers, but not " 112278497Sdim "stack buffers.") 113278497SdimASAN_FLAG(bool, poison_array_cookie, true, 114278497Sdim "Poison (or not) the array cookie after operator new[].") 115278497Sdim 116278497Sdim// Turn off alloc/dealloc mismatch checker on Mac and Windows for now. 117296417Sdim// https://github.com/google/sanitizers/issues/131 118296417Sdim// https://github.com/google/sanitizers/issues/309 119278497Sdim// TODO(glider,timurrrr): Fix known issues and enable this back. 120278497SdimASAN_FLAG(bool, alloc_dealloc_mismatch, 121314564Sdim !SANITIZER_MAC && !SANITIZER_WINDOWS && !SANITIZER_ANDROID, 122278497Sdim "Report errors on malloc/delete, new/free, new/delete[], etc.") 123278497Sdim 124278497SdimASAN_FLAG(bool, new_delete_type_mismatch, true, 125309124Sdim "Report errors on mismatch between size of new and delete.") 126278497SdimASAN_FLAG( 127278497Sdim bool, strict_init_order, false, 128278497Sdim "If true, assume that dynamic initializers can never access globals from " 129278497Sdim "other modules, even if the latter are already initialized.") 130278497SdimASAN_FLAG( 131278497Sdim bool, start_deactivated, false, 132278497Sdim "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap " 133278497Sdim "poisoning) to reduce memory consumption as much as possible, and " 134278497Sdim "restores them to original values when the first instrumented module is " 135278497Sdim "loaded into the process. This is mainly intended to be used on " 136278497Sdim "Android. ") 137278497SdimASAN_FLAG( 138278497Sdim int, detect_invalid_pointer_pairs, 0, 139341825Sdim "If >= 2, detect operations like <, <=, >, >= and - on invalid pointer " 140341825Sdim "pairs (e.g. when pointers belong to different objects); " 141341825Sdim "If == 1, detect invalid operations only when both pointers are non-null.") 142360784SdimASAN_FLAG(bool, detect_container_overflow, true, 143360784Sdim "If true, honor the container overflow annotations. See " 144360784Sdim "https://github.com/google/sanitizers/wiki/" 145360784Sdim "AddressSanitizerContainerOverflow") 146278497SdimASAN_FLAG(int, detect_odr_violation, 2, 147278497Sdim "If >=2, detect violation of One-Definition-Rule (ODR); " 148278497Sdim "If ==1, detect ODR-violation only if the two variables " 149278497Sdim "have different sizes") 150279194SdimASAN_FLAG(const char *, suppressions, "", "Suppressions file name.") 151296417SdimASAN_FLAG(bool, halt_on_error, true, 152296417Sdim "Crash the program after printing the first error report " 153296417Sdim "(WARNING: USE AT YOUR OWN RISK!)") 154321369SdimASAN_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true, 155321369Sdim "realloc(p, 0) is equivalent to free(p) by default (Same as the " 156321369Sdim "POSIX standard). If set to false, realloc(p, 0) will return a " 157321369Sdim "pointer to an allocated space which can not be used.") 158321369SdimASAN_FLAG(bool, verify_asan_link_order, true, 159321369Sdim "Check position of ASan runtime in library list (needs to be disabled" 160321369Sdim " when other library has to be preloaded system-wide)") 161360784SdimASAN_FLAG( 162360784Sdim bool, windows_hook_rtl_allocators, false, 163360784Sdim "(Windows only) enable hooking of Rtl(Allocate|Free|Size|ReAllocate)Heap.") 164