Skip to content

Commit

Permalink
i#4425: handle unspecified-by-the-app sigaction restorer for AArch64 (#…
Browse files Browse the repository at this point in the history
…4840)

Prevents a seg fault in the burst_aarch64_sys test that was caused by reading an unspecified
sigaction restorer in sig_has_restorer() in unix/signal.c. Does so by returning false early
in sig_has_restorer() for AArch64 when the SA_RESTORER flag is not set.

By preventing the seg fault, it also prevents the nested signal handling and consequently
the stack overflow in burst_aarch64_sys test when the -signal_stack_size is not specified.

Issue: #4425
  • Loading branch information
sapostolakis authored Apr 7, 2021
1 parent 4f8d2f9 commit 61a0ed3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions clients/drcachesim/tests/burst_aarch64_sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ post_process()
static std::string
gather_trace()
{
if (!my_setenv("DYNAMORIO_OPTIONS",
// XXX i#4425: Fix debug-build stack overflow issue and
// remove custom signal_stack_size below.
"-stderr_mask 0xc -signal_stack_size 64K "
"-client_lib ';;-offline'"))
if (!my_setenv("DYNAMORIO_OPTIONS", "-stderr_mask 0xc -client_lib ';;-offline'"))
std::cerr << "failed to set env var!\n";

std::cerr << "pre-DR init\n";
Expand Down
11 changes: 11 additions & 0 deletions core/unix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,17 @@ sig_has_restorer(thread_sig_info_t *info, int sig)
return false;
if (TEST(SA_RESTORER, info->app_sigaction[sig]->flags))
return true;
# ifdef AARCH64
/* In AArch64 either the app or the kernel defines a restorer, not glibc, contrary
* to x86/ARM where glibc defines a restorer if the app did not define one. Thus,
* reading info->app_sigaction[sig]->restorer when SA_RESTORER is not specified by
* the app was never an issue for x86/ARM, but for AArch64 if the SA_RESTORER is
* not specified DR will read garbage leading to a seg fault later when
* safe_reading the restorer. To avoid this issue return false early for AArch64 if
* SA_RESTORER is not specified.
*/
return false;
# endif
if (info->app_sigaction[sig]->restorer == NULL)
return false;
/* we cache the result due to the safe_read cost */
Expand Down

0 comments on commit 61a0ed3

Please sign in to comment.