forked from gramineproject/gramine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[common,Pal,LibOS] ASan: Enable stack sanitization
The current implementation is able to catch stack buffer overflows and use-after-scope bugs (but not use-after-return). The implementation requires Gramine to maintain proper hygiene when handling stack memory. Otherwise, false positives are possible: if Gramine stops using a stack (e.g. when returning from a syscall), but doesn't unpoison it, the poisoned stack memory can incorrectly trigger ASan the next time that stack is used. Signed-off-by: Paweł Marczewski <[email protected]>
- Loading branch information
Showing
19 changed files
with
278 additions
and
56 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
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* Borys Popławski <[email protected]> | ||
*/ | ||
|
||
#include "asan.h" | ||
#include "shim_defs.h" | ||
#include "shim_internal.h" | ||
#include "shim_table.h" | ||
|
@@ -62,3 +63,13 @@ noreturn void shim_emulate_syscall(PAL_CONTEXT* context) { | |
|
||
return_from_syscall(context); | ||
} | ||
|
||
__attribute_no_sanitize_address | ||
noreturn void return_from_syscall(PAL_CONTEXT* context) { | ||
#ifdef ASAN | ||
uintptr_t libos_stack_bottom = (uintptr_t)SHIM_TCB_GET(libos_stack_bottom); | ||
asan_unpoison_region(libos_stack_bottom - SHIM_THREAD_LIBOS_STACK_SIZE, | ||
SHIM_THREAD_LIBOS_STACK_SIZE); | ||
#endif | ||
_return_from_syscall(context); | ||
} |
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
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
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
Oops, something went wrong.