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