diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-18 23:23:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-18 23:23:03 +0100 |
| commit | 0bb72a2c66d0daa417baa27eaf2d276d835b87a2 (patch) | |
| tree | 7a60885694e580e76b90562ba1df9557837151e6 /compiler/rustc_target/src | |
| parent | f8b83a2aa60d60b60386ef460071261963c8b988 (diff) | |
| parent | 568aeda9e955ca2a4c043bc2ae7f854e60f6103a (diff) | |
| download | rust-0bb72a2c66d0daa417baa27eaf2d276d835b87a2.tar.gz rust-0bb72a2c66d0daa417baa27eaf2d276d835b87a2.zip | |
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
Diffstat (limited to 'compiler/rustc_target/src')
| -rw-r--r-- | compiler/rustc_target/src/spec/aarch64_linux_android.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/spec/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/aarch64_linux_android.rs index 1e9abbbe1e7..5692925f63b 100644 --- a/compiler/rustc_target/src/spec/aarch64_linux_android.rs +++ b/compiler/rustc_target/src/spec/aarch64_linux_android.rs @@ -14,7 +14,9 @@ pub fn target() -> Target { // As documented in https://developer.android.com/ndk/guides/cpu-features.html // the neon (ASIMD) and FP must exist on all android aarch64 targets. features: "+neon,+fp-armv8".to_string(), - supported_sanitizers: SanitizerSet::CFI | SanitizerSet::HWADDRESS, + supported_sanitizers: SanitizerSet::CFI + | SanitizerSet::HWADDRESS + | SanitizerSet::MEMTAG, ..super::android_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs index 850381f7fb0..974a5b84d1d 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs @@ -14,6 +14,7 @@ pub fn target() -> Target { | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::MEMORY + | SanitizerSet::MEMTAG | SanitizerSet::THREAD | SanitizerSet::HWADDRESS, ..super::linux_gnu_base::opts() diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index bfafe2d83d7..92678aed5b1 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -606,6 +606,7 @@ bitflags::bitflags! { const THREAD = 1 << 3; const HWADDRESS = 1 << 4; const CFI = 1 << 5; + const MEMTAG = 1 << 6; } } @@ -619,6 +620,7 @@ impl SanitizerSet { SanitizerSet::CFI => "cfi", SanitizerSet::LEAK => "leak", SanitizerSet::MEMORY => "memory", + SanitizerSet::MEMTAG => "memtag", SanitizerSet::THREAD => "thread", SanitizerSet::HWADDRESS => "hwaddress", _ => return None, @@ -652,6 +654,7 @@ impl IntoIterator for SanitizerSet { SanitizerSet::CFI, SanitizerSet::LEAK, SanitizerSet::MEMORY, + SanitizerSet::MEMTAG, SanitizerSet::THREAD, SanitizerSet::HWADDRESS, ] @@ -1883,6 +1886,7 @@ impl Target { Some("cfi") => SanitizerSet::CFI, Some("leak") => SanitizerSet::LEAK, Some("memory") => SanitizerSet::MEMORY, + Some("memtag") => SanitizerSet::MEMTAG, Some("thread") => SanitizerSet::THREAD, Some("hwaddress") => SanitizerSet::HWADDRESS, Some(s) => return Err(format!("unknown sanitizer {}", s)), |
