Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4d2f1ada-2f31-4b44-a30d-dbccb97feba1@yandex.ru>
Date: Mon, 24 Feb 2025 16:35:54 +0300
From: Ivan Trofimov <i.trofimow@...dex.ru>
To: musl@...ts.openwall.com
Subject: [PATCH] x86_64: Generate an eh-frame entry for syscall_cp

Some eBPF-based profilers (open-telemetry/opentelemetry-ebpf-profiler, 
yandex/perforator, parca-dev/parca etc. at github.com) leverage eh-frame 
section to unwind the stacks of native executables in kernel context.

This approach works pretty well most of the time, but sometimes fails to 
unwind through hand-written assembly due to it missing cfi-* directives.
Usually it's not that big of a deal and doesn't change the whole picture 
much, however with musl things are different, since these unwinders fail 
to unwind syscalls back to userspace, as musl doesn't generate an 
eh-frame entry for __syscall_cp function.

Imagine a flamegraph, where all (or most) of the syscalls are completely 
out of place: this is the problem this patch aims to fix for x86-64.

Signed-off-by: Ivan Trofimov <i.trofimow@...dex.ru>

---
  src/thread/x86_64/syscall_cp.s | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/thread/x86_64/syscall_cp.s b/src/thread/x86_64/syscall_cp.s
index 4f101716..296415d7 100644
--- a/src/thread/x86_64/syscall_cp.s
+++ b/src/thread/x86_64/syscall_cp.s
@@ -10,6 +10,7 @@
  .hidden __syscall_cp_asm
  .type   __syscall_cp_asm,@function
  __syscall_cp_asm:
+.cfi_startproc

  __cp_begin:
         mov (%rdi),%eax
@@ -29,3 +30,5 @@ __cp_end:
         ret
  __cp_cancel:
         jmp __cancel
+
+.cfi_endproc
--

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.