Skip to content

Commit

Permalink
[Pal/Linux] Exit process in case of errors in setup_asan
Browse files Browse the repository at this point in the history
Previously, if mapping ASAN shadow memory failed, process would just
enter an infinite loop. This commit makes it exit the whole process
instead.

Signed-off-by: Borys Popławski <borysp@invisiblethingslab.com>
  • Loading branch information
boryspoplawski authored and dimakuv committed Oct 5, 2021
1 parent 4355bdc commit 6fdde89
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Pal/src/host/Linux/db_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ static void setup_asan(void) {
int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED;
void* addr = (void*)DO_SYSCALL(mmap, (void*)ASAN_SHADOW_START, ASAN_SHADOW_LENGTH, prot, flags,
/*fd=*/-1, /*offset=*/0);
if (IS_PTR_ERR(addr))
if (IS_PTR_ERR(addr)) {
/* We are super early in the init sequence, TCB is not yet set, we probably should not call
* any logging functions. */
DO_SYSCALL(exit_group, PAL_ERROR_NOMEM);
die_or_inf_loop();
}
}
#endif

Expand Down

0 comments on commit 6fdde89

Please sign in to comment.