Rollup merge of #91675 - ivanloz:memtagsan, r=nagisa
Add MemTagSanitizer Support Add support for the LLVM [MemTagSanitizer](https://llvm.org/docs/MemTagSanitizer.html). On hardware which supports it (see caveats below), the MemTagSanitizer can catch bugs similar to AddressSanitizer and HardwareAddressSanitizer, but with lower overhead. On a tag mismatch, a SIGSEGV is signaled with code SEGV_MTESERR / SEGV_MTEAERR. # Usage `-Zsanitizer=memtag -C target-feature="+mte"` # Comments/Caveats * MemTagSanitizer is only supported on AArch64 targets with hardware support * Requires `-C target-feature="+mte"` * LLVM MemTagSanitizer currently only performs stack tagging. # TODO * Tests * Example
This commit is contained in:
commit
0bb72a2c66
15 changed files with 67 additions and 6 deletions
|
@ -55,6 +55,19 @@ pub fn sanitize<'ll>(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &
|
|||
if enabled.contains(SanitizerSet::HWADDRESS) {
|
||||
llvm::Attribute::SanitizeHWAddress.apply_llfn(Function, llfn);
|
||||
}
|
||||
if enabled.contains(SanitizerSet::MEMTAG) {
|
||||
// Check to make sure the mte target feature is actually enabled.
|
||||
let sess = cx.tcx.sess;
|
||||
let features = llvm_util::llvm_global_features(sess).join(",");
|
||||
let mte_feature_enabled = features.rfind("+mte");
|
||||
let mte_feature_disabled = features.rfind("-mte");
|
||||
|
||||
if mte_feature_enabled.is_none() || (mte_feature_disabled > mte_feature_enabled) {
|
||||
sess.err("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`");
|
||||
}
|
||||
|
||||
llvm::Attribute::SanitizeMemTag.apply_llfn(Function, llfn);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue