[PATCH] D42023: [hwasan] An LLVM flag to disable stack tag randomization.
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 12 17:33:32 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT322429: [hwasan] An LLVM flag to disable stack tag randomization. (authored by eugenis, committed by ).
Herald added a subscriber: Sanitizers.
Changed prior to commit:
https://reviews.llvm.org/D42023?vs=129739&id=129741#toc
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D42023
Files:
lib/hwasan/hwasan.cc
lib/hwasan/hwasan_interface_internal.h
test/hwasan/lit.cfg
Index: lib/hwasan/hwasan_interface_internal.h
===================================================================
--- lib/hwasan/hwasan_interface_internal.h
+++ lib/hwasan/hwasan_interface_internal.h
@@ -86,6 +86,9 @@
SANITIZER_INTERFACE_ATTRIBUTE
void __hwasan_tag_memory(uptr p, u8 tag, uptr sz);
+SANITIZER_INTERFACE_ATTRIBUTE
+u8 __hwasan_generate_tag();
+
// Returns the offset of the first tag mismatch or -1 if the whole range is
// good.
SANITIZER_INTERFACE_ATTRIBUTE
Index: lib/hwasan/hwasan.cc
===================================================================
--- lib/hwasan/hwasan.cc
+++ lib/hwasan/hwasan.cc
@@ -363,6 +363,14 @@
TagMemoryAligned(p, sz, tag);
}
+static const u8 kFallbackTag = 0xBB;
+
+u8 __hwasan_generate_tag() {
+ HwasanThread *t = GetCurrentThread();
+ if (!t) return kFallbackTag;
+ return t->GenerateRandomTag();
+}
+
#if !SANITIZER_SUPPORTS_WEAK_HOOKS
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
Index: test/hwasan/lit.cfg
===================================================================
--- test/hwasan/lit.cfg
+++ test/hwasan/lit.cfg
@@ -9,7 +9,7 @@
config.test_source_root = os.path.dirname(__file__)
# Setup default compiler flags used with -fsanitize=memory option.
-clang_hwasan_cflags = ["-fsanitize=hwaddress", config.target_cflags] + config.debug_info_flags
+clang_hwasan_cflags = ["-fsanitize=hwaddress", "-mllvm", "-hwasan-generate-tags-with-calls", config.target_cflags] + config.debug_info_flags
clang_hwasan_cxxflags = config.cxx_mode_flags + clang_hwasan_cflags
def build_invocation(compile_flags):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42023.129741.patch
Type: text/x-patch
Size: 1605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180113/8362b1ee/attachment.bin>
More information about the llvm-commits
mailing list