-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add API to temporalily suppress usage of ASAN's fake stack #160135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4e72801
Add API to temporalily disable usage of ASAN's fake stack
happyCoder92 c10e568
Add API to temporalily disable usage of ASAN's fake stack
happyCoder92 0769e3d
Revert "Add API to temporalily disable usage of ASAN's fake stack"
vitalybuka 41c302e
Merge branch 'happyCoder92/main' into HEAD
vitalybuka 7657030
Update test
vitalybuka f56cd99
format
vitalybuka 710eccb
format
vitalybuka 29622a9
format
vitalybuka 4289146
Add thorough tests
happyCoder92 7296b02
Rename the functions & use counter
happyCoder92 4237306
Code formatting
happyCoder92 51c5eba
Merge branch 'main' into main
happyCoder92 5f658bf
Rename test utility & try to fix it for Windows
happyCoder92 32699e3
Explicitly set UAR option as those default to false on Windows
happyCoder92 05ae9b9
Merge branch 'main' into main
happyCoder92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
| // RUN: %clangxx_asan %s -o %t && env ASAN_OPTIONS=detect_stack_use_after_return=1 %run %t | ||
| // RUN: %clangxx_asan %s -mllvm -asan-use-after-return=runtime -o %t && env ASAN_OPTIONS=detect_stack_use_after_return=1 %run %t | ||
| // RUN: %clangxx_asan %s -mllvm -asan-use-after-return=always -o %t && %run %t | ||
|
|
||
| #include "defines.h" | ||
|
|
||
| #include <cassert> | ||
| #include <sanitizer/asan_interface.h> | ||
|
|
||
| volatile uintptr_t saved; | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame, | ||
| uintptr_t var_addr) { | ||
| uintptr_t this_frame = | ||
| reinterpret_cast<uintptr_t>(__builtin_frame_address(0)); | ||
| return this_frame <= var_addr && var_addr <= parent_frame; | ||
| } | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame) { | ||
| volatile char temp = ' '; | ||
| saved = reinterpret_cast<uintptr_t>(&temp); | ||
| return IsOnRealStack(parent_frame, saved); | ||
| } | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack() { | ||
| return IsOnRealStack(reinterpret_cast<uintptr_t>(__builtin_frame_address(0))); | ||
| } | ||
|
|
||
| int main(int argc, char *argv[]) { | ||
| assert(!IsOnRealStack()); | ||
|
|
||
| __asan_suppress_fake_stack(); | ||
| assert(IsOnRealStack()); | ||
|
|
||
| __asan_unsuppress_fake_stack(); | ||
| assert(!IsOnRealStack()); | ||
|
|
||
| return 0; | ||
| } |
40 changes: 40 additions & 0 deletions
40
compiler-rt/test/asan/TestCases/suppress_fake_stack_force_disabled.cpp
This file contains hidden or 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,40 @@ | ||
| // Check unsuppressing fake stack does not reenable it if disabled via compile or runtime options. | ||
| // | ||
| // RUN: %clangxx_asan %s -mllvm -asan-use-after-return=never -o %t && %run %t | ||
| // RUN: %clangxx_asan %s -mllvm -asan-use-after-return=runtime -o %t && env ASAN_OPTIONS=detect_stack_use_after_return=0 %run %t | ||
|
|
||
| #include "defines.h" | ||
|
|
||
| #include <cassert> | ||
| #include <sanitizer/asan_interface.h> | ||
|
|
||
| volatile uintptr_t saved; | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame, | ||
| uintptr_t var_addr) { | ||
| uintptr_t this_frame = | ||
| reinterpret_cast<uintptr_t>(__builtin_frame_address(0)); | ||
| return this_frame <= var_addr && var_addr <= parent_frame; | ||
| } | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame) { | ||
| volatile char temp = ' '; | ||
| saved = reinterpret_cast<uintptr_t>(&temp); | ||
| return IsOnRealStack(parent_frame, saved); | ||
| } | ||
|
|
||
| ATTRIBUTE_NOINLINE bool IsOnRealStack() { | ||
| return IsOnRealStack(reinterpret_cast<uintptr_t>(__builtin_frame_address(0))); | ||
| } | ||
|
|
||
| int main(int argc, char *argv[]) { | ||
| assert(IsOnRealStack()); | ||
|
|
||
| __asan_suppress_fake_stack(); | ||
| assert(IsOnRealStack()); | ||
|
|
||
| __asan_unsuppress_fake_stack(); | ||
| assert(IsOnRealStack()); | ||
|
|
||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.