From 61a0ed3d308e3b18c13ff890aa1f47dc403b681c Mon Sep 17 00:00:00 2001 From: Sotiris Apostolakis Date: Wed, 7 Apr 2021 12:11:26 -0400 Subject: [PATCH] i#4425: handle unspecified-by-the-app sigaction restorer for AArch64 (#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 --- clients/drcachesim/tests/burst_aarch64_sys.cpp | 6 +----- core/unix/signal.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clients/drcachesim/tests/burst_aarch64_sys.cpp b/clients/drcachesim/tests/burst_aarch64_sys.cpp index 1b274ea20f8..f8807d6a141 100644 --- a/clients/drcachesim/tests/burst_aarch64_sys.cpp +++ b/clients/drcachesim/tests/burst_aarch64_sys.cpp @@ -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"; diff --git a/core/unix/signal.c b/core/unix/signal.c index 882523fe10a..4dd105ab296 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -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 */