This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hwasan: Untag unwound stack frames by wrapping personality functions.
One problem with untagging memory in landing pads is that it only works correctly if the function that catches the exception is instrumented. If the function is uninstrumented, we have no opportunity to untag the memory. To address this, replace landing pad instrumentation with personality function wrapping. Each function with an instrumented stack has its personality function replaced with a wrapper provided by the runtime. Functions that did not have a personality function to begin with also get wrappers if they may be unwound past. As the unwinder calls personality functions during stack unwinding, the original personality function is called and the function's stack frame is untagged by the wrapper if the personality function instructs the unwinder to keep unwinding. If unwinding stops at a landing pad, the function is still responsible for untagging its stack frame if it resumes unwinding. The old landing pad mechanism is preserved for compatibility with old runtimes. Differential Revision: https://reviews.llvm.org/D66377 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369721 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
4 changed files
with
199 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
; RUN: opt < %s -mtriple aarch64-linux-android29 -hwasan -S | FileCheck %s --check-prefix=NOPERS | ||
; RUN: opt < %s -mtriple aarch64-linux-android30 -hwasan -S | FileCheck %s --check-prefix=PERS | ||
|
||
; NOPERS: define void @nostack() #{{[0-9]+}} { | ||
; PERS: define void @nostack() #{{[0-9]+}} { | ||
define void @nostack() sanitize_hwaddress { | ||
ret void | ||
} | ||
|
||
; NOPERS: define void @stack1() #{{[0-9]+}} { | ||
; PERS: personality {{.*}} @__hwasan_personality_thunk | ||
define void @stack1() sanitize_hwaddress { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
|
||
; NOPERS: personality void ()* @global | ||
; PERS: personality {{.*}} @__hwasan_personality_thunk.global | ||
define void @stack2() sanitize_hwaddress personality void ()* @global { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
define internal void @local() { | ||
ret void | ||
} | ||
|
||
@local_alias = internal alias void (), void ()* @local | ||
|
||
; NOPERS: personality void ()* @local | ||
; PERS: personality {{.*}} @__hwasan_personality_thunk.local | ||
define void @stack3() sanitize_hwaddress personality void ()* @local { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
; NOPERS: personality void ()* @local_alias | ||
; PERS: personality {{.*}} @__hwasan_personality_thunk.local_alias | ||
define void @stack4() sanitize_hwaddress personality void ()* @local_alias { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
; NOPERS: personality void ()* inttoptr (i64 1 to void ()*) | ||
; PERS: personality i32 (i32, i32, i64, i8*, i8*)* @__hwasan_personality_thunk. | ||
define void @stack5() sanitize_hwaddress personality void ()* inttoptr (i64 1 to void ()*) { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
; NOPERS: personality void ()* inttoptr (i64 2 to void ()*) | ||
; PERS: personality i32 (i32, i32, i64, i8*, i8*)* @__hwasan_personality_thunk..1 | ||
define void @stack6() sanitize_hwaddress personality void ()* inttoptr (i64 2 to void ()*) { | ||
%p = alloca i8 | ||
call void @sink(i8* %p) | ||
ret void | ||
} | ||
|
||
declare void @global() | ||
declare void @sink(i8*) | ||
|
||
; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) comdat | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* null, i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 | ||
|
||
; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.global(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) comdat | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @global to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 | ||
|
||
; PERS: define internal i32 @__hwasan_personality_thunk.local(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @local to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 | ||
|
||
; PERS: define internal i32 @__hwasan_personality_thunk.local_alias(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @local_alias to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 | ||
|
||
; PERS: define internal i32 @__hwasan_personality_thunk.(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) { | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* inttoptr (i64 1 to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 | ||
|
||
; PERS: define internal i32 @__hwasan_personality_thunk..1(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) { | ||
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* inttoptr (i64 2 to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*)) | ||
; PERS: ret i32 %5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters