[PATCH] D56954: hwasan: Move memory access checks into small outlined functions on aarch64.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 22 18:20:21 PST 2019
This revision was automatically updated to reflect the committed changes.
pcc marked an inline comment as done.
Closed by commit rCRT351920: hwasan: Move memory access checks into small outlined functions on aarch64. (authored by pcc, committed by ).
Herald added a subscriber: Sanitizers.
Changed prior to commit:
https://reviews.llvm.org/D56954?vs=182661&id=183012#toc
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56954/new/
https://reviews.llvm.org/D56954
Files:
lib/hwasan/hwasan_linux.cc
Index: lib/hwasan/hwasan_linux.cc
===================================================================
--- lib/hwasan/hwasan_linux.cc
+++ lib/hwasan/hwasan_linux.cc
@@ -368,22 +368,27 @@
return AccessInfo{addr, size, is_store, !is_store, recover};
}
-static bool HwasanOnSIGTRAP(int signo, siginfo_t *info, ucontext_t *uc) {
- AccessInfo ai = GetAccessInfo(info, uc);
- if (!ai.is_store && !ai.is_load)
- return false;
-
+static void HandleTagMismatch(AccessInfo ai, uptr pc, uptr frame,
+ ucontext_t *uc) {
InternalMmapVector<BufferedStackTrace> stack_buffer(1);
BufferedStackTrace *stack = stack_buffer.data();
stack->Reset();
- SignalContext sig{info, uc};
- GetStackTrace(stack, kStackTraceMax, StackTrace::GetNextInstructionPc(sig.pc),
- sig.bp, uc, common_flags()->fast_unwind_on_fatal);
+ GetStackTrace(stack, kStackTraceMax, pc, frame, uc,
+ common_flags()->fast_unwind_on_fatal);
++hwasan_report_count;
bool fatal = flags()->halt_on_error || !ai.recover;
ReportTagMismatch(stack, ai.addr, ai.size, ai.is_store, fatal);
+}
+
+static bool HwasanOnSIGTRAP(int signo, siginfo_t *info, ucontext_t *uc) {
+ AccessInfo ai = GetAccessInfo(info, uc);
+ if (!ai.is_store && !ai.is_load)
+ return false;
+
+ SignalContext sig{info, uc};
+ HandleTagMismatch(ai, StackTrace::GetNextInstructionPc(sig.pc), sig.bp, uc);
#if defined(__aarch64__)
uc->uc_mcontext.pc += 4;
@@ -394,6 +399,19 @@
return true;
}
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __hwasan_tag_mismatch(
+ uptr addr, uptr access_info) {
+ AccessInfo ai;
+ ai.is_store = access_info & 0x10;
+ ai.recover = false;
+ ai.addr = addr;
+ ai.size = 1 << (access_info & 0xf);
+
+ HandleTagMismatch(ai, (uptr)__builtin_return_address(0),
+ (uptr)__builtin_frame_address(0), nullptr);
+ __builtin_unreachable();
+}
+
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
GetStackTrace(stack, kStackTraceMax, StackTrace::GetNextInstructionPc(sig.pc),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56954.183012.patch
Type: text/x-patch
Size: 2120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190123/4c53403b/attachment.bin>
More information about the llvm-commits
mailing list