From c5f7f4fc8bb857cbe07972ff1e29970b101e9995 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 31 May 2024 12:26:43 +0200 Subject: x86_64: Use shadow stack for backtrace implementation Test failures: FAIL: debug/tst-backtrace4 FAIL: misc/tst-sigcontext-get_pc The return address of signal handlers is not on the shadow stack. --- debug/backtrace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'debug') diff --git a/debug/backtrace.c b/debug/backtrace.c index 969d699bd1..2ed0112cb8 100644 --- a/debug/backtrace.c +++ b/debug/backtrace.c @@ -20,6 +20,7 @@ #include #include #include +#include struct trace_arg { @@ -63,6 +64,16 @@ backtrace_helper (struct _Unwind_Context *ctx, void *a) int __backtrace (void **array, int size) { + if (size <= 0) + return 0; + + /* Try the architecture-specific implementation first. */ + { + int result = __arch_backtrace (array, size); + if (result >= 0) + return result; + } + struct trace_arg arg = { .array = array, @@ -72,7 +83,7 @@ __backtrace (void **array, int size) .cnt = -1 }; - if (size <= 0 || arg.unwind_link == NULL) + if (arg.unwind_link == NULL) return 0; UNWIND_LINK_PTR (arg.unwind_link, _Unwind_Backtrace) -- cgit v1.2.3