true, true, true, ATTRS, true, \
(flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD \
| SANITIZE_HWADDRESS \
+ | SANITIZE_MEMTAG_STACK \
| SANITIZE_UNDEFINED \
| SANITIZE_UNDEFINED_NONDEFAULT) \
|| flag_sanitize_coverage))
deterministic sequence beginning at a random tag for each frame. With this
parameter unset tags are chosen using the same sequence but beginning from 1.
This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
-for @option{-fsanitize=kernel-hwaddress}.
+for @option{-fsanitize=kernel-hwaddress} and @option{-fsanitize=memtag-stack}.
To disable it use @option{--param hwasan-random-frame-tag=0}.
@item hwasan-instrument-allocas
To disable instrumentation of builtin functions use
@option{--param hwasan-instrument-mem-intrinsics=0}.
+@item memtag-instrument-allocas
+Enable hardware-assisted memory tagging of dynamically sized stack-allocated
+variables. This kind of code generation is enabled by default when using
+@option{-fsanitize=memtag-stack}.
+
@item use-after-scope-direct-emission-threshold
If the size of a local variable in bytes is smaller or equal to this
number, directly poison (or unpoison) shadow memory instead of using
@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
tag is not implemented for kernel instrumentation.
+@opindex fsanitize=memtag-stack
+@item -fsanitize=memtag-stack
+Use Memory Tagging Extension instructions instead of instrumentation
+to allow the detection of memory errors. Similar to HWASAN, it is
+also a probabilistic method. This option is available only on those
+AArch64 architectures that support Memory Tagging Extensions.
+
@opindex fsanitize=pointer-compare
@item -fsanitize=pointer-compare
Instrument comparison operation (<, <=, >, >=) with pointer operands.
SANITIZE_KERNEL_HWADDRESS = 1UL << 30,
/* Shadow Call Stack. */
SANITIZE_SHADOW_CALL_STACK = 1UL << 31,
+ /* Memory Tagging for Stack. */
+ SANITIZE_MEMTAG_STACK = 1ULL << 32,
+ /* Memory Tagging. */
+ SANITIZE_MEMTAG = SANITIZE_MEMTAG_STACK,
SANITIZE_SHIFT = SANITIZE_SHIFT_BASE | SANITIZE_SHIFT_EXPONENT,
SANITIZE_UNDEFINED = SANITIZE_SHIFT | SANITIZE_DIVIDE | SANITIZE_UNREACHABLE
| SANITIZE_VLA | SANITIZE_NULL | SANITIZE_RETURN
report_conflicting_sanitizer_options (opts, loc, SANITIZE_USER_ADDRESS,
SANITIZE_KERNEL_ADDRESS);
+ /* Sanitizers using Memory-Tagging Extension conflict with HWASAN and
+ ASAN. */
+ report_conflicting_sanitizer_options (opts, loc, SANITIZE_MEMTAG,
+ SANITIZE_HWADDRESS);
+ report_conflicting_sanitizer_options (opts, loc, SANITIZE_MEMTAG,
+ SANITIZE_ADDRESS);
+
+ /* Memtag sanitizer implies HWASAN but with tags always generated by
+ the hardware randomly. */
+ if ((opts->x_flag_sanitize & SANITIZE_MEMTAG_STACK)
+ && opts->x_param_hwasan_random_frame_tag == 0)
+ {
+ warning_at (loc, OPT_fsanitize_,
+ "%<--param hwasan-random-frame-tag=0%> is ignored when "
+ "%<-fsanitize=memtag-stack%> is present");
+ opts->x_param_hwasan_random_frame_tag = 1;
+ }
+
/* Check error recovery for -fsanitize-recover option. */
for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
if ((opts->x_flag_sanitize_recover & sanitizer_opts[i].flag)
SANITIZER_OPT (pointer-overflow, SANITIZE_POINTER_OVERFLOW, true, true),
SANITIZER_OPT (builtin, SANITIZE_BUILTIN, true, true),
SANITIZER_OPT (shadow-call-stack, SANITIZE_SHADOW_CALL_STACK, false, false),
+ SANITIZER_OPT (memtag-stack, SANITIZE_MEMTAG_STACK, false, false),
SANITIZER_OPT (all, ~sanitize_code_type (0), true, true),
#undef SANITIZER_OPT
{ NULL, sanitize_code_type (0), 0UL, false, false }
else if (code == OPT_fsanitize_recover_)
flags |= ~(SANITIZE_THREAD | SANITIZE_LEAK
| SANITIZE_UNREACHABLE | SANITIZE_RETURN
- | SANITIZE_SHADOW_CALL_STACK);
+ | SANITIZE_SHADOW_CALL_STACK
+ | SANITIZE_MEMTAG_STACK);
else /* if (code == OPT_fsanitize_trap_) */
flags |= (SANITIZE_UNDEFINED
| SANITIZE_UNDEFINED_NONDEFAULT);
Common Joined UInteger Var(param_hwasan_instrument_mem_intrinsics) Init(1) IntegerRange(0, 1) Param Optimization
Enable hwasan instrumentation of builtin functions.
+-param=memtag-instrument-allocas=
+Target Joined UInteger Var(param_memtag_instrument_allocas) Init(1) IntegerRange(0, 1) Param
+When sanitizing using MTE instructions, add checks for all stack allocas.
+
-param=avg-loop-niter=
Common Joined UInteger Var(param_avg_loop_niter) Init(10) IntegerRange(1, 65536) Param Optimization
Average number of iterations of a loop.