hwasan_flags.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //===-- hwasan_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. // Hwasan runtime flags.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef HWASAN_FLAG
  13. # error "Define HWASAN_FLAG prior to including this file!"
  14. #endif
  15. // HWASAN_FLAG(Type, Name, DefaultValue, Description)
  16. // See COMMON_FLAG in sanitizer_flags.inc for more details.
  17. HWASAN_FLAG(bool, verbose_threads, false,
  18. "inform on thread creation/destruction")
  19. HWASAN_FLAG(bool, tag_in_malloc, true, "")
  20. HWASAN_FLAG(bool, tag_in_free, true, "")
  21. HWASAN_FLAG(bool, print_stats, false, "")
  22. HWASAN_FLAG(bool, halt_on_error, true, "")
  23. HWASAN_FLAG(bool, atexit, false, "")
  24. HWASAN_FLAG(
  25. bool, print_live_threads_info, true,
  26. "If set, prints the remaining threads in report as an extra information.")
  27. // Test only flag to disable malloc/realloc/free memory tagging on startup.
  28. // Tagging can be reenabled with __hwasan_enable_allocator_tagging().
  29. HWASAN_FLAG(bool, disable_allocator_tagging, false, "")
  30. // If false, use simple increment of a thread local counter to generate new
  31. // tags.
  32. HWASAN_FLAG(bool, random_tags, true, "")
  33. HWASAN_FLAG(
  34. int, max_malloc_fill_size, 0,
  35. "HWASan allocator flag. max_malloc_fill_size is the maximal amount of "
  36. "bytes that will be filled with malloc_fill_byte on malloc.")
  37. HWASAN_FLAG(bool, free_checks_tail_magic, 1,
  38. "If set, free() will check the magic values "
  39. "after the allocated object "
  40. "if the allocation size is not a divident of the granule size")
  41. HWASAN_FLAG(
  42. int, max_free_fill_size, 0,
  43. "HWASan allocator flag. max_free_fill_size is the maximal amount of "
  44. "bytes that will be filled with free_fill_byte during free.")
  45. HWASAN_FLAG(int, malloc_fill_byte, 0xbe,
  46. "Value used to fill the newly allocated memory.")
  47. HWASAN_FLAG(int, free_fill_byte, 0x55,
  48. "Value used to fill deallocated memory.")
  49. HWASAN_FLAG(int, heap_history_size, 1023,
  50. "The number of heap (de)allocations remembered per thread. "
  51. "Affects the quality of heap-related reports, but not the ability "
  52. "to find bugs.")
  53. HWASAN_FLAG(bool, export_memory_stats, true,
  54. "Export up-to-date memory stats through /proc")
  55. HWASAN_FLAG(int, stack_history_size, 1024,
  56. "The number of stack frames remembered per thread. "
  57. "Affects the quality of stack-related reports, but not the ability "
  58. "to find bugs.")
  59. // Malloc / free bisection. Only tag malloc and free calls when a hash of
  60. // allocation size and stack trace is between malloc_bisect_left and
  61. // malloc_bisect_right (both inclusive). [0, 0] range is special and disables
  62. // bisection (i.e. everything is tagged). Once the range is narrowed down
  63. // enough, use malloc_bisect_dump to see interesting allocations.
  64. HWASAN_FLAG(uptr, malloc_bisect_left, 0,
  65. "Left bound of malloc bisection, inclusive.")
  66. HWASAN_FLAG(uptr, malloc_bisect_right, 0,
  67. "Right bound of malloc bisection, inclusive.")
  68. HWASAN_FLAG(bool, malloc_bisect_dump, false,
  69. "Print all allocations within [malloc_bisect_left, "
  70. "malloc_bisect_right] range ")
  71. // Exit if we fail to enable the AArch64 kernel ABI relaxation which allows
  72. // tagged pointers in syscalls. This is the default, but being able to disable
  73. // that behaviour is useful for running the testsuite on more platforms (the
  74. // testsuite can run since we manually ensure any pointer arguments to syscalls
  75. // are untagged before the call.
  76. HWASAN_FLAG(bool, fail_without_syscall_abi, true,
  77. "Exit if fail to request relaxed syscall ABI.")
  78. HWASAN_FLAG(
  79. uptr, fixed_shadow_base, -1,
  80. "If not -1, HWASan will attempt to allocate the shadow at this address, "
  81. "instead of choosing one dynamically."
  82. "Tip: this can be combined with the compiler option, "
  83. "-hwasan-mapping-offset, to optimize the instrumentation.")