[PATCH] D118948: [MTE] Add -fsanitize=memtag* and friends.

Mitch Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 3 14:34:03 PST 2022


hctim created this revision.
hctim added a reviewer: eugenis.
Herald added subscribers: dexonsmith, dang, arichardson, emaste.
Herald added a reviewer: MaskRay.
hctim requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently, enablement of heap MTE on Android is specified by an ELF note, which
signals to the linker to enable heap MTE. This change allows
-fsanitize=memtag-heap to synthesize these notes, rather than adding them
through the build system. We need to extend this feature to also signal the
linker to do special work for MTE globals (in future) and MTE stack (currently
implemented in the toolchain, but not implemented in the loader).

Current Android uses a non-backwards-compatible ELF note, called
".note.android.memtag". Stack MTE is an ABI break anyway, so we don't mind that
we won't be able to run executables with stack MTE on Android 11/12 devices.

The current expectation is to support the verbiage used by Android, in
that "SYNC" means MTE Synchronous mode, and "ASYNC" effectively means
"fast", using the Kernel auto-upgrade feature that allows
hardware-specific and core-specific configuration as to whether "ASYNC"
would end up being Asynchronous, Asymmetric, or Synchronous on that
particular core, whichever has a reasonable performance delta. Of
course, this is platform and loader-specific.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118948

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Sanitizers.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/Driver/fsanitize.c
  clang/test/Driver/memtag-ld.c
  clang/test/Driver/memtag-stack.c
  clang/test/Driver/memtag.c
  clang/test/Lexer/has_feature_memtag_heap.cpp
  clang/test/Lexer/has_feature_memtag_sanitizer.cpp
  clang/test/Lexer/has_feature_memtag_stack.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp
  lld/test/ELF/memtag-android-abi.s
  llvm/include/llvm/BinaryFormat/ELF.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118948.405798.patch
Type: text/x-patch
Size: 28022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220203/14cd7660/attachment-0001.bin>


More information about the cfe-commits mailing list