about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-02-18 23:23:03 +0100
committerGitHub <noreply@github.com>2022-02-18 23:23:03 +0100
commit0bb72a2c66d0daa417baa27eaf2d276d835b87a2 (patch)
tree7a60885694e580e76b90562ba1df9557837151e6 /src/test/codegen
parentf8b83a2aa60d60b60386ef460071261963c8b988 (diff)
parent568aeda9e955ca2a4c043bc2ae7f854e60f6103a (diff)
downloadrust-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 'src/test/codegen')
-rw-r--r--src/test/codegen/sanitizer_memtag_attr_check.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/codegen/sanitizer_memtag_attr_check.rs b/src/test/codegen/sanitizer_memtag_attr_check.rs
new file mode 100644
index 00000000000..2fd362656d4
--- /dev/null
+++ b/src/test/codegen/sanitizer_memtag_attr_check.rs
@@ -0,0 +1,12 @@
+// This tests that the sanitize_memtag attribute is
+// applied when enabling the memtag sanitizer.
+//
+// needs-sanitizer-memtag
+// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte
+
+#![crate_type = "lib"]
+
+// CHECK: ; Function Attrs:{{.*}}sanitize_memtag
+pub fn tagged() {}
+
+// CHECK: attributes #0 = {{.*}}sanitize_memtag