]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/hwasan/hwasan_flags.inc
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / lib / hwasan / hwasan_flags.inc
1 //===-- hwasan_flags.inc ------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Hwasan runtime flags.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef HWASAN_FLAG
14 # error "Define HWASAN_FLAG prior to including this file!"
15 #endif
16
17 // HWASAN_FLAG(Type, Name, DefaultValue, Description)
18 // See COMMON_FLAG in sanitizer_flags.inc for more details.
19
20 HWASAN_FLAG(bool, verbose_threads, false,
21             "inform on thread creation/destruction")
22 HWASAN_FLAG(bool, tag_in_malloc, true, "")
23 HWASAN_FLAG(bool, tag_in_free, true, "")
24 HWASAN_FLAG(bool, print_stats, false, "")
25 HWASAN_FLAG(bool, halt_on_error, true, "")
26 HWASAN_FLAG(bool, atexit, false, "")
27
28 // Test only flag to disable malloc/realloc/free memory tagging on startup.
29 // Tagging can be reenabled with __hwasan_enable_allocator_tagging().
30 HWASAN_FLAG(bool, disable_allocator_tagging, false, "")
31
32 // If false, use simple increment of a thread local counter to generate new
33 // tags.
34 HWASAN_FLAG(bool, random_tags, true, "")
35
36 HWASAN_FLAG(
37     int, max_malloc_fill_size, 0x1000,  // By default, fill only the first 4K.
38     "HWASan allocator flag. max_malloc_fill_size is the maximal amount of "
39     "bytes that will be filled with malloc_fill_byte on malloc.")
40
41 // Rules for malloc alignment on aarch64:
42 //   * If the size is 16-aligned, then malloc should return 16-aligned memory.
43 //   * Otherwise, malloc should return 8-alignment memory.
44 // So,
45 //   * If the size is 16-aligned, we don't need to do anything.
46 //   * Otherwise we don't have to obey 16-alignment, just the 8-alignment.
47 //   * We may want to break the 8-alignment rule to catch more buffer overflows
48 //     but this will break valid code in some rare cases, like this:
49 //     struct Foo {
50 //       // accessed via atomic instructions that require 8-alignment.
51 //       std::atomic<int64_t> atomic_stuff;
52 //       ...
53 //       char vla[1];  // the actual size of vla could be anything.
54 //     }
55 // Which means that the safe values for malloc_align_right are 0, 8, 9,
56 // and the values 1 and 2 may require changes in otherwise valid code.
57
58 HWASAN_FLAG(
59     int, malloc_align_right, 0,  // off by default
60     "HWASan allocator flag. "
61     "0 (default): allocations are always aligned left to 16-byte boundary; "
62     "1: allocations are sometimes aligned right to 1-byte boundary (risky); "
63     "2: allocations are always aligned right to 1-byte boundary (risky); "
64     "8: allocations are sometimes aligned right to 8-byte boundary; "
65     "9: allocations are always aligned right to 8-byte boundary."
66   )
67 HWASAN_FLAG(bool, free_checks_tail_magic, 1,
68     "If set, free() will check the magic values "
69     "to the right of the allocated object "
70     "if the allocation size is not a divident of the granule size")
71 HWASAN_FLAG(
72     int, max_free_fill_size, 0,
73     "HWASan allocator flag. max_free_fill_size is the maximal amount of "
74     "bytes that will be filled with free_fill_byte during free.")
75 HWASAN_FLAG(int, malloc_fill_byte, 0xbe,
76           "Value used to fill the newly allocated memory.")
77 HWASAN_FLAG(int, free_fill_byte, 0x55,
78           "Value used to fill deallocated memory.")
79 HWASAN_FLAG(int, heap_history_size, 1023,
80           "The number of heap (de)allocations remembered per thread. "
81           "Affects the quality of heap-related reports, but not the ability "
82           "to find bugs.")
83 HWASAN_FLAG(bool, export_memory_stats, true,
84             "Export up-to-date memory stats through /proc")
85 HWASAN_FLAG(int, stack_history_size, 1024,
86             "The number of stack frames remembered per thread. "
87             "Affects the quality of stack-related reports, but not the ability "
88             "to find bugs.")