asan_flags.inc 7.9 KB

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