options.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //===-- options.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. #ifndef GWP_ASAN_OPTION
  9. #error "Define GWP_ASAN_OPTION prior to including this file!"
  10. #endif
  11. #ifndef GWP_ASAN_DEFAULT_ENABLED
  12. #define GWP_ASAN_DEFAULT_ENABLED true
  13. #endif
  14. #ifndef GWP_ASAN_STRINGIFY
  15. #define GWP_ASAN_STRINGIFY(S) GWP_ASAN_STRINGIFY_(S)
  16. #define GWP_ASAN_STRINGIFY_(S) #S
  17. #endif
  18. GWP_ASAN_OPTION(bool, Enabled, GWP_ASAN_DEFAULT_ENABLED,
  19. "Is GWP-ASan enabled? Defaults to " GWP_ASAN_STRINGIFY(
  20. GWP_ASAN_DEFAULT_ENABLED) ".")
  21. GWP_ASAN_OPTION(int, MaxSimultaneousAllocations, 16,
  22. "Number of simultaneously-guarded allocations available in the "
  23. "pool. Defaults to 16.")
  24. GWP_ASAN_OPTION(int, SampleRate, 5000,
  25. "The probability (1 / SampleRate) that an allocation is "
  26. "selected for GWP-ASan sampling. Default is 5000. Sample rates "
  27. "up to (2^30 - 1) are supported.")
  28. // Developer note - This option is not actually processed by GWP-ASan itself. It
  29. // is included here so that a user can specify whether they want signal handlers
  30. // or not. The supporting allocator should inspect this value to see whether
  31. // signal handlers need to be installed, and then use
  32. // crash_handler::installSignalHandlers() in order to install the handlers. Note
  33. // that in order to support signal handlers, you will need to link against the
  34. // optional crash_handler component.
  35. GWP_ASAN_OPTION(
  36. bool, InstallSignalHandlers, true,
  37. "Install GWP-ASan signal handlers for SIGSEGV during dynamic loading. This "
  38. "allows better error reports by providing stack traces for allocation and "
  39. "deallocation when reporting a memory error. GWP-ASan's signal handler "
  40. "will forward the signal to any previously-installed handler, and user "
  41. "programs that install further signal handlers should make sure they do "
  42. "the same. Note, if the previously installed SIGSEGV handler is SIG_IGN, "
  43. "we terminate the process after dumping the error report.")
  44. GWP_ASAN_OPTION(bool, InstallForkHandlers, true,
  45. "Install GWP-ASan atfork handlers to acquire internal locks "
  46. "before fork and release them after.")
  47. GWP_ASAN_OPTION(bool, help, false, "Print a summary of the available options.")
  48. // =============================================================================
  49. // ==== WARNING
  50. // =============================================================================
  51. // If you are adding flags to GWP-ASan, please note that GWP-ASan flag strings
  52. // may be parsed by trusted system components (on Android, GWP-ASan flag strings
  53. // are parsed by libc during the dynamic loader). This means that GWP-ASan
  54. // should never feature flags like log paths on disk, because this can lead to
  55. // arbitrary file write and thus privilege escalation. For an example, see the
  56. // setuid ASan log_path exploits: https://www.exploit-db.com/exploits/46241.
  57. //
  58. // Please place all new flags above this warning, so that the warning always
  59. // stays at the bottom.