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